-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Log when any stateful resource is in stack
A resource is a raw CloudFormation item. A construct is CDK's L1 or L2 abstraction of a resource. A stateful resource can be defined as something that holds state. This could be a database, a bucket, load balancer, message queue etc. This change will, upon stack synthesis, walk the tree of resources and log a warning for all the stateful resources we have identified. This does mean we end up keeping a list of these resources, which is not ideal... The `GuStatefulMigratableConstruct` mixin performs a similar role here, however that only operates against the constructs that exist in the library. Ideally we'd be able to use Stack Policies to protect these resources. However they are not currently supported in CDK. See: - https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_core.Construct.html#protected-prepare - https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/protect-stack-resources.html - aws/aws-cdk-rfcs#72
- Loading branch information
Showing
3 changed files
with
74 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* A list of resource types that should be considered stateful | ||
* and care should be taken when updating them to ensure they | ||
* are not accidentally replaced as this could lead to downtime. | ||
* | ||
* For example, if a load balancer is accidentally replaced, | ||
* any CNAME DNS entry for it would now be invalid and downtime | ||
* will be incurred for the TTL of the DNS entry. | ||
* | ||
* Currently, this list is used to generate warnings at synth time. | ||
* Ideally we'd add a stack policy to stop the resource being deleted, | ||
* however this isn't currently supported in CDK. | ||
* | ||
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/protect-stack-resources.html | ||
* @see https://github.com/aws/aws-cdk-rfcs/issues/72 | ||
*/ | ||
export const StatefulResourceTypes: string[] = [ | ||
"AWS::CertificateManager::Certificate", | ||
"AWS::DynamoDB::Table", | ||
"AWS::ElasticLoadBalancing::LoadBalancer", | ||
"AWS::ElasticLoadBalancingV2::LoadBalancer", | ||
"AWS::S3::Bucket", | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters