cloudformation-coverage-roadmap icon indicating copy to clipboard operation
cloudformation-coverage-roadmap copied to clipboard

Stack DRIFTED when template matches resources

Open LUKEALDRED opened this issue 4 years ago • 7 comments

Name of the resource

AWS::EC2::SecurityGroupIngress

Resource Name

No response

Issue Description

Drift details "Expected" is missing a security group ingress rule causing an incorrect stack status of DRIFTED.

Expected

{
  "GroupDescription": "Jumpbox Security Group",
  "GroupName": "shared_jbx_sg",
  "SecurityGroupIngress": [
    {
      "FromPort": 3389,
      "IpProtocol": "tcp",
      "SourceSecurityGroupId": "sg-xxxxxxxx",
      "SourceSecurityGroupOwnerId": xxxxxxxx4932,
      "ToPort": 3389
    }
  ],
  "Tags": [
    {
      "Key": "Name",
      "Value": "shared_jbx_sg"
    }
  ],
  "VpcId": "vpc-xxxxxxxx"
}

Actual

{
  "GroupDescription": "Jumpbox Security Group",
  "GroupName": "shared_jbx_sg",
  "SecurityGroupIngress": [
    {
      "FromPort": 3389,
      "IpProtocol": "tcp",
      "SourceSecurityGroupId": "sg-xxxxxxxx",
      "SourceSecurityGroupOwnerId": xxxxxxxx4932,
      "ToPort": 3389
    },
    {
      "FromPort": 3389,
      "IpProtocol": "tcp",
      "SourceSecurityGroupId": "sg-xxxxxxxxxxxxxxxxx",
      "SourceSecurityGroupOwnerId": xxxxxxxx1251,
      "ToPort": 3389
    }
  ],
  "Tags": [
    {
      "Key": "Name",
      "Value": "shared_jbx_sg"
    }
  ],
  "VpcId": "vpc-xxxxxxxx"
}

Expected Behavior

This stack should not be drifted as the resources match the template.

Observed Behavior

Drift status is DRIFTED.

Test Cases

I have commented out the offending AWS::EC2::SecurityGroupIngress resource from the template, saved the template and updated the stack. Stack status changes to IN-SYNC.

I have then uncommented the AWS::EC2::SecurityGroupIngress resource, saved the template and updated the stack. Stack status changes to DRIFTED.

Other Details

No response

LUKEALDRED avatar Nov 07 '22 11:11 LUKEALDRED

Hi @LUKEALDRED - Luke, maybe you hitting the same issue as we reported here: #1198 (AWS::EC2::SecurityGroupIngress causing false positive drift within referenced AWS::EC2::SecurityGroup). Within the above referenced issue, I've added an screenshot of Drift details "Expected". May this helps to cross-check it's the same topic or not.

We are in touch with the CFN team at AWS - In case https://github.com/aws-cloudformation/cloudformation-coverage-roadmap/issues/1198 doesn't cover your case as well, I would like to reconstruct your scenario and share the with the team as well. Thanks a lot. Cheers, Robert.

rgoltz avatar Nov 08 '22 21:11 rgoltz

Hey @LUKEALDRED! If you're still running into this issue, are you able to share some more details about your template? I'd like to try and reproduce this issue so I can figure out what's going on.

davidataws avatar May 22 '25 15:05 davidataws

@davidataws - Thanks for taking on this issue as a team member of AWS. I'm very happy that you're working on these topics for AWS::EC2::SecurityGroup*** here at GitHub! - Could you please take a look at the example in case: https://github.com/aws-cloudformation/cloudformation-coverage-roadmap/issues/1198 - It's containing two examples for the same issue reported here along with a template to repo the problem.

rgoltz avatar May 22 '25 16:05 rgoltz

Yep, I'll have a look at #1198 when I get some time. I'm not sure if this issue is something different, though, or if it's exactly the same problem.

davidataws avatar May 22 '25 16:05 davidataws

Thanks. To arrow down the this issue #1387 here, we have to wait for @LUKEALDRED / Luke - Since we just see the drift (without template), it's hard to reproduce the issue. To be fair, requesting a sample after more than 2 years could be challenging ;-) - But, let's see.

rgoltz avatar May 22 '25 16:05 rgoltz

@rgoltz @davidataws Hi both, apologies I've only just seen your replies. I will have a look and come back with a proper reply. Thanks.

LUKEALDRED avatar Jun 02 '25 10:06 LUKEALDRED

Hi again @rgoltz @davidataws Well the good news is I've just gone into the account and the stack looks to be OK now. The template for the security group in question matches the resources that are present (i.e. both ingress rules are there) and the stack is IN_SYNC. Really appreciate your time but we can probably check this one off.

LUKEALDRED avatar Jun 04 '25 10:06 LUKEALDRED