Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IT-3506] Address lambda timeout issue from 2024-03-02 #22

Merged
merged 1 commit into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions email_totals/ce.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,22 @@
from datetime import datetime, timedelta

import boto3
from botocore.config import Config as BotoConfig


LOG = logging.getLogger(__name__)
LOG.setLevel(logging.DEBUG)

ce_client = boto3.client('ce')

cost_metric = 'NetAmortizedCost'

# Use adaptive mode in an attempt to optimize retry back-off
ce_config = BotoConfig(
retries = {
'mode': 'adaptive', # default mode is legacy
}
)
ce_client = boto3.client('ce', config=ce_config)

# get_cost_and_usage_with_resources() can only look back at most 14 days,
# but we only need current resources missing tags, so hard-code the period
# to be yesterday; store it in a global variable to avoid recalculating it
Expand Down
5 changes: 0 additions & 5 deletions email_totals/ses.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,11 +462,6 @@ def send_email(recipients, subject, body_html, body_text):
Source=sender,
)

# We need to rate limit our calls to 'send_email', our current SES
# quota allows for sending 14 emails per second, sleep for 72ms after
# each call to send a maximum of 14 emails in 1008ms.
time.sleep(0.072)

# Display an error if something goes wrong.
except ClientError as e:
LOG.exception(e)
Expand Down
2 changes: 1 addition & 1 deletion template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Parameters:
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
Timeout: 60
Timeout: 120

Resources:
#lambda execution role config
Expand Down
Loading