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

(aws-cdk-lib): (Change terminationProtection on existing Stack instances) #21304

Closed
2 tasks
Rabadash8820 opened this issue Jul 24, 2022 · 2 comments · Fixed by #26992
Closed
2 tasks

(aws-cdk-lib): (Change terminationProtection on existing Stack instances) #21304

Rabadash8820 opened this issue Jul 24, 2022 · 2 comments · Fixed by #26992
Labels
@aws-cdk/core Related to core CDK functionality aws-cdk-lib Related to the aws-cdk-lib package effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2

Comments

@Rabadash8820
Copy link
Contributor

Rabadash8820 commented Jul 24, 2022

Describe the feature

Currently, the only way to enable termination protection on a CDK Stack is in the props passed to the Stack's constructor, e.g.:

const myStack = new MyStack(app, "MyStack", {
    terminationProtection: true,
    // ...
});

However, there is no way to set termination protection on an existing Stack instance. E.g., in the code above, if I then write myStack.terminationProtection = false, then I get the following compiler error:

Cannot assign to 'terminationProtection' because it is a read-only property.

I request that this property be writable.

Use Case

I'm trying to define an Aspect to enable termination protection on all of my production stacks, so that I don't accidentally forget to enable it in the CDK app. I was hoping to define this Aspect as follows, but instead I get the aforementioned compiler error.

export class ProdTerminationProtectionAspect implements IAspect {

    constructor(private readonly isProduction: boolean) { }

    public visit(construct: IConstruct): void {
        if (!this.isProduction || !Stack.isStack(construct))
            return;

        construct.terminationProtection = this.isProduction;    // ERROR
    }
}

Proposed Solution

No response

Other Information

Alternatively, you could take this as a feature request to add an "auto-termination-protection-enabling" Aspect to the CDK itself. 🙂

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2.33.0 (build 859272d)

Environment details (OS name and version, etc.)

Debian buster (technically in a WSL devcontainer on Windows 11 Pro)

@Rabadash8820 Rabadash8820 added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Jul 24, 2022
@github-actions github-actions bot added the aws-cdk-lib Related to the aws-cdk-lib package label Jul 24, 2022
@peterwoodworth peterwoodworth added p2 effort/small Small work item – less than a day of effort and removed needs-triage This issue or PR still needs to be triaged. labels Sep 2, 2022
@otaviomacedo otaviomacedo added the @aws-cdk/core Related to core CDK functionality label Apr 27, 2023
@ryo0301
Copy link

ryo0301 commented Sep 4, 2023

#26992

@mergify mergify bot closed this as completed in #26992 Sep 19, 2023
mergify bot pushed a commit that referenced this issue Sep 19, 2023
Closes #14463.
Closes #21304.

----

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

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

HBobertz pushed a commit that referenced this issue Sep 19, 2023
Closes #14463.
Closes #21304.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
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 aws-cdk-lib Related to the aws-cdk-lib package effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants