question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

aws-elasticloadbalancingv2: Resource of type 'AWS::ElasticLoadBalancingV2::Listener' with identifier 'Idempotency Check Failed' already exists.

See original GitHub issue

❓ General Issue

The Question

We are trying to run our cloudformation template to modify our environment but keep getting this error:

Resource of type 'AWS::ElasticLoadBalancingV2::Listener' with identifier 'Idempotency Check Failed' already exists.

Environment

  • CDK CLI Version: Not using
  • Module Version: 1.89.0
  • Node.js Version: 14.15.4
  • OS: Ubuntu 18.04.5 LTS
  • Language (Version): TypeScript 3.9.7

Other information

Here is the load balancer related code:

import * as elb from '@aws-cdk/aws-elasticloadbalancingv2';

const loadBalancer = new elb.ApplicationLoadBalancer(this, 'Alb', {
            vpc: props.vpc,
            internetFacing: true
});

const listener = loadBalancer.addListener(`PublicListener`, {
            protocol: elb.ApplicationProtocol.HTTPS,
            port: 443,
            open: true,
            defaultAction: elb.ListenerAction.fixedResponse(200, {
                contentType: 'text/html',
                messageBody: `<html><head><title>Load Balancer</title></head><body>${this.namespace}</body></html>`
            })
        });

listener.addCertificates('Arns', [elb.ListenerCertificate.fromCertificateManager(props.certificate)]);

loadBalancer.addListener('PublicRedirectListener', {
            protocol: elb.ApplicationProtocol.HTTP,
            port: 80,
            open: true,
            defaultAction: elb.ListenerAction.redirect({
                port: '443',
                protocol: elb.ApplicationProtocol.HTTPS,
                permanent: true,
            })
        });

Here is the actual error from CloudFormation:

image

The listener in question (HTTPS listener) already exists so CloudFormation should just keep going as we are just updating some other resources.

Here is a picture of the listener that already exists:

image

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
peterwoodworthcommented, Aug 4, 2021

I was able to reproduce this issue. According to CloudFormation, if the arn of the Listener is updated (this would happen if you change the id) then a replacement of the resource will need to happen. When cloudformation replaces a resource, it will first create the replacement resource then delete the old resource. This will cause a failure during deployment because it will try to create a Listener with a port that’s already being used by the listener (despite the fact that the listener already using the port would be about to be deleted).

To fix this, you’ll want to either adjust your code so that CFN doesn’t think it needs to recreate your resource, or if you want to keep your configuration the way it currently I’m not sure what the best way to solve this would be. If deleting just the listener doesn’t cause any issues that could potentially work. If you figure a way out of this situation let me know, and if you need additional help or guidance, feel free to ping me 😄

0reactions
chungllai2commented, Mar 20, 2022

I am using elastic beanstalk & having the same error.

TLDR: If you create the ALB manually, don’t try to update the config with cloudformation file

@peterwoodworth is right, on my case, I create the Load balancer MANUALLY on elastic beanstalk management console.

When I updated it with a .ebextensions/alb-http-to-https-redirection-full.config, it will prompt this error

Read more comments on GitHub >

github_iconTop Results From Across the Web

AWS::ElasticLoadBalancingV2::Listener - AWS CloudFormation
Specifies a listener for an Application Load Balancer, Network Load Balancer, or Gateway Load Balancer.
Read more >
a listener already exists on this port for this load balancer
Resource of type 'AWS::ElasticLoadBalancingV2::Listener' with identifier 'Idempotency Check Failed' already exists. Environment. CDK CLI Version: Not using ...
Read more >
@aws-cdk/aws-elasticloadbalancingv2 - npm
Start using @aws-cdk/aws-elasticloadbalancingv2 in your project by running ... TypeScript icon, indicating that this package has built-in type declarations.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found