-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
provider/aws: Add support for updating Lambda function #5239
provider/aws: Add support for updating Lambda function #5239
Conversation
3de5b52
to
42d4c3d
Compare
Waiting for #5305 to be reviewed and merged. That should make writing acceptance test for S3 deployment much easier. |
76c09be
to
9409086
Compare
This is now ready for final review. |
9409086
to
c632c4d
Compare
c632c4d
to
01d5fdd
Compare
if d.HasChange("s3_bucket") || d.HasChange("s3_key") || d.HasChange("s3_object_version") { | ||
d.SetPartial("s3_bucket") | ||
d.SetPartial("s3_key") | ||
d.SetPartial("s3_object_version") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we're building up inputs for a single API call rather than making a bunch of smaller API calls, I believe the partial mode code is unnecessary. The update will either fully succeed or fully fail, there's no partial success here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was first thinking the same thing when I first saw this piece of code (it's not exactly my addition), but then I scrolled down to line 351
. We actually send two API calls: https://github.com/hashicorp/terraform/pull/5239/files#diff-2dcdbaf0cd0066fa2112ca76a0c2135eR351
So I think the partial state handling here is actually useful, isn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah sorry yes, missed that. So I think the pattern should then be to setPartial
on all the attributes that would be successfully updated by UpdateFunctionCode
once it completes successfully. In pseudocode:
enable partial mode
build up UpdateFunctionCode request
if error, return and nothing is updated
if successful, mark all FunctionCode related attributes successful
build up UpdateFunctionConfig request
if error, return and only marked FunctionCode attrs will be picked up
if successful, disable partial mode, since everything worked (perhaps mark specific attrs here anyways to prepare for a potential 3rd update API call down the road?)
Let me know if this makes sense!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I think it does - basically it means I'll need to move all of the d.SetPartial(
calls below conn.UpdateFunctionCode
so these are only called when conn.UpdateFunctionCode
is actually successful.
The same will apply to UpdateFunctionConfiguration
and its related fields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep exactly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Few nits inline, but this is looking good! |
01d5fdd
to
4a3ee46
Compare
4a3ee46
to
9f6b487
Compare
@phinze are u happy with all the changes I made, especially around the partial state mgmt? |
Yep this LGTM! |
provider/aws: Add support for updating Lambda function
hashicorp/terraform#5239 was merged into tf
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
This supersedes #3825
To do:
source_code_hash = base64sha256()
testAccCheckAWSLambdaAttributes()
with more specific ones -testAccCheckAwsLambdaFunctionName
&testAccCheckAwsLambdaFunctionArn