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

ElasticLoadBalancingV2: ApplicationLoadBalancer http2.enabled from false to true is ignored in cloudformation #31609

Closed
1 task
Assignees
Labels
@aws-cdk/aws-elasticloadbalancingv2 Related to Amazon Elastic Load Balancing V2 bug This issue is a bug. effort/small Small work item – less than a day of effort p2

Comments

@robob4him
Copy link

Describe the bug

When an ApplicationLoadBalancer routing.http2.enabled attribute is modified from "false" to "true" CDK will remove the attribute with the expectation that "true" will be the default. CloudFormation does not remove the attribute nor does it set the attribute value back to default.

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Version

No response

Expected Behavior

Modifying the attribute value from "false" to "true" modifies the load balancer attribute from "false" to "true"

Current Behavior

Value remains "false" despite the attribute being removed.

Reproduction Steps

New instance of load balancer, http2.enabled set to false; deploy
Modify http2 from false to true; deploy

Possible Solution

When http2 is not undefined, reflect string value

Additional Information/Context

No response

CDK CLI Version

2.160.0 (build 7a8ae02)

Framework Version

No response

Node.js Version

v18.19.1

OS

Ubuntu 24.04.1 LTS

Language

.NET

Language Version

.Net 8.0.108

Other information

No response

@robob4him robob4him added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Oct 1, 2024
@github-actions github-actions bot added the @aws-cdk/aws-elasticloadbalancingv2 Related to Amazon Elastic Load Balancing V2 label Oct 1, 2024
@ashishdhingra ashishdhingra self-assigned this Oct 1, 2024
@ashishdhingra ashishdhingra added investigating This issue is being investigated and/or work is in progress to resolve the issue. and removed needs-triage This issue or PR still needs to be triaged. labels Oct 1, 2024
@ashishdhingra
Copy link
Contributor

ashishdhingra commented Oct 1, 2024

Reproducible using code below:

import * as cdk from 'aws-cdk-lib';
import * as ec2 from 'aws-cdk-lib/aws-ec2';
import * as elbv2 from 'aws-cdk-lib/aws-elasticloadbalancingv2';

export class CdktestStack extends cdk.Stack {
  constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

    const vpc = ec2.Vpc.fromLookup(this, 'DefaultVpc', { isDefault: true });
    new elbv2.ApplicationLoadBalancer(this, "TestALB", {
      vpc,
      http2Enabled: false
    });
  }
}

This creates an ALB with HTTP/2 set as Off.

Setting http2Enabled to true thereafter displays the following output when running cdk diff:

Resources
[~] AWS::ElasticLoadBalancingV2::LoadBalancer TestALB TestALB70A5B1F2 
 └─ [~] LoadBalancerAttributes
     └─ @@ -2,9 +2,5 @@
        [ ]   {
        [ ]     "Key": "deletion_protection.enabled",
        [ ]     "Value": "false"
        [-]   },
        [-]   {
        [-]     "Key": "routing.http2.enabled",
        [-]     "Value": "false"
        [ ]   }
        [ ] ]

So it removes the attribute, which is due to check here only sets routing.http2.enabled attribute if property http2Enabled is explicitly set to false.

Running cdk deploy appears to cause CloudFormation stack to be updated, but the ALB's HTTP/2 doesn't get updated. So simply removing the attribute would not reset it to default On. The attribute routing.http2.enabled needs to be explicitly set to true for CloudFormation to change it. This could be verified by using the following property override as a workaround (assuming that the position of routing.http2.enabled in LoadBalancerAttributes collection is known, 2nd in this case):

import * as cdk from 'aws-cdk-lib';
import * as ec2 from 'aws-cdk-lib/aws-ec2';
import * as elbv2 from 'aws-cdk-lib/aws-elasticloadbalancingv2';

export class CdktestStack extends cdk.Stack {
  constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

    const vpc = ec2.Vpc.fromLookup(this, 'DefaultVpc', { isDefault: true });
    const alb = new elbv2.ApplicationLoadBalancer(this, "TestALB", {
      vpc,
      http2Enabled: true
    });

    const cfnLb = alb.node.defaultChild as elbv2.CfnLoadBalancer;
    cfnLb.addPropertyOverride('LoadBalancerAttributes.1.Key', 'routing.http2.enabled');
    cfnLb.addPropertyOverride('LoadBalancerAttributes.1.Value', 'true');
  }
}

Running cdk diff now adds routing.http2.enabled as true in LoadBalancerAttributes:

Resources
[~] AWS::ElasticLoadBalancingV2::LoadBalancer TestALB TestALB70A5B1F2 
 └─ [~] LoadBalancerAttributes
     └─ @@ -2,5 +2,9 @@
        [ ]   {
        [ ]     "Key": "deletion_protection.enabled",
        [ ]     "Value": "false"
        [+]   },
        [+]   {
        [+]     "Key": "routing.http2.enabled",
        [+]     "Value": "true"
        [ ]   }
        [ ] ]


✨  Number of stacks with differences: 1

Deploying it now sets HTTP/2 as On.

@ashishdhingra ashishdhingra added p2 effort/small Small work item – less than a day of effort and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. labels Oct 1, 2024
@mergify mergify bot closed this as completed in #31675 Oct 10, 2024
@mergify mergify bot closed this as completed in c1b240e Oct 10, 2024
Copy link

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

1 similar comment
Copy link

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.