Skip to content

Commit

Permalink
Set Lambda function log retention, add FIXME (#6070, #6911)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsotirho-ucsc committed Feb 20, 2025
1 parent 7b09ffa commit 9a898f1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions scripts/import_cloudwatch_log_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ def resource(name):
name, stage = config.unqualified_resource_name(name)
if stage == config.deployment_stage:
log_groups[resource('chatbot')] = group_name
elif not tf_component:
# Lambda functions
if group_name.startswith('/aws/lambda'):
name = group_name.rpartition('/')[2]
name, stage, suffix = config.unqualified_resource_name_and_suffix(name)
if stage == config.deployment_stage:
name = name + (f'_{suffix[1:]}' if suffix else '') + '_lambda'
log_groups[resource(name)] = group_name
else:
pass

Expand Down
3 changes: 3 additions & 0 deletions terraform/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ rename_resources: validate

.PHONY: import_resources
import_resources: rename_resources
@# FIXME: Remove once the log groups have been imported into all deployments
@# https://github.com/DataBiosphere/azul/issues/6911
python $(project_root)/scripts/import_cloudwatch_log_groups.py

.PHONY: plan
plan: import_resources
Expand Down
7 changes: 7 additions & 0 deletions terraform/api_gateway.tf.json.template.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,13 @@ def for_domain(cls, domain):
f'{app.name}_api_gateway': {
'name': '/aws/apigateway/' + config.qualified_resource_name(app.name),
'retention_in_days': config.audit_log_retention_days,
},
**{
f'{resource_name}_lambda': {
'name': f'/aws/lambda/{resource['function_name']}',
'retention_in_days': config.audit_log_retention_days
} for resource_name, resource in
chalice.tf_config(app.name)['resource']['aws_lambda_function'].items()
}
},
'aws_iam_role': {
Expand Down

0 comments on commit 9a898f1

Please sign in to comment.