diff --git a/chalice/package.py b/chalice/package.py index ecdd0268e..a6dfe8913 100644 --- a/chalice/package.py +++ b/chalice/package.py @@ -817,26 +817,20 @@ def generate(self, resources): # type: (List[models.Model]) -> Dict[str, Any] template = { 'resource': {}, - 'locals': {}, + 'locals': { + 'chalice_app': self._config.app_name, + 'chalice_stage': self._config.chalice_stage + }, 'terraform': { 'required_version': '>= 0.12.26, < 1.4.0', 'required_providers': { 'aws': {'version': '>= 2, < 5'}, - 'null': {'version': '>= 2, < 4'} } }, 'data': { 'aws_caller_identity': {'chalice': {}}, 'aws_partition': {'chalice': {}}, 'aws_region': {'chalice': {}}, - 'null_data_source': { - 'chalice': { - 'inputs': { - 'app': self._config.app_name, - 'stage': self._config.chalice_stage - } - } - } } } diff --git a/tests/unit/test_package.py b/tests/unit/test_package.py index cd01e451d..4de7ce123 100644 --- a/tests/unit/test_package.py +++ b/tests/unit/test_package.py @@ -616,10 +616,14 @@ def test_can_generate_chalice_terraform_static_data(self, sample_app): app_name='myfoo', api_gateway_stage='dev') template = self.generate_template(config) - assert template['data']['null_data_source']['chalice']['inputs'] == { - 'app': 'myfoo', - 'stage': 'dev' - } + assert 'chalice_app' in template['locals'] + assert 'chalice_stage' in template['locals'] + assert 'chalice_api_swagger' in template['locals'] + assert template['locals']['chalice_app'] == 'myfoo' + assert template['locals']['chalice_stage'] == 'dev' + assert template['locals']['chalice_api_swagger'] == ( + '{"info": {"title": "some-app"}, "x-amazon-apigateway-binary-media-types": []}' + ) def test_can_package_s3_event_handler_sans_filters(self, sample_app): @sample_app.on_s3_event(bucket='foo')