AWS EB: Unresolved resource dependencies
Asked Answered
B

3

2

My Django app is deployed and working thanks to this fantastic article: https://medium.com/@justaboutcloud/how-to-deploy-a-django3-application-on-elastic-beanstalk-python3-7-and-amazon-linux-2-bd9b8447b55

I'm to the end of the project and am setting up HTTPS. To do that, I've created a config file in my .ebextensions folder called 02_https.config

In this file, I copy and pasted the code from the article:

option_settings:
  aws:elbv2:listener:443:
    SSLCertificateArns: <YourACMCertificateARN>
    Protocol: HTTPS
Resources:
    AWSEBV2LoadBalancerListener:
      Type: 'AWS::ElasticLoadBalancingV2::Listener'
      Properties:
        LoadBalancerArn: { "Ref" : "AWSEBV2LoadBalancer" }
        DefaultActions:
          - RedirectConfig:
              Port: 443
              Protocol: HTTPS
              StatusCode: HTTP_301
            Type: redirect
        Port: 80
        Protocol: HTTP

When I deploy the app, I get this error message:

Service:AmazonCloudFormation, Message:Template format error: Unresolved resource dependencies [AWSEBV2LoadBalancer] in the Resources block of the template

I have two theories:

  1. I'm not pasting the ARN Certificate in the correct format, which is throwing off my YAML formatting

  2. There is something wrong about this code's formatting.

Could someone please provide some input?

Blumenfeld answered 28/5, 2020 at 6:32 Comment(1)
you are using the old classic load balancer elb instead of the new application one elbv2Finder
M
6

To me, none of your theory seems to be correct for the error you're receiving due to a couple of reasons.

First of all, let's read the error carefully.

Service:AmazonCloudFormation, Message:Template format error: Unresolved resource dependencies [AWSEBV2LoadBalancer] in the Resources block of the template

The CFN stack backing the EB environment complaining about the unresolved dependency "AWSEBV2LoadBalancer". This means that the stack being created doesn't know what this logical id "AWSEBV2LoadBalancer" is for.

This can only happen if your beanstalk application is either:

A single instance application (no LB)

or

Using ELB (classic V1 LB) whose logical id in EB CFN stack is "AWSEBLoadBalancer" and not "AWSEBV2LoadBalancer".

The later "AWSEBV2LoadBalancer" is being used as logical id for application and network LBs.

From the medium article link you shared, I see that the author created his environment with application load balancer. Did you miss this?

eb create django3 --elb-type application --region eu-west-1 

Also the code snippet you shared is a valid YAML.

Memorialize answered 8/6, 2020 at 20:13 Comment(1)
I have the same error and my case is this: A single instance application (no LB) that's because is the worker, any way to ignore that config for the worker?Laclos
I
2

You are trying to use the Load Balancer for redirecting HTTP requests to HTTPS. But you are using a EB Environment type: Single instance which does not come with a load balancer.

Either switch to EB Environment type: Load balanced or stop using the Load Balancer for redirecting HTTP requests to HTTPS.

Impiety answered 10/12, 2021 at 23:10 Comment(0)
D
0

A similar error occurred in our case when using CloudFormation to create a stack with two elasticbeanstalk environments:

Service:AmazonCloudFormation, Message:Template format error: Unresolved resource dependencies [AWSEBV2LoadBalancer] in the Resources block of the template

The AWSEBV2LoadBalancer refers to the resource that is automatically created by Elastic Beanstalk when you create an environment of the "Load balanced" type.

Our setup:

  • a single cloudformation template creates one basic environment of the WebServer tier and one environment of the Worker tier
  • only the WebServer environment is load balanced
  • the exact same application version is deployed to both environments
  • .ebextensions contains HTTPS config for the load balancer, similar to OP

Cause:

The same app version is used for both the WebServer and the Worker. This means cloudformation also tries to apply the load balancer HTTPS configuration to the worker, even though that does not make sense, because a worker does not actually have a load balancer.

Solution:

Disabling the HTTPS config for the worker solved the issue.

Note:

Using the Elastic Beanstalk web console, or CloudFormation, it is possible to create a Worker environment that is apparently "Load balanced". However, no actual load balancer is created for such a worker. So even if your worker's EnvironmentType is "LoadBalanced", there is no actual AWSEBV2LoadBalancer resource. The "LoadBalanced" setting only enables auto-scaling to multiple instances.

Deerhound answered 4/7 at 10:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.