11

I'm having trouble defining instance type and security groups through .ebextensions/*.config files in the root of my application bundle.

Briefly, I have two config files that look like this:

.ebextensions/01-options.config:

option_settings:
  [...]
  - namespace: 'aws:elasticbeanstalk:application:environment'
    option_name: CONFIG_FILE_ONE
    value: '01-options.config'
  [...]

and .ebextensions/02-app-test-env.config:

option_settings:
  - namespace: 'aws:elasticbeanstalk:application:environment'
    option_name: NODE_ENV
    value: 'Test'

  - namespace: 'aws:elasticbeanstalk:application:environment'
    option_name: CONFIG_FILE_TWO
    value: '02-app-test-env'

  - namespace: aws:autoscaling:launchconfiguration
    option_name: InstanceType
    value: t2.micro

  - namespace: aws:autoscaling:launchconfiguration
    option_name: SecurityGroups
    value: sg-ys75dfs2

Now, the environment variables are being set, so I know it's reading both config files, but the security group and instance type aren't being set - even when I rebuild the environment, instances are still created as t1.micro with default security groups - my settings aren't being applied.

What am I missing here? How can I define the instance type using .config files?

Charles
  • 103
  • 3
Josh Hunt
  • 570
  • 8
  • 12
  • Did you check the logs after the app is up and running? Maybe it complained on one of your options? After reading [this](http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html#customize-containers-format-options) I got the impression that only the namespaces listed in that table is supported, due to this sentence: `[...] The following table displays the namespaces that are supported for each container type. [...]`. But it seems strange if that would be the case. – Bazze Jan 13 '15 at 18:47

2 Answers2

11

You should be able to use what you have in that config file for the launchconfiguration namespace, but you need the single quotes around the namespace and value like you have in the first 2 that are working.

- namespace: 'aws:autoscaling:launchconfiguration'
  option_name: InstanceType
  value: 't2.micro'

- namespace: 'aws:autoscaling:launchconfiguration'
  option_name: SecurityGroups
  value: 'sg-ys75dfs2'

Also, be sure to watch for errors with eb logs if using eb cli 3.x. Hope that helps.

Tyler
  • 111
  • 3
  • I tried this an it both the original and the version with quotes. Neither worked for me. Other settings in my .config such as MinSize and MaxSize are working. Ended up having to use: eb create -i 't2.medium' instead?! – Charles Oct 16 '15 at 13:53
  • @Charles, yeah I'm no longer getting InstanceType to work either, not sure what the problem is there because as you mentioned, the other instance-related options work. – Tyler Oct 17 '15 at 22:59
  • Thanks for the confirmation. Going to post the question in AWS forum ... will report back if I find out the answer. – Charles Oct 17 '15 at 23:23
  • AWS forum question: https://forums.aws.amazon.com/thread.jspa?threadID=218096 – Charles Oct 18 '15 at 00:42
  • 1
    So I think I might be onto what the issue is here, looks like certain items are set at the API level and you have to update them AFTER environment creation. `If you use the Elastic Beanstalk console or EB CLI to create environments, and you want to set these options using configuration files or saved configurations, you can remove the options settings with the AWS CLI or EB CLI after the environment is created.` (http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/command-options.html) – Tyler Oct 19 '15 at 17:03
  • @Tyler, did you happen to figure this out? I'm running into the same problem trying to set my InstanceType to t2.medium – am17torres Nov 25 '15 at 01:23
  • `Recommended values: The EB command line interface (CLI) and Elastic Beanstalk console provide recommended values for some configuration options. These values can be different from the default values and are set at the API level when your environment is created. ... For example, both the EB CLI and Elastic Beanstalk console set the configuration option for EC2 instance type (InstanceType in the aws:autoscaling:launchconfiguration namespace).` (http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/command-options.html) – Charles Dec 30 '15 at 18:28
3

As mentioned in the comments, the settings in the config files are ignored if they are also set on the environment level, (and the setting for InstanceType is automatically created on the environment level).

If you prefer to keep your settings in the config files, you need to remove them from the environment, you can do that for InstanceType with the following command:

aws elasticbeanstalk update-environment --environment-name my-env --options-to-remove Namespace=aws:autoscaling:launchconfiguration,OptionName=InstanceType

See also the AWS docs for other ways to change environment level settings.