-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default policy are getting creating even when Managed policy were created in the Role #4196
Labels
@aws-cdk/aws-iam
Related to AWS Identity and Access Management
feature-request
A feature should be added or improved.
Comments
nikhilbhoj
added
bug
This issue is a bug.
needs-triage
This issue or PR still needs to be triaged.
labels
Sep 23, 2019
Hey @nikhilbhoj , unfortunately, you're hitting this issue. The quick solution here, before we fix #2985, is to create a simple wrapper in your code: class ImmutableRole implements iam.IRole {
private readonly role: iam.IRole;
constructor(role: iam.IRole) {
this.role = role;
}
readonly assumeRoleAction = this.role.assumeRoleAction;
readonly grantPrincipal = this.role.grantPrincipal;
readonly node = this.role.node;
readonly policyFragment = this.role.policyFragment;
readonly roleArn = this.role.roleArn;
readonly roleName = this.role.roleName;
readonly stack = this.role.stack;
addManagedPolicy(policy: iam.IManagedPolicy): void {
// do nothing
}
addToPolicy(statement: iam.PolicyStatement): boolean {
return false;
}
attachInlinePolicy(policy: iam.Policy): void {
// do nothing
}
grant(grantee: iam.IPrincipal, ...actions: string[]): iam.Grant {
return this.role.grant(grantee, ...actions);
}
grantPassRole(grantee: iam.IPrincipal): iam.Grant {
return this.role.grantPassRole(grantee);
}
} and then pass this wrapper to the Role for the const projectRole = new iam.Role(this, 'cdkBuildRole', {
assumedBy: new iam.ServicePrincipal('codebuild.amazonaws.com'),
});
const cdkBuild = new codebuild.PipelineProject(this, 'CdkBuild', {
role: new ImmutableRole(projectRole),
// ...
}); |
skinny85
added
gap
and removed
bug
This issue is a bug.
needs-triage
This issue or PR still needs to be triaged.
labels
Sep 24, 2019
Thanks @skinny85 for the quick help. I would be doing this in my code. |
skinny85
added
feature-request
A feature should be added or improved.
and removed
gap
labels
Sep 24, 2019
I don't think we need to have 2 copies of this issue open. Closing as duplicate of #2985. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
@aws-cdk/aws-iam
Related to AWS Identity and Access Management
feature-request
A feature should be added or improved.
In my organization, we need to use Manage Policy and not inline policy.
So ,instead of using policy created by CDK, I have to created custom Managed policy and attaching it to the role.
But what is happening is both types of policy are being created by CDK i.e.
Inline policy - By CDK
Managed Policy : created by me.
Since, we have a permission boundary policy in place my stack creation fails.
I create this Managed Policy as below:
And then in my code build.PipelineProject , I create a custom role
Reproduction Steps
It is creating this managed policy
And this inline default policy
Error Log
My stack creation fails
Environment
This is 🐛 Bug Report
The text was updated successfully, but these errors were encountered: