iam: cannot pass iam.ManagedPolicy or iam.Policy to lambda.Function.grantInvoke #32980
Labels
@aws-cdk/aws-iam
Related to AWS Identity and Access Management
bug
This issue is a bug.
needs-triage
This issue or PR still needs to be triaged.
Describe the bug
Following code fails:
The error message is:
Regression Issue
Last Known Working CDK Version
No response
Expected Behavior
Grant
lambda:InvokeFunction
toManagedPolicy
orPolicy
.Current Behavior
grantInvoke()
throws an error described above.Reproduction Steps
See the description above.
Possible Solution
grantInvoke()
callsgrantee.grantPrincipal.policyFragment.conditions
to create a dedupe hash.aws-cdk/packages/aws-cdk-lib/aws-lambda/lib/function-base.ts
Lines 435 to 442 in 2b2443d
But
policyFragment
getter ofManagedPolicy
andPolicy
throws an error. (see #22712)It should return a dummy policy fragment like
Group
.aws-cdk/packages/aws-cdk-lib/aws-iam/lib/group.ts
Lines 82 to 84 in 2b2443d
Group
is blocked inPolicyStatement
aws-cdk/packages/aws-cdk-lib/aws-iam/lib/policy-statement.ts
Lines 240 to 244 in 2b2443d
Additional Information/Context
No response
CDK CLI Version
2.176.0
Framework Version
2.176.0
Node.js Version
22.13.0
OS
Ubuntu
Language
TypeScript
Language Version
No response
Other information
Related to #32795
The text was updated successfully, but these errors were encountered: