0

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?

peer
  • 4,171
  • 8
  • 42
  • 73

2 Answers2

1

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

option_settings:
  aws:elasticbeanstalk:application:environment:
    SPRING_PROFILES_ACTIVE: elasticbeanstalk
Marcin
  • 215,873
  • 14
  • 235
  • 294
  • I can't find it anymore, but I think `aws:elasticbeanstalk:application:environment:` is the default and can be omitted. After I made it work (see my answer) I tried the options.config from my question again and it still works. – peer Feb 23 '22 at 00:35
0

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.

peer
  • 4,171
  • 8
  • 42
  • 73