[custom-resources] allow for no policy to be specified
See original GitHub issueI do not have the ability to modify roles and the CDK assumes I do for an AwsCustomResource
. I can specify the execution role for the custom resource Lambda, but I have to specify a policy, and cdk deploy
fails for me because I don’t have access to modify the execution role with the new policy. I would expect for policy to be optional if role is specified. I am in a corporate setting where permissions are “locked down” and roles exist but can not be modified.
Reproduction Steps
export class ExistingS3BucketEventSource extends CDK.Construct {
constructor(scope: CDK.Construct, id: string, props: S3NotificationLambdaProps) {
super(scope, id);
new CR.AwsCustomResource(scope, id + 'CustomResource', {
onCreate: {
...
},
onDelete: {
...
},
policy: CR.AwsCustomResourcePolicy.fromStatements([]), // I don't want this! Also specifying no statements doesn't work!
role: props.role // I want permissions from here!
});
props.lambda.addPermission('AllowS3Invocation', {
action: 'lambda:InvokeFunction',
principal: new IAM.ServicePrincipal('s3.amazonaws.com'),
sourceArn: props.bucket.bucketArn
});
}
}
interface S3NotificationLambdaProps {
role: IAM.IRole;
bucket: S3.IBucket;
lambda: Lambda.IFunction;
events: string[];
prefix: string;
}
What did you expect to happen?
I do not want to modify the execution role.
What actually happened?
The execution role is modified.
Environment
- CDK CLI Version : 1.90.0 (build 7edba31)
- Framework Version: 1.90.0
- Node.js Version: v12.18.3
- OS : Catalina 10.15.7
- Language (Version): TypeScript (3.8.3)
Other
This is 🐛 Bug Report
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:9 (6 by maintainers)
Top Results From Across the Web
aws-cdk/custom-resources module - AWS Documentation
The provider framework makes it easy to implement "waiters" by allowing users to specify an additional AWS Lambda function in isCompleteHandler .
Read more >Extend the Kubernetes API with CustomResourceDefinitions
Custom resources are validated via OpenAPI v3 schemas, by x-kubernetes-validations when the Validation Rules feature is enabled, and you can add ...
Read more >Policy for Kubernetes Custom Resources | Neon Mirrors
The first is that Kyverno is fine for Kubernetes "out-of-the-box" resources like Pods and Deployments but is somehow either not capable or ...
Read more >Extending the Kubernetes API with Custom Resources
Cluster role aggregation allows the insertion of custom policy rules into these ... The roles with more permissions do not inherit rules from...
Read more >Implementing Custom Resources with AWS CDK - Medium
Custom Resources allow you to write custom logic in your CloudFormation ... upon deployment, calls the AWS SDK APIs that you defined for...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@rix0rrr - I have used
Role.from_role_arn( ..., mutable=False)
androle.without_policy_updates()
with no luck (in Python). AwsCustomResource does not seem to respect the immutable role and always adds duplicate inline policies.Experiencing the same problem. I need to provide an immutable role to
AwsCustomResource
which already has the correct permissions to do what I want. I’m not allowed to update an IAM role with a new policy in my corporate environment.No workaround available as far as I can see, it always tries to attach a policy if
role
is defined: aws-custom-resource.ts#L409