Skip to content

Commit 1ca226b

Browse files
authored
Merge pull request #2 from aws/master
Fetch and merge from the upstream branch aws/chalice
2 parents a18cb8f + d6a9d8d commit 1ca226b

File tree

5 files changed

+54
-37
lines changed

5 files changed

+54
-37
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"type": "enhancement",
3+
"category": "Pip",
4+
"description": "Bump pip version range to latest version <22.2 (#1924)"
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"type": "enhancement",
3+
"category": "Websockets",
4+
"description": "Add support for WebSockets API Terraform packaging (#1670)"
5+
}

chalice/package.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ def service_principal(self, service):
101101
class ResourceBuilder(object):
102102
def __init__(self,
103103
application_builder, # type: ApplicationGraphBuilder
104-
deps_builder, # type: DependencyBuilder
105-
build_stage, # type: BuildStage
104+
deps_builder, # type: DependencyBuilder
105+
build_stage, # type: BuildStage
106106
):
107107
# type: (...) -> None
108108
self._application_builder = application_builder
@@ -970,17 +970,21 @@ def _inject_websocketapi_outputs(self, websocket_api_id, template):
970970
output['WebsocketConnectHandlerArn'] = {
971971
"value": "${aws_lambda_function.websocket_connect.arn}"}
972972
output['WebsocketConnectHandlerName'] = {
973-
"value": "${aws_lambda_function.websocket_connect}"}
973+
"value": (
974+
"${aws_lambda_function.websocket_connect.function_name}")}
974975
if 'websocket_message' in aws_lambda_functions:
975976
output['WebsocketMessageHandlerArn'] = {
976977
"value": "${aws_lambda_function.websocket_message.arn}"}
977978
output['WebsocketMessageHandlerName'] = {
978-
"value": "${aws_lambda_function.websocket_message}"}
979+
"value": (
980+
"${aws_lambda_function.websocket_message.function_name}")}
979981
if 'websocket_disconnect' in aws_lambda_functions:
980982
output['WebsocketDisconnectHandlerArn'] = {
981983
"value": "${aws_lambda_function.websocket_disconnect.arn}"}
982984
output['WebsocketDisconnectHandlerName'] = {
983-
"value": "${aws_lambda_function.websocket_disconnect}"}
985+
"value": (
986+
"${aws_lambda_function.websocket_disconnect"
987+
".function_name}")}
984988

985989
output['WebsocketConnectEndpointURL'] = {
986990
"value": (
@@ -1205,10 +1209,10 @@ def _generate_lambdalayer(self, resource, template):
12051209
# type: (models.LambdaLayer, Dict[str, Any]) -> None
12061210
template['resource'].setdefault(
12071211
"aws_lambda_layer_version", {})[
1208-
resource.resource_name] = {
1209-
'layer_name': resource.layer_name,
1210-
'compatible_runtimes': [resource.runtime],
1211-
'filename': resource.deployment_package.filename,
1212+
resource.resource_name] = {
1213+
'layer_name': resource.layer_name,
1214+
'compatible_runtimes': [resource.runtime],
1215+
'filename': resource.deployment_package.filename,
12121216
}
12131217
self._chalice_layer = resource.resource_name
12141218

@@ -1337,8 +1341,7 @@ def _generate_restapi(self, resource, template):
13371341
'principal': self._options.service_principal('apigateway'),
13381342
'source_arn': (
13391343
"${aws_api_gateway_rest_api.%s.execution_arn}" % (
1340-
resource.resource_name
1341-
) + "/*"
1344+
resource.resource_name) + "/*"
13421345
)
13431346
}
13441347
self._add_domain_name(resource, template)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def recursive_include(relative_dir):
2525
'typing==3.6.4;python_version<"3.7"',
2626
'mypy-extensions==0.4.3',
2727
'six>=1.10.0,<2.0.0',
28-
'pip>=9,<22.1',
28+
'pip>=9,<22.2',
2929
'attrs>=19.3.0,<21.5.0',
3030
'jmespath>=0.9.3,<2.0.0',
3131
'pyyaml>=5.3.1,<7.0.0',

tests/unit/test_package.py

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -816,19 +816,23 @@ def test_can_generate_websockets_api(self, sample_websocket_app):
816816
'value': '${aws_lambda_function.websocket_connect.arn}'
817817
},
818818
'WebsocketConnectHandlerName': {
819-
'value': '${aws_lambda_function.websocket_connect}'
819+
'value': (
820+
'${aws_lambda_function.websocket_connect.function_name}')
820821
},
821822
'WebsocketMessageHandlerArn': {
822823
'value': '${aws_lambda_function.websocket_message.arn}'
823824
},
824825
'WebsocketMessageHandlerName': {
825-
'value': '${aws_lambda_function.websocket_message}'
826+
'value': (
827+
'${aws_lambda_function.websocket_message.function_name}')
826828
},
827829
'WebsocketDisconnectHandlerArn': {
828830
'value': '${aws_lambda_function.websocket_disconnect.arn}'
829831
},
830832
'WebsocketDisconnectHandlerName': {
831-
'value': '${aws_lambda_function.websocket_disconnect}'
833+
'value': (
834+
'${aws_lambda_function.websocket_disconnect'
835+
'.function_name}')
832836
},
833837
'WebsocketConnectEndpointURL': {
834838
'value': 'wss://${aws_apigatewayv2_api.websocket_api.id}'
@@ -984,19 +988,19 @@ def test_can_generate_custom_domain_name(self, sample_app):
984988
)
985989
template = self.generate_template(config)
986990
assert template['resource']['aws_api_gateway_domain_name'][
987-
'api_gateway_custom_domain'] == {
988-
'domain_name': 'example.com',
989-
'certificate_arn': 'my_cert_arn',
990-
'security_policy': 'TLS_1_2',
991-
'endpoint_configuration': {'types': ['EDGE']},
992-
'tags': {'foo': 'bar'},
993-
}
991+
'api_gateway_custom_domain'] == {
992+
'domain_name': 'example.com',
993+
'certificate_arn': 'my_cert_arn',
994+
'security_policy': 'TLS_1_2',
995+
'endpoint_configuration': {'types': ['EDGE']},
996+
'tags': {'foo': 'bar'},
997+
}
994998
assert template['resource']['aws_api_gateway_base_path_mapping'][
995-
'api_gateway_custom_domain_mapping'] == {
996-
'api_id': '${aws_api_gateway_rest_api.rest_api.id}',
997-
'stage_name': 'api',
998-
'domain_name': 'example.com',
999-
}
999+
'api_gateway_custom_domain_mapping'] == {
1000+
'api_id': '${aws_api_gateway_rest_api.rest_api.id}',
1001+
'stage_name': 'api',
1002+
'domain_name': 'example.com',
1003+
}
10001004
outputs = template['output']
10011005
assert outputs['AliasDomainName']['value'] == (
10021006
'${aws_api_gateway_domain_name.api_gateway_custom_domain'
@@ -1020,17 +1024,17 @@ def test_can_generate_domain_for_regional_endpoint(self, sample_app):
10201024
)
10211025
template = self.generate_template(config)
10221026
assert template['resource']['aws_api_gateway_domain_name'][
1023-
'api_gateway_custom_domain'] == {
1024-
'domain_name': 'example.com',
1025-
'regional_certificate_arn': 'my_cert_arn',
1026-
'endpoint_configuration': {'types': ['REGIONAL']},
1027-
}
1027+
'api_gateway_custom_domain'] == {
1028+
'domain_name': 'example.com',
1029+
'regional_certificate_arn': 'my_cert_arn',
1030+
'endpoint_configuration': {'types': ['REGIONAL']},
1031+
}
10281032
assert template['resource']['aws_api_gateway_base_path_mapping'][
1029-
'api_gateway_custom_domain_mapping'] == {
1030-
'api_id': '${aws_api_gateway_rest_api.rest_api.id}',
1031-
'stage_name': 'api',
1032-
'domain_name': 'example.com',
1033-
}
1033+
'api_gateway_custom_domain_mapping'] == {
1034+
'api_id': '${aws_api_gateway_rest_api.rest_api.id}',
1035+
'stage_name': 'api',
1036+
'domain_name': 'example.com',
1037+
}
10341038
outputs = template['output']
10351039
assert outputs['AliasDomainName']['value'] == (
10361040
'${aws_api_gateway_domain_name.api_gateway_custom_domain'

0 commit comments

Comments
 (0)