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

WIP: fix: support intrinsics in Location property of Serverless Application #710

Closed
wants to merge 1 commit into from

Conversation

keetonian
Copy link
Contributor

Issue #, if available:
#694
Description of changes:
Support intrinsics such as Ref and Sub in the Location parameter for s3 strings.

This does not add support for intrinsics in ApplicationId or SemanticVersion.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@codecov-io
Copy link

Codecov Report

Merging #710 into develop will increase coverage by 0.07%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #710      +/-   ##
===========================================
+ Coverage    94.17%   94.25%   +0.07%     
===========================================
  Files           67       67              
  Lines         2678     2680       +2     
  Branches       478      478              
===========================================
+ Hits          2522     2526       +4     
  Misses          80       80              
+ Partials        76       74       -2
Impacted Files Coverage Δ
...lator/plugins/application/serverless_app_plugin.py 80.46% <100%> (+0.31%) ⬆️
samtranslator/model/sam_resources.py 96.44% <0%> (+0.71%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dc9a3b7...474f36d. Read the comment docs.

@keetonian keetonian changed the title Support intrinsics in Location property of Serverless Application fix: support intrinsics in Location property of Serverless Application Dec 8, 2018
and self.APPLICATION_ID_KEY in app.properties[self.LOCATION_KEY]
and self.SEMANTIC_VERSION_KEY in app.properties[self.LOCATION_KEY])
and isinstance(location, dict)
and list(location.keys())[0] not in resolver.DEFAULT_SUPPORTED_INTRINSICS

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why it only checks for the first key?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's an S3 location, it will only have one dictionary key at this level:

Location:
  Ref: parameter
# or
Location:
  Sub: s3://{something}

If it has something else, then it's probably not valid.

This brings up a good point though: this doesn't check for all possible intrinsics. I need to fix that.

@@ -187,7 +190,8 @@ def on_before_transform_resource(self, logical_id, resource_type, resource_prope
self._check_for_dictionary_key(logical_id, resource_properties, [self.LOCATION_KEY])

# If location isn't a dictionary, don't modify the resource.
if not isinstance(resource_properties[self.LOCATION_KEY], dict):
if (not isinstance(resource_properties[self.LOCATION_KEY], dict)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make it a util function to check these conditions? You have the same check in the function above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea

@keetonian keetonian changed the title fix: support intrinsics in Location property of Serverless Application WIP: fix: support intrinsics in Location property of Serverless Application Dec 12, 2018
@keetonian keetonian added the stage/in-progress A fix is being worked on label Dec 13, 2018
@keetonian keetonian closed this Feb 20, 2019
@hawkins
Copy link

hawkins commented Mar 6, 2019

Why was this closed? Don't we still need this functionality? I'm unable to use intrinsic functions in Location today in version 0.11.0

@wangwylie
Copy link

Still running into this issue as well while using an intrinsic function (Fn::Join and I've tried Fn::Sub) with the location property in Serverless::Application

""StatusReason": "Transform AWS::Serverless-2016-10-31 failed with: Invalid Serverless Application Specification document. Number of errors found: 11. Resource with id [someStack] is invalid. Resource is missing the required [ApplicationId] property"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage/in-progress A fix is being worked on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants