Skip to content

Commit

Permalink
Fix: Service responses are not compressed (#6360, PR #6412)
Browse files Browse the repository at this point in the history
  • Loading branch information
achave11-ucsc committed Aug 15, 2024
2 parents e1bb690 + 606e717 commit d4f970b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
1 change: 0 additions & 1 deletion lambdas/indexer/.chalice/config.json.template.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"manage_iam_role": False,
"iam_role_arn": "${aws_iam_role.%s.arn}" % app_name,
"environment_variables": config.lambda_env,
"minimum_compression_size": config.minimum_compression_size,
"lambda_timeout": config.api_gateway_lambda_timeout,
"lambda_memory_size": 128,
**chalice.vpc_lambda_config(app_name),
Expand Down
1 change: 0 additions & 1 deletion lambdas/service/.chalice/config.json.template.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"manage_iam_role": False,
"iam_role_arn": "${aws_iam_role.%s.arn}" % app_name,
"environment_variables": config.lambda_env,
"minimum_compression_size": config.minimum_compression_size,
"lambda_timeout": config.api_gateway_lambda_timeout,
"lambda_memory_size": 2048,
**chalice.vpc_lambda_config(app_name),
Expand Down
14 changes: 14 additions & 0 deletions src/azul/terraform.py
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,20 @@ def tf_config(self, app_name):
del deployment['lifecycle']
deployment['triggers'] = {'redeployment': deployment.pop('stage_description')}

# Using Terraform to specify the REST API minimum compression size
# proved to be problematic as it would first make an UpdateRestApi call
# to set the property, followed by a PutRestApi call with mode=overwrite
# which would reset the property back to its default value (disabled).
# Setting this property using AWS API Gateway extensions to the OpenAPI
# specification works around this issue.
#
rest_api = resources['aws_api_gateway_rest_api'][app_name]
assert 'minimum_compression_size' not in rest_api, rest_api
openapi_spec = json.loads(locals[app_name])
key = 'x-amazon-apigateway-minimum-compression-size'
openapi_spec[key] = config.minimum_compression_size
locals[app_name] = json.dumps(openapi_spec)

return {
'resource': resources,
'data': data,
Expand Down

0 comments on commit d4f970b

Please sign in to comment.