Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace null resource in terraform template with locals to fix warning #2068

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions chalice/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
}
}

Expand Down
12 changes: 8 additions & 4 deletions tests/unit/test_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down