From c3620088d5850e80c5460e19e1d145fbf1b3b612 Mon Sep 17 00:00:00 2001 From: Daniel Sotirhos Date: Mon, 15 Jul 2024 17:29:21 -0700 Subject: [PATCH] Fix: Service responses are not compressed (#6360) --- lambdas/indexer/.chalice/config.json.template.py | 1 - lambdas/service/.chalice/config.json.template.py | 1 - src/azul/terraform.py | 6 ++++++ test/test_openapi.py | 9 +++++++-- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lambdas/indexer/.chalice/config.json.template.py b/lambdas/indexer/.chalice/config.json.template.py index 6751ef223..dd77ae946 100644 --- a/lambdas/indexer/.chalice/config.json.template.py +++ b/lambdas/indexer/.chalice/config.json.template.py @@ -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), diff --git a/lambdas/service/.chalice/config.json.template.py b/lambdas/service/.chalice/config.json.template.py index 46747fb3d..c40dff944 100644 --- a/lambdas/service/.chalice/config.json.template.py +++ b/lambdas/service/.chalice/config.json.template.py @@ -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), diff --git a/src/azul/terraform.py b/src/azul/terraform.py index 84b5fffad..3849f7d58 100644 --- a/src/azul/terraform.py +++ b/src/azul/terraform.py @@ -793,6 +793,12 @@ def tf_config(self, app_name): del deployment['lifecycle'] deployment['triggers'] = {'redeployment': deployment.pop('stage_description')} + swagger_doc = json.loads(locals[app_name]) + swagger_doc.update({ + 'x-amazon-apigateway-minimum-compression-size': config.minimum_compression_size + }) + locals[app_name] = json.dumps(swagger_doc) + return { 'resource': resources, 'data': data, diff --git a/test/test_openapi.py b/test/test_openapi.py index 0fb24e034..e543b2284 100644 --- a/test/test_openapi.py +++ b/test/test_openapi.py @@ -33,9 +33,14 @@ def app(self, spec): return AzulChaliceApp('testing', '/app.py', spec=spec) def test_top_level_spec(self): - spec = {'foo': 'bar'} + spec = { + 'foo': 'bar', + } app = self.app(spec) - self.assertEqual(app._specs, {'foo': 'bar', 'paths': {}}, "Confirm 'paths' is added") + self.assertEqual(app._specs, { + 'foo': 'bar', + 'paths': {} + }, "Confirm 'paths' is added") spec['new key'] = 'new value' self.assertNotIn('new key', app.spec(), 'Changing input object should not affect specs')