2

I'm trying to create a new Elastic Beanstalk environment with the EB CLI but it's failing because of an invalid option, even though that option isn't set in my config.

The command I'm running:

$ eb create my-new-environment -v --timeout 15

The error I'm getting:

2020-09-27 08:45:00    ERROR   "option_settings" in one of the configuration files failed validation. More details to follow.
2020-09-27 08:45:00    ERROR   Invalid option value: '1.0' (Namespace: 'aws:autoscaling:updatepolicy:rollingupdate', OptionName: 'MinInstancesInService'): You can't enable rolling updates for a single-instance environment.
2020-09-27 08:45:01    ERROR   Failed to launch environment.

But I don't have aws:autoscaling:updatepolicy:rollingupdate specified in my config file!

# .ebextensions/settings.config

option_settings:
    aws:elasticbeanstalk:managedactions:
        ManagedActionsEnabled: true
        PreferredStartTime: "Thu:04:00"
    aws:elasticbeanstalk:managedactions:platformupdate:
        UpdateLevel: minor
        InstanceRefreshEnabled: true
    aws:elasticbeanstalk:command:
        DeploymentPolicy: AllAtOnce
    aws:elasticbeanstalk:environment:
        EnvironmentType: SingleInstance
    aws:ec2:instances:
        InstanceTypes: t3.medium
    aws:elasticbeanstalk:cloudwatch:logs:
        StreamLogs: true
        DeleteOnTerminate: true
        RetentionInDays: 1
    aws:elasticbeanstalk:application:
        Application Healthcheck URL: /health
    aws:autoscaling:launchconfiguration:
        MonitoringInterval: 1 minute

Here's my .elasticbeanstalk/config.yml:

# .elasticbeanstalk/config.yml

deploy:
  artifact: out.zip
global:
  application_name: my-application
  branch: null
  default_ec2_keyname: null
  default_platform: 64bit Amazon Linux 2 v2.0.2 running .NET Core
  default_region: eu-west-1
  include_git_submodules: true
  instance_profile: null
  platform_name: null
  platform_version: null
  profile: null
  repository: null
  sc: git
  workspace_type: Application

If it helps I think I did have the MinInstancesInService option set in a previous attempt but I've since deleted that from my config; and I have double and tripled checked that only the new version of my config is in my out.zip artefact.

Aron
  • 8,696
  • 6
  • 33
  • 59
  • Can you run `eb config list` and check if you have any saved configurations? – Marcin Sep 27 '20 at 09:41
  • Nope, got nothing. I also double checked in the console but there are no saved configurations for my application. – Aron Sep 27 '20 at 09:42
  • What about `env.yaml` file? It can also have these settings? – Marcin Sep 27 '20 at 09:52
  • I don't have an env.yaml file, I only have a config.yml file, which I've posted above – Aron Sep 27 '20 at 09:54
  • You are deploying totally new environment? Its not an existing one where you manually set its type in EB console? – Marcin Sep 27 '20 at 10:02
  • Yeah, it's a new environment - though for an existing application – Aron Sep 27 '20 at 10:02
  • [Docs](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/command-options-general.html#command-options-general-autoscalingupdatepolicyrollingupdate) that you can't set `RollingUpdateEnabled` in CLI. EB will overwrite it anyway. Maybe you can try forcing it `eb create my-new-environment -v --timeout 15 --single`? – Marcin Sep 27 '20 at 10:18
  • Sorry I don't understand. I'm *not* setting `RollingUpdateEnabled` in the CLI, I'm *only* setting it in the configuration file, which means that it should work as expected, no? – Aron Sep 27 '20 at 10:22
  • EB CLI ignores some settings from your config files. The list of these settings is [here](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/command-options.html#configuration-options-recommendedvalues). This could probably explain why they are set anyway, as EB CLI will set them by itself, regardless of your configurations. – Marcin Sep 27 '20 at 10:24
  • 1
    Setting `--single` does seem to work... but then what's the point of having the `EnvironmentType: SingleInstance` option set in config if EB always overrides it anyway, either with the CLI or the console? – Aron Sep 27 '20 at 10:32
  • Not sure. Its a design choice that AWS made. But the option works in CloudFormation as I use it a lot there. If you don't mind I would like to provide an answer. – Marcin Sep 27 '20 at 10:35
  • 1
    Yeah go for it :) – Aron Sep 27 '20 at 10:35

2 Answers2

5

Based on the comments.

The issue was caused by the fact that EB CLI ignores some settings from the config files. From docs:

Because the recommended values are set at the API level, they will override values for the same options that you set in configuration files or saved configurations.

The solution was to explicitly set the EB environment to single-instance type, using EB CLI option --single.

eb create my-new-environment -v --timeout 15 --single
Marcin
  • 215,873
  • 14
  • 235
  • 294
  • 1
    Just to note that the question still remains that "what's the point of having the `EnvironmentType: SingleInstance` option set in config if EB always overrides it anyway, either with the CLI or the console?" – Aron Sep 27 '20 at 10:46
2

It's easy to disable "rolling update" from AWS console by selecting the EB instance and select configuration, and then select Rolling Update, and disabled it. You can. now specify a single instance with no load balancing.

This is what I did to save some $ when the instance is deployed mostly for testing purpose or you don't anticipate much traffic on the backend.

David

us_david
  • 4,431
  • 35
  • 29
  • TIL we need load balancing if we want "deployments without downtime" (i.e rolling updates) If we choose single instance option in `Environment-->configuration --> capacity` , it will show error about rolling updates. So disable the `rolling updates` first and then move from `load balanced` to single `instance` –  Feb 27 '23 at 06:51
  • @RandString You may have a point here :-) – us_david Feb 28 '23 at 16:06