[plugin] Fix: lambda-deploy update path now verifies the execution role exists#676
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
lambda-deployplugin's update path never verifies that the function's execution role still exists. Lambda validates the execution role lazily — only at invoke time, not when a function is created or updated — so a redeploy against a function whose role was deleted (for example by a previouslambda-deploy --delete, which removes both the function and its role) succeeds silently. The function is left pointing at a non-existent role and fails at invoke time with:The role was only ever resolved/created on the create path, so once the auto-managed role went missing there was no way to recover via redeploy, and no diagnostic pointing at the cause.
Fix
GetFunctionresponse already fetched to determine create-vs-update, so the verification adds no extraGetFunctioncall —functionExists(...) -> BoolbecameexistingFunctionConfiguration(...) -> FunctionConfiguration?and the configuration is carried downstream.roleName(fromARN:)(extracts the role name from an execution-role ARN, handling nested paths and partitions) andverifyExecutionRoleExists(...)(maps IAMNoSuchEntityto the actionableexecutionRoleMissingerror).Tests
Added a property-test suite covering
roleName(fromARN:)— valid ARNs including service-role/nested paths and theaws-us-govpartition, plus malformed/empty ARNs that must returnnil.All
AWSLambdaPluginHelperTestspass (75 tests); theAWSLambdaPluginHelpertarget builds clean on Swift 6.4.