简体   繁体   中英

AWS EB: Unresolved resource dependencies

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?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM