-
Notifications
You must be signed in to change notification settings - Fork 58
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
PFR - option to define & exclude dedicated resources/properties from CFN Drift Detection - e.g. due to AWS::EC2::SecurityGroupIngress references #1533
Comments
The use case for this PFR has multiple use cases. Especially if you're interested in making an EC2 Security Group in one Stack, and then you want to apply the Security Group Ingress or Egress rules on the EC2 Security Group in another Stack. The EC2 Security Group would shows drifted since the limitation highlighted here Drift is the most consistent way of ensuring that the CloudFormation Stack Resources are in a Nominal state. You can see the necessity for this feature with issues also relating to the AWS::RDS::DBInstance Resource if you mark the "AutoMinorVersionUpgrade" Property Boolean as True. As soon as a Minor Version is released, the CloudFormation Template would need to be updated since the Engine Version difference causes a drift. While the AWS::RDS::DBInstance issue can be solved via a Transform, it would be more ideal to highlight either a specific property within a Resource or the Resource itself to be exempted from Drift Detection. It would make Drift Detection for RDS Resources significantly more informative and viable to leverage. Ideally, I would love to see a development of a common CloudFormation Attribute similar to the DependsOn Attribute where you specify which properties would and would not be exempted from Drift detection, or just declare "All" to remove the Resource from being considered in Drift Detection. With the amount of problems that Drift Detection runs into regarding edge cases like the ones highlighted in my comment, it negatively impacts confidence within the Drift Detection feature. If a new way of defining what is and isn't detected within a Resource when running Drift Detection is developed, it would effectively be able to breathe new life into the usability of Drift Detection with this requested feature giving organizations the ability to start defining what drift they would like to actually detect and ignore. |
Case 2 feels like a crutch instead of better centralized drift solutions When I worked on CloudFormation, drift detection was more reactive than proactive. Customers complained about drift bugs, and then CloudFormation would investigate case-by-case Drift detection should monitor property types with high drift rates. Many customer-reported drift bugs had 100% drift rates; obviously, every customer using a property type did not manually drift out-of-band. Drift detection for those property types should be automatically disabled and CloudFormation can asynchronously work through that list to fix them without customer involvement |
Thanks Pat for your valuable input. I agree. I'm adding an other example, where -individually- based on your personal use-case a exclude within CFN Drift Detection would be great:
|
Here is another use-case: |
Name of the resource
AWS::EC2::SecurityGroupIngress
Resource name
No response
Description
Summary & Starting point:
This idea is more a generic one - there are different circumstances, where CloudFormation Drift Detection reporting a DRIFT, but it's not - reasons could be:
AWS::EC2::SecurityGroupIngress
in Stack-B in with reference to a (Security)GroupId which is deployed in Stack-A as discussed here: AWS::EC2::SecurityGroupIngress causing false positive drift within referenced AWS::EC2::SecurityGroup #1198 - Overall, once you are facing a limitation of CloudFormation Drift Dectection.After brainstorming with different people in CloudFormation area (e.g. @kanitkah @ziarrdan @LariWo), we thought of "exclusion list", which should be part of the CloudFormation template. By doing so, we could add this "exclusion-list for resources inside the stack, which should not be checked" to our version controlled CFN/CDK projects/files.
Since the benefit for case (2) is clear - Removing the resouce from list, after the github issue with the false-postive is solved. I'd like to add an example for case (1) here based on #1198:
Our Stack-A having a SecurityGroup (e.g. of an EC2 with a legacy database, later called as Logical ID
DatabaseSecGroupIngressStaticInSync
). All resources and stacks of this Team-A are not dynamically. Once deployed Team-A taking care of Stack-A.There is a Team-B. This team utilize more cloud-native patterns, hence they create there ECS container-cluster only on request and drop this infrastructure (+ stacks, etc) after the workload is done and not required anymore.
There is a "contract" between Team-B and Team-A: In order to allow the Team-B's ECS components to access the database, Team-A defined a dedictated SecurityGroup for them (later named with Logical ID
ThisSecGroupIsAlwaysDrifted
) and inform on the Physical ID (likesg-666xyz
), where Team-B can "inject" Ingress rules to access the database by defining aAWS::EC2::SecurityGroupIngress
in TeamB's CFN/CDK. Team-A helps this pattern as well, since Team-B doesn't need to request new rules everytime once ECS is active and later removed again.As we can see, Team-A encapsulate the access from Team-B using a dedicated SecurityGroup. The main reason is caused by issue AWS::EC2::SecurityGroupIngress causing false positive drift within referenced AWS::EC2::SecurityGroup #1198. Once Team-A checking there CloudFormation Stack (here called Stack-A) for Drifts, their SecurityGroup is always in state DRIFTED (due to #1198).
Ideas for this PFR:
AWS::EC2::SecurityGroup
with Logical IDThisSecGroupIsAlwaysDrifted
from Drift Detection.DatabaseSecGroupIngressStaticInSync
should still be part of Drift Detection.Benefits from this PFR:
Other Details
Happy to discuss further ideas or difficulties for such pattern - here via github or via CloudFormation Discord https://discord.gg/9zpd7TTRwq :)
The text was updated successfully, but these errors were encountered: