Home > Net >  How to configure an environment variable for a new environment?
How to configure an environment variable for a new environment?

Time:02-23

I'm using eb create to create a new environment. The file structure is:

myapp
 '- .ebextensions
      '- options.config
 '- elasticbeanstalk
      '- config.yml

However the environment variables are not created, which I can confirm via: Elastic Beanstalk > Environments > myenv Configuration.

My options.config is:

option_settings:
  - option_name: SPRING_PROFILES_ACTIVE
    value: elasticbeanstalk

My config.yaml is:

branch-defaults:
  feature/highscore:
    environment: myapp-dev
    group_suffix: null
  main:
    environment: null
    group_suffix: null
deploy:
  artifact: build/libs/my-app-name.zip
global:
  application_name: my app name
  branch: null
  default_ec2_keyname: aws-eb
  default_platform: Corretto 11 running on 64bit Amazon Linux 2
  default_region: eu-central-1
  include_git_submodules: true
  instance_profile: null
  platform_name: null
  platform_version: null
  profile: null
  repository: null
  sc: git
  workspace_type: Application

What am I doing wrong? Why are the environment variables not loaded in elastic beanstalk?

CodePudding user response:

Environment variables are setup using aws:elasticbeanstalk:application:environment. So it should be:

option_settings:
  aws:elasticbeanstalk:application:environment:
    SPRING_PROFILES_ACTIVE: elasticbeanstalk

CodePudding user response:

I didn't know .ebextensions needs to be in the zip folder (thanks https://stackoverflow.com/a/26804625/3014199). I am uploading a locally compiled jar instead of the whole folder, so it didn't go there automatically. If my-app-name.zip comprises both my-app-name.jar and .ebextensions it works.

  • Related