Load balancer being created by elastic beanstalk isn't a network load balancer

0

I have a django rest api that I'm trying to deploy on a docker container to elastic beanstalk. I have a .ebextensions folder with four files in it for my configuration. In one of those files (04_elb.config), I specify the load balancer type to network:

  - namespace: aws:elasticbeanstalk:environment
    option_name: LoadBalancerType
    value: network

However, when I run eb create restapi-prod to create the environment, I can see the load balancer that was created is an application load balancer, when it obviously should be a network load balancer. Any assistance on this problem would be much appreciated.

Further context:

My full configuration in .ebextensions:

.ebextensions/01_env.config

option_settings:
  - namespace: aws:elasticbeanstalk:environment
    option_name: ServiceRole
    value: AWSServiceRoleForElasticBeanstalk
  - namespace: aws:elasticbeanstalk:environment:process:default
    option_name: HealthCheckPath
    value: /health
  - namespace: aws:elasticbeanstalk:environment:process:default
    option_name: Port
    value: 8000
  - namespace: aws:elasticbeanstalk:environment:proxy
    option_name: ProxyServer
    value: none
  - namespace: aws:elasticbeanstalk:cloudwatch:logs
    option_name: StreamLogs
    value: true
  - namespace: aws:elasticbeanstalk:cloudwatch:logs
    option_name: DeleteOnTerminate
    value: true
  - namespace: aws:elasticbeanstalk:cloudwatch:logs
    option_name: RetentionInDays
    value: 7

.ebextensions/02_vpc.config

option_settings:
  - namespace: aws:ec2:vpc
    option_name: VPCId
    value: vpc-xxxx
  - namespace: aws:ec2:vpc
    option_name: Subnets
    value: subnet-xxxx, subnet-xxxx, subnet-xxxx

.ebextensions/03_vpc.config

option_settings:
  - namespace: aws:autoscaling:launchconfiguration
    option_name: InstanceType
    value: t2.micro
  - namespace: aws:autoscaling:launchconfiguration
    option_name: SecurityGroups
    value: sg-xxxx sg-xxxx, sg-xxxx
  - namespace: aws:autoscaling:launchconfiguration
    option_name: IamInstanceProfile
    value: AwsElasticBeanstalkEc2Role

.ebextensions/04_elb.config

option_settings:
  - namespace: aws:elasticbeanstalk:environment
    option_name: LoadBalancerType
    value: network
  - namespace: aws:elbv2:listener:443
    option_name: Protocol
    value: TCP
  - namespace: aws:ec2:vpc
    option_name: ELBScheme
    value: internal
  - namespace: aws:ec2:vpc
    option_name: ELBSubnets
    value: subnet-xxxx, subnet-xxxx, subnet-xxxx

My config.yml file in .elasticbeanstalk

branch-defaults:
  default:
    environment: restapi-prod
    group_suffix: null
global:
  application_name: restapi
  branch: null
  default_ec2_keyname: null
  default_platform: Docker running on 64bit Amazon Linux 2023
  default_region: us-west-2
  include_git_submodules: true
  instance_profile: null
  platform_name: null
  platform_version: null
  profile: eb-cli
  repository: null
  sc: null
  workspace_type: Application

And lastly the contents of my env.yml

SolutionStack: 64bit Amazon Linux 2023 v4.3.0 running Docker
Spencer
已提问 1 个月前148 查看次数
3 回答
1

I somehow stumbled upon this stack overflow question which actually addresses this: https://stackoverflow.com/questions/48491702/is-it-possible-to-configure-an-application-load-balancer-with-elastic-beanstalk

Using this inside the elb config file makes sure that the lb is of the network type.

Resources:
  AWSEBV2LoadBalancer:
    Type: AWS::ElasticLoadBalancingV2::LoadBalancer
    Properties:
      Scheme: internal
      Subnets:
        - subnet-0b9cd43a6494e4fd5
        - subnet-0c387b32e825aa0d4
        - subnet-0c2fd1584b2d52e05
      Type: network
Spencer
已回答 1 个月前
0

Hello.

".ebextensions" are loaded alphabetically.
So, in your case, "01_env.config" will be loaded first.
If I put the NLB settings in "01_env.config", will it be loaded?
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/command-options.html#configuration-options-precedence

Configuration Files (.ebextensions) – Settings for any options that are not applied directly to the environment, and also not specified in a saved configuration, are loaded from configuration files in the .ebextensions folder at the root of the application source bundle.

Configuration files are executed in alphabetical order. For example, .ebextensions/01run.config is executed before .ebextensions/02do.config.

Also, since the settings to be read have priority, you will need to check whether ALB is specified in the higher settings.

Settings applied directly to the environment
Saved Configurations
Configuration Files (.ebextensions)
Default Values

profile picture
专家
已回答 1 个月前
profile picture
专家
已审核 1 个月前
  • If I move the elb config to the top of the list of configs by renaming it 01_elb.config, the problem persists. When I'm creating the environment via the eb cli, I don't pass any other arguments and I have no saved environment configs, so I don't know where a load balancer setting would be overriding the setting I have in the config file which specifies a network load balancer.

-1

By default, Elastic Beanstalk creates an Application Load Balancer when you enabled load balancing. You can choose the type of load balancer during environment creation by setting the load balancer type to "Network" in the configuration file which is documented under Network Load Balancer namespaces section.

profile pictureAWS
专家
已回答 1 个月前
  • The configuration already specifies this as you can see in the original post. My question was why this was failing to creating a network load balancer as expected.

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则