Skip to content
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

Escape hatch: be able to delete an entire resource from the subtree #1408

Closed
eladb opened this issue Dec 20, 2018 · 6 comments · Fixed by #5608
Closed

Escape hatch: be able to delete an entire resource from the subtree #1408

eladb opened this issue Dec 20, 2018 · 6 comments · Fixed by #5608
Assignees
Labels
@aws-cdk/core Related to core CDK functionality feature-request A feature should be added or improved. pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member.

Comments

@eladb
Copy link
Contributor

eladb commented Dec 20, 2018

Sometimes users might want to delete an entire resource.

See #1404 for a use case

@eladb eladb added enhancement bug This issue is a bug. and removed enhancement labels Dec 20, 2018
@eladb eladb added feature-request A feature should be added or improved. and removed bug This issue is a bug. labels Jan 8, 2019
@fisherpro
Copy link

fisherpro commented Feb 14, 2019

If a certain cdk object creates a role, how do I then stop that role from being created?
If I am reading this issue correctly, this is impossible today?

I may need to abandon AWS CDK in my organization.

There are certain resources I am not allowed to create with my user's AWS Role. I was hoping to be able to delete the resources and reference an ARN where needed instead of having then created with cdk.

Thank you

@eladb
Copy link
Contributor Author

eladb commented Feb 24, 2019

This is definitely in our roadmap and a legitimate request. Many AWS constructs allow you to pass in an IRole instead of auto-creating the role. Was there a specific construct that you are using that didn't support it?

@fisherpro
Copy link

Hi @eladb, Thanks for the reply.

I was attempting to use an AutoscalingGroup instance, but the role that is passed in (thank you for allowing a role to be passed in btw) to a new InstanceProfile. But creating an Instance profile is also an off-limits IAM function within my organization. So my thought was to simply delete the Instance Profile and use an existing one within my Amazon account. I could not figure out how to delete the Instance Profile that was created by the AutoscalingGroup.

I think the above problem is related to this issue. Correct?

Thanks

@dsharkou
Copy link

@jcamilli I have the same for the customer (but for ecs.FargateTaskDefinition- on addContainer it creates redundant for me IAM Policy to create log stream and put log events)
@eladb Do you have any updates on this?

@NGL321 NGL321 added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Sep 10, 2019
@NGL321 NGL321 added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Sep 10, 2019
@eladb eladb added @aws-cdk/core Related to core CDK functionality and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Sep 11, 2019
@konstantinj
Copy link

Would like this feature. I just wanted to add a custom route table to my subnets while still using the VPC construct. I have a new route table but I can't remove the already existing ones.

@pasieronen
Copy link

pasieronen commented Nov 8, 2019

I have a similar use case: would like to use existing Elastic IPs with NAT Gateways. I can override the NAT Gateway's allocationId by:

const natGateway1 = vpc.node.findChild('publicSubnet1').node.findChild('NATGateway') as CfnNatGateway
natGateway1.allocationId = /* something */

but I can't remove the EIPs created by the VPC construct...

EDITED: Apparently this works, but it would be nice to a have a publicly documented deleteChild API...

 delete (vpc.node.findChild('publicSubnet1').node as any)._children['EIP']

@mergify mergify bot closed this as completed in #5608 Jan 6, 2020
mergify bot pushed a commit that referenced this issue Jan 6, 2020
Immutably imported `Role`s could not be used for CodeBuild
`Project`s, because they would create a policy but be unable
to attach it to the Role. That leaves an unattached Policy,
which is invalid.

Fix this by making `Policy` objects only render to an `AWS::IAM::Policy`
resource if they actually have any effect. It is perfectly allowed to
create new unattached Policy objects, or have empty Policy objects.
Only if and when they actually need to mutate the policy of an IAM
identity will they render themselves to the CloudFormation template.
Being able to abstract away these kinds of concerns is exactly the value
of a higher-level programming model.

To allow for the rare cases where an empty Policy object would be
considered a programming error, we still have the flag `mustCreate`
which triggers the legacy behavior of alwyas creating the
`AWS::IAM::Policy` resource which must have a statement and be
attached to an identity.

Fixes #1408.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*

<!-- 
Please read the contribution guidelines and follow the pull-request checklist:
https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md
 -->
@mwfpope mwfpope mentioned this issue May 4, 2020
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/core Related to core CDK functionality feature-request A feature should be added or improved. pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants