Conversation
…pression (#302) When a Task state's Resource was a Fn::Sub object (produced by plugins like serverless-pseudo-parameters), the versioned ARN (:*) was generated as a Fn::Sub array with the Fn::Sub object as a variable map value — invalid CloudFormation that causes MalformedPolicyDocument errors on deploy. Introduces getVersionedArn() which appends :* directly to the Fn::Sub template string instead of nesting it as a variable value. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
commit: |
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.
Summary
Fixes #302.
When a Task state's
Resourceis aFn::Subobject — as produced by plugins likeserverless-pseudo-parametersthat convert#{AWS::Region}to${AWS::Region}— the versioned ARN (:*) was generated using the array form ofFn::Subwith theFn::Subobject as a variable map value:{ "Fn::Sub": ["${functionArn}:*", { "functionArn": { "Fn::Sub": "arn:..." } }] }CloudFormation does not support nesting
Fn::Subas a variable map value, so this produces aMalformedPolicyDocumenterror on deploy.Fix
Introduces
getVersionedArn()inlambda.jswhich detects when the base ARN is already aFn::Suband appends:*directly to the template string:{ "Fn::Sub": "arn:${AWS::Partition}:lambda:${AWS::Region}:${AWS::AccountId}:function:my-fn:*" }RefandFn::GetAttresources are unaffected and continue to use the existing array form.Test plan
lambda.test.js(written before the fix, confirmed failing then passing)fnSubMachinestate machine added to thebasic-state-machineintegration fixture, covering theFn::Subresource reference style alongside the existingFn::GetAttoneverify.test.jsadded tobasic-state-machinefixture asserting no nestedFn::Subin the IAM policy and a valid versioned ARN🤖 Generated with Claude Code