Skip to content

Conversation

@ShreyaGangishetty
Copy link

Issue #, if available:
#634
Description of changes:
Updated the code to take function name when redeploying api
This PR resolves only Ref and Fn::Sub intrinsics for parameter values

Description of how you validated changes:
added a test which updates the deployment hash when functionname changes

Checklist:

  • Write/update tests
  • make pr passes
  • Verify transformed template deploys and application functions as expected

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

@ShreyaGangishetty ShreyaGangishetty changed the title Redeploy api hash when function name changes fix: redeploy api hash when function name changes Nov 7, 2019
@codecov-io
Copy link

codecov-io commented Nov 7, 2019

Codecov Report

Merging #1235 into develop will increase coverage by <.01%.
The diff coverage is 96.77%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1235      +/-   ##
===========================================
+ Coverage    94.41%   94.42%   +<.01%     
===========================================
  Files           78       78              
  Lines         4529     4554      +25     
  Branches       903      912       +9     
===========================================
+ Hits          4276     4300      +24     
  Misses         119      119              
- Partials       134      135       +1
Impacted Files Coverage Δ
samtranslator/model/apigateway.py 97.95% <100%> (+0.05%) ⬆️
samtranslator/model/api/api_generator.py 95.13% <100%> (ø) ⬆️
samtranslator/model/sam_resources.py 93.99% <100%> (+0.01%) ⬆️
samtranslator/translator/translator.py 98.37% <94.73%> (-0.67%) ⬇️

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 ba4ac42...a417034. Read the comment docs.

@ShreyaGangishetty ShreyaGangishetty changed the title fix: redeploy api hash when function name changes fix: redeploy api when function name changes Nov 7, 2019
@praneetap praneetap self-assigned this Nov 8, 2019
Copy link
Author

Choose a reason for hiding this comment

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

This function appends all the function names of an API as an API can have multiple functions. If atleast one function name changes, the api will be redeployed.

Copy link
Contributor

@praneetap praneetap Nov 12, 2019

Choose a reason for hiding this comment

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

You don't need the second none/"" argument in 'get', that's the default behavior

Copy link
Author

Choose a reason for hiding this comment

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

Thank you. I have updated the code without ""/None

Copy link
Author

Choose a reason for hiding this comment

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

This case works for !Ref FunctionParameter

Copy link
Author

Choose a reason for hiding this comment

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

This resolves Fn::Sub: FunctionName to a string

function_names = redeploy_restapi_parameters.get('function_names')
else:
function_names = None
if function_names and function_names.get(self.logical_id[:-10], None):
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you remind me again why self.logical_id[:-10] is needed here? Maybe add a comment about what you're trying to do?

Copy link
Author

@ShreyaGangishetty ShreyaGangishetty Dec 9, 2019

Choose a reason for hiding this comment

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

Sure, I will add a comment. self.logical_id has the api_name and the word "deployment". I am removing the word "deployment" and just getting the api_name to search for corresponding string of function_name/names

self.plugins = plugins
self.sam_parser = sam_parser

def _get_function_names(self, resource_dict, parameter_values):
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it not possible to use the intrinsic resolver? This looks like a lot of duplicated effort.

Intrinsic resolver does additional things, like resolving "!Sub ${parameter}-name", which this doesn't appear to handle.

Copy link
Author

@ShreyaGangishetty ShreyaGangishetty Dec 9, 2019

Choose a reason for hiding this comment

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

I will check and get back if i can call intrinsics resolver here.

Copy link
Contributor

@praneetap praneetap left a comment

Choose a reason for hiding this comment

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

Nice! Thanks for this Shreya!

@praneetap praneetap merged commit 40d2d79 into aws:develop Dec 27, 2019
@patrickgreenwell
Copy link
Contributor

This is still an issue if you reference the RestApiId via a Ref and have a FunctionName with a Sub in it. The OrderDict object seems to be more specific than needs be and templates can still fall into the else statement under the right conditions. I've made a branch for a change that will resolve the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants