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

Fix issue in updating iam role arn for deployments #363

Merged
merged 5 commits into from
Jun 6, 2017

Conversation

kyleknap
Copy link
Contributor

This fixes two issues related to providing an iam role:

kyleknap added 4 commits May 31, 2017 13:26
Previously the update_function took no account for updates
to configuration with respect to IAM role arns. Now this value
are plumbed through to the update_function method call.
The SAM packaging logic did not respect the case where the user
supplies their own iam role.
This parallels the retry used in the create_function method that
retries the creation of the Lambda function until Lambda can use
the provided role.
@kyleknap kyleknap requested review from jamesls and stealthycoin May 31, 2017 22:29
@codecov-io
Copy link

codecov-io commented May 31, 2017

Codecov Report

Merging #363 into master will increase coverage by 0.03%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #363      +/-   ##
==========================================
+ Coverage   90.69%   90.73%   +0.03%     
==========================================
  Files          18       18              
  Lines        2139     2148       +9     
  Branches      274      276       +2     
==========================================
+ Hits         1940     1949       +9     
  Misses        146      146              
  Partials       53       53
Impacted Files Coverage Δ
chalice/awsclient.py 89.04% <100%> (+0.25%) ⬆️
chalice/deploy/deployer.py 84.09% <100%> (+0.06%) ⬆️
chalice/package.py 97.4% <100%> (+0.1%) ⬆️

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 9b46d98...a27ad4a. Read the comment docs.

@@ -90,22 +90,27 @@ def create_function(self,
kwargs['Timeout'] = timeout
if memory_size is not None:
kwargs['MemorySize'] = memory_size
return self._create_or_update_function_with_retries(
'create_function', kwargs)['FunctionArn']
Copy link
Member

Choose a reason for hiding this comment

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

  • You can technically pass any client method here so the name seems too restrictive.
  • We don't need getattr logic, it's always going to be a method we know statically. I'd prefer to update this to just pass the method obj directly. (self._client('lambda').create_function)

@jamesls
Copy link
Member

jamesls commented Jun 6, 2017

Looks good, just had a comment about _create_or_update_function_with_retries.

self._client('lambda').create_function, kwargs)['FunctionArn']

def _call_client_method_with_retries(self, method, kwargs):
# type: (Callable[..., Any], Dict[str, Any]) -> Dict[str, Any]
Copy link
Member

Choose a reason for hiding this comment

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

Can we tighten up the signature here? Callable that only takes kwargs and returns a dict of str, Any maybe? http://mypy.readthedocs.io/en/latest/kinds_of_types.html#extended-callable-types

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right. Clients will always return a dict.

@kyleknap
Copy link
Contributor Author

kyleknap commented Jun 6, 2017

@jamesls I updated to make stricter type checking on the client method. Decided not to use the KwArg types as that would require pulling in mypy_extensions as a dependency.

Copy link
Member

@jamesls jamesls left a comment

Choose a reason for hiding this comment

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

One small, change otherwise looks good.

self._create_or_update_function_with_retries(
'update_function_configuration', kwargs)
self._call_client_method_with_retries(
self._client('lambda').update_function_configuration, kwargs)
Copy link
Member

Choose a reason for hiding this comment

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

You already create a lambda_client in the first line of this function, you shouldn't need to create it again here.

@kyleknap
Copy link
Contributor Author

kyleknap commented Jun 6, 2017

Updated to use already instantiated client. Travis passed as well. Merging.

@kyleknap kyleknap merged commit d0086f6 into aws:master Jun 6, 2017
@kyleknap kyleknap deleted the fix-iam-update branch June 6, 2017 20:32
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.

3 participants