Skip to content

Commit

Permalink
Merge pull request #2 from aws/master
Browse files Browse the repository at this point in the history
Fetch and merge from the upstream branch aws/chalice
  • Loading branch information
adityamohta authored May 18, 2022
2 parents a18cb8f + d6a9d8d commit 1ca226b
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 37 deletions.
5 changes: 5 additions & 0 deletions .changes/next-release/35786244445-enhancement-Pip-39203.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "enhancement",
"category": "Pip",
"description": "Bump pip version range to latest version <22.2 (#1924)"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "enhancement",
"category": "Websockets",
"description": "Add support for WebSockets API Terraform packaging (#1670)"
}
25 changes: 14 additions & 11 deletions chalice/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ def service_principal(self, service):
class ResourceBuilder(object):
def __init__(self,
application_builder, # type: ApplicationGraphBuilder
deps_builder, # type: DependencyBuilder
build_stage, # type: BuildStage
deps_builder, # type: DependencyBuilder
build_stage, # type: BuildStage
):
# type: (...) -> None
self._application_builder = application_builder
Expand Down Expand Up @@ -970,17 +970,21 @@ def _inject_websocketapi_outputs(self, websocket_api_id, template):
output['WebsocketConnectHandlerArn'] = {
"value": "${aws_lambda_function.websocket_connect.arn}"}
output['WebsocketConnectHandlerName'] = {
"value": "${aws_lambda_function.websocket_connect}"}
"value": (
"${aws_lambda_function.websocket_connect.function_name}")}
if 'websocket_message' in aws_lambda_functions:
output['WebsocketMessageHandlerArn'] = {
"value": "${aws_lambda_function.websocket_message.arn}"}
output['WebsocketMessageHandlerName'] = {
"value": "${aws_lambda_function.websocket_message}"}
"value": (
"${aws_lambda_function.websocket_message.function_name}")}
if 'websocket_disconnect' in aws_lambda_functions:
output['WebsocketDisconnectHandlerArn'] = {
"value": "${aws_lambda_function.websocket_disconnect.arn}"}
output['WebsocketDisconnectHandlerName'] = {
"value": "${aws_lambda_function.websocket_disconnect}"}
"value": (
"${aws_lambda_function.websocket_disconnect"
".function_name}")}

output['WebsocketConnectEndpointURL'] = {
"value": (
Expand Down Expand Up @@ -1205,10 +1209,10 @@ def _generate_lambdalayer(self, resource, template):
# type: (models.LambdaLayer, Dict[str, Any]) -> None
template['resource'].setdefault(
"aws_lambda_layer_version", {})[
resource.resource_name] = {
'layer_name': resource.layer_name,
'compatible_runtimes': [resource.runtime],
'filename': resource.deployment_package.filename,
resource.resource_name] = {
'layer_name': resource.layer_name,
'compatible_runtimes': [resource.runtime],
'filename': resource.deployment_package.filename,
}
self._chalice_layer = resource.resource_name

Expand Down Expand Up @@ -1337,8 +1341,7 @@ def _generate_restapi(self, resource, template):
'principal': self._options.service_principal('apigateway'),
'source_arn': (
"${aws_api_gateway_rest_api.%s.execution_arn}" % (
resource.resource_name
) + "/*"
resource.resource_name) + "/*"
)
}
self._add_domain_name(resource, template)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def recursive_include(relative_dir):
'typing==3.6.4;python_version<"3.7"',
'mypy-extensions==0.4.3',
'six>=1.10.0,<2.0.0',
'pip>=9,<22.1',
'pip>=9,<22.2',
'attrs>=19.3.0,<21.5.0',
'jmespath>=0.9.3,<2.0.0',
'pyyaml>=5.3.1,<7.0.0',
Expand Down
54 changes: 29 additions & 25 deletions tests/unit/test_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -816,19 +816,23 @@ def test_can_generate_websockets_api(self, sample_websocket_app):
'value': '${aws_lambda_function.websocket_connect.arn}'
},
'WebsocketConnectHandlerName': {
'value': '${aws_lambda_function.websocket_connect}'
'value': (
'${aws_lambda_function.websocket_connect.function_name}')
},
'WebsocketMessageHandlerArn': {
'value': '${aws_lambda_function.websocket_message.arn}'
},
'WebsocketMessageHandlerName': {
'value': '${aws_lambda_function.websocket_message}'
'value': (
'${aws_lambda_function.websocket_message.function_name}')
},
'WebsocketDisconnectHandlerArn': {
'value': '${aws_lambda_function.websocket_disconnect.arn}'
},
'WebsocketDisconnectHandlerName': {
'value': '${aws_lambda_function.websocket_disconnect}'
'value': (
'${aws_lambda_function.websocket_disconnect'
'.function_name}')
},
'WebsocketConnectEndpointURL': {
'value': 'wss://${aws_apigatewayv2_api.websocket_api.id}'
Expand Down Expand Up @@ -984,19 +988,19 @@ def test_can_generate_custom_domain_name(self, sample_app):
)
template = self.generate_template(config)
assert template['resource']['aws_api_gateway_domain_name'][
'api_gateway_custom_domain'] == {
'domain_name': 'example.com',
'certificate_arn': 'my_cert_arn',
'security_policy': 'TLS_1_2',
'endpoint_configuration': {'types': ['EDGE']},
'tags': {'foo': 'bar'},
}
'api_gateway_custom_domain'] == {
'domain_name': 'example.com',
'certificate_arn': 'my_cert_arn',
'security_policy': 'TLS_1_2',
'endpoint_configuration': {'types': ['EDGE']},
'tags': {'foo': 'bar'},
}
assert template['resource']['aws_api_gateway_base_path_mapping'][
'api_gateway_custom_domain_mapping'] == {
'api_id': '${aws_api_gateway_rest_api.rest_api.id}',
'stage_name': 'api',
'domain_name': 'example.com',
}
'api_gateway_custom_domain_mapping'] == {
'api_id': '${aws_api_gateway_rest_api.rest_api.id}',
'stage_name': 'api',
'domain_name': 'example.com',
}
outputs = template['output']
assert outputs['AliasDomainName']['value'] == (
'${aws_api_gateway_domain_name.api_gateway_custom_domain'
Expand All @@ -1020,17 +1024,17 @@ def test_can_generate_domain_for_regional_endpoint(self, sample_app):
)
template = self.generate_template(config)
assert template['resource']['aws_api_gateway_domain_name'][
'api_gateway_custom_domain'] == {
'domain_name': 'example.com',
'regional_certificate_arn': 'my_cert_arn',
'endpoint_configuration': {'types': ['REGIONAL']},
}
'api_gateway_custom_domain'] == {
'domain_name': 'example.com',
'regional_certificate_arn': 'my_cert_arn',
'endpoint_configuration': {'types': ['REGIONAL']},
}
assert template['resource']['aws_api_gateway_base_path_mapping'][
'api_gateway_custom_domain_mapping'] == {
'api_id': '${aws_api_gateway_rest_api.rest_api.id}',
'stage_name': 'api',
'domain_name': 'example.com',
}
'api_gateway_custom_domain_mapping'] == {
'api_id': '${aws_api_gateway_rest_api.rest_api.id}',
'stage_name': 'api',
'domain_name': 'example.com',
}
outputs = template['output']
assert outputs['AliasDomainName']['value'] == (
'${aws_api_gateway_domain_name.api_gateway_custom_domain'
Expand Down

0 comments on commit 1ca226b

Please sign in to comment.