Cannot create IManagedPolicy from a customer managed policy
See original GitHub issue-
I’m submitting a …
- 🚀 feature request
-
What is the current behavior?
Role.addManagedPolicy(policy: IManagedPolicy)
is the method to add managed policies to a role. However the only method to create IManagedPolicy
is ManagedPolicy.fromAwsManagedPolicyName()
, which only supports the AWS managed policies. There is no way to add a customer-managed policy to a role, either by its arn or by a ref to a CfnManagedPolicy
.
This is a regression from 0.34.0 behaviour. In 0.34.0 you could do the following:
myRole: Role;
myPolicy: CfnManagedPolicy;
myRole.attachManagedPolicy(myPolicy.managedPolicyArn);
- What is the expected behavior (or behavior of feature suggested)?
One or more of the following methods should be added to ManagedPolicy
to support more managed policy types:
ManagedPolicy.fromManagedPolicyRef(ref: IResolvable)
ManagedPolicy.fromManagedPolicyArn(arn: string)
- What is the motivation / use case for changing the behavior or adding this feature?
To support customer Managed policies.
-
Please tell us about your environment:
- CDK CLI Version: 0.35.0
- OS: Windows 10
- Language: TypeScript
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:5 (3 by maintainers)
Top Results From Across the Web
class ManagedPolicy (construct) · AWS CDK
For example, "Grants access to production DynamoDB tables." The policy description is immutable. After a value is assigned, it cannot be changed.
Read more >CDK - Add policies to role with For each - Stack Overflow
I managed to make it work with the code bellow: policyName.forEach(policyName => { const importedPolicy = ManagedPolicy.fromManagedPolicyName( ...
Read more >Managed Policy Examples in AWS CDK - Complete Guide
In this article we are going to go over examples of AWS managed and Customer managed policies. Creating a Managed Policy in AWS...
Read more >IAM Customer Managed Policy with Administrative ...
If the search process does not return any customer managed policies, there is no IAM admin policy created within the current AWS account...
Read more >Limit scope of AWS Managed IAM Policies?
The advantage of using the AWS managed policy is that any updates/changes to the CodeDeploy ... You could create few other things to...
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
You can try using addManagedPolicy:
I took a stab at implementing the creation / reference of customer managed policies here https://github.com/IainCole/aws-cdk/blob/ic_support_customer_managed_policy/packages/%40aws-cdk/aws-iam/lib/managed-policy.ts
It seems to work from my testing, @NGL321 if this makes sense logically I can submit a PR with tests etc.