-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into bump-cdk
* origin/main: (22 commits) Add use case files Bumped version CDK due python deprecation in EKS modules (#267) Bumped version CDK due python deprecation in EKS modules Replace banner text Removed CDK Nag dependencies update deps revert dependencies dotnet7 Update services.ts to include a specific addonVersion update deps revert dependencies dotnet7 Removed Fluentbit dashboard after oteladdon Enabling AWS Observbility Enhanced monitoring for EKS and removed manifests update deps revert dependencies dotnet7 Added Application insights module code Bump staging to main (#254) update deps ...
- Loading branch information
Showing
7 changed files
with
618 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
PetAdoptions/cdk/pet_stack/resources/application-insights/dynamodb-query-function.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import os | ||
import time | ||
import boto3 | ||
from boto3.dynamodb.conditions import Key | ||
|
||
dynamodb = boto3.resource('dynamodb') | ||
DYNAMODB_TABLE_NAME = os.environ['DYNAMODB_TABLE_NAME'] | ||
|
||
def lambda_handler(event, context): | ||
table = dynamodb.Table(DYNAMODB_TABLE_NAME) | ||
error_mode = event.get('error_mode') | ||
if error_mode == 'true': | ||
query_key = 'wrongKey' | ||
else: | ||
query_key = 'pettype' | ||
t_end = time.time() + 60 * 13 | ||
while time.time() < t_end: | ||
try: | ||
response = table.query( | ||
KeyConditionExpression=Key(query_key).eq('puppy') | ||
) | ||
items = response['Items'] | ||
except Exception as e: | ||
print("An exception occurred, but still continuing. The error is: ",e) | ||
items = "FunctionError" | ||
time.sleep(30) | ||
return { | ||
'statusCode': 200, | ||
'body': items | ||
} |
Oops, something went wrong.