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::ElasticLoadBalancingV2::Listener] - [BUG] - False-positive drift for ListenerAttributes/tcp.idle_timeout.seconds #2198

Open
r-heimann opened this issue Nov 25, 2024 · 1 comment
Labels

Comments

@r-heimann
Copy link

Name of the resource

AWS::ElasticLoadBalancingV2::Listener

Resource Name

No response

Issue Description

We found a false-positive CloudFormation drift for

  Listener:
    Type: AWS::ElasticLoadBalancingV2::Listener
    Properties:
      LoadBalancerArn: !GetAtt NLB.LoadBalancerArn
      Port: 8080
      Protocol: TCP
      DefaultActions:
        - Type: forward
          TargetGroupArn: !GetAtt TargetGroup.TargetGroupArn
      ListenerAttributes:
        - Key: tcp.idle_timeout.seconds # <-
          Value: 6000
Property Change Expected value Current value
ListenerAttributes REMOVE [{"Key":"tcp.idle_timeout.seconds","Value":6000}] -

Expected Behavior

CloudFormation Drift Detection is able to find the configuration.

Observed Behavior

It doesn't work.

Test Cases

AWSTemplateFormatVersion: 2010-09-09
Description: Test

Resources:
  NLB:
    Type: AWS::ElasticLoadBalancingV2::LoadBalancer
    Properties:
      IpAddressType: ipv4
      Scheme: internal
      Type: network
      Subnets:
        - <subnet1>

  Listener:
    Type: AWS::ElasticLoadBalancingV2::Listener
    Properties:
      LoadBalancerArn: !GetAtt NLB.LoadBalancerArn
      Port: 8080
      Protocol: TCP
      DefaultActions:
        - Type: forward
          TargetGroupArn: !GetAtt TargetGroup.TargetGroupArn
      ListenerAttributes:
        - Key: tcp.idle_timeout.seconds
          Value: 6000

  TargetGroup:
    Type: AWS::ElasticLoadBalancingV2::TargetGroup
    Properties:
      VpcId: <vpc-id>
      Port: 8080
      Protocol: TCP
      TargetType: ip
      TargetGroupAttributes:
        - Key: deregistration_delay.timeout_seconds
          Value: 300
        - Key: preserve_client_ip.enabled
          Value: true

### Other Details

_No response_
@r-heimann r-heimann added the bug label Nov 25, 2024
@greg5123334
Copy link

Confirmed.

vpc = ec2.Vpc(self, "VPC", max_azs=2)

lb = elbv2.NetworkLoadBalancer(
    self,
    "LB",
    vpc=vpc,
    internet_facing=True,
)

# Add a listener on a particular port.
listener = lb.add_listener(
    "Listener", port=8080, tcp_idle_timeout=Duration.seconds(300)
)

asg = autoscaling.AutoScalingGroup(
    self,
    "ASG",
    vpc=vpc,
    instance_type=ec2.InstanceType.of(
        ec2.InstanceClass.BURSTABLE3, ec2.InstanceSize.MEDIUM
    ),
    machine_image=ec2.AmazonLinuxImage(),
)
listener.add_targets("AppFleet", port=8080, targets=[asg])

Expected

{
  "DefaultActions": [
    {
      "TargetGroupArn": "arn:aws:elasticloadbalancing:eu-west-1:000000000000:targetgroup/Sandbo-LBLis-xxxxxxxx/xxxxxxxx",
      "Type": "forward"
    }
  ],
  "ListenerAttributes": [
    {
      "Key": "tcp.idle_timeout.seconds",
      "Value": 300
    }
  ],
  "LoadBalancerArn": "arn:aws:elasticloadbalancing:eu-west-1:000000000000:loadbalancer/net/Sandbo-LB8A1-xxxxxxxx/xxxxxxxx",
  "Port": 8080,
  "Protocol": "TCP"
}

Actual

{
  "DefaultActions": [
    {
      "TargetGroupArn": "arn:aws:elasticloadbalancing:eu-west-1:000000000000:targetgroup/Sandbo-LBLis-xxxxxxxx/xxxxxxxx",
      "Type": "forward"
    }
  ],
  "LoadBalancerArn": "arn:aws:elasticloadbalancing:eu-west-1:000000000000:loadbalancer/net/Sandbo-LB8A1-xxxxxxxx/xxxxxxxx",
  "Port": 8080,
  "Protocol": "TCP"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants