How to use launch templates with ElasticBeanstalk's AutoScaling

4 minute read
Content level: Intermediate
1

Using AutoScaling with ElasticBeanstalk uses launch configurations. As a result, an error occurs and AWS resource creation fails.

As stated in the document below, the launch configuration has been deprecated, so if you are not using a launch template, you will receive an error.
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environments-cfg-autoscaling-launch-templates.html

Starting on October 1, 2024, the Amazon EC2 Auto Scaling service will no longer support the creation of launch configurations for new accounts. This change is due to launch configurations being phased out and replaced by launch templates by the Amazon EC2 Auto Scaling service. For more information, see Auto Scaling launch configurations in the Amazon EC2 Auto Scaling User Guide.

If you configure AutoScaling with ElasticBeanstalk without taking any action, the following error will occur and creation of AWS resources will fail.

The Launch Configuration creation operation is not available in your account. Use launch templates to create configuration templates for your Auto Scaling groups.

How to deal with it

Launch templates are used by using Option Settings as described in the documentation below.
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environments-cfg-autoscaling-launch-templates.html#environments-cfg-autoscaling-launch-templates-options

  • RootVolumeType option set to gp3. You can set this option with the console or the namespace .
  • BlockDeviceMappings option contains gp3. You can set this option with the console or the namespace.
  • DisableIMDSv1 option set to true. We recommend that you set this option using the namespace.
  • EnableSpot option set to true. For more information, see Spot instance support and Configuration Auto Scaling group configuration .

Try setting

Configure settings using the "eb" command.
First, run "eb init".

eb init

Select a default region
1) us-east-1 : US East (N. Virginia)
2) us-west-1 : US West (N. California)
3) us-west-2 : US West (Oregon)
4) eu-west-1 : EU (Ireland)
5) eu-central-1 : EU (Frankfurt)
6) ap-south-1 : Asia Pacific (Mumbai)
7) ap-southeast-1 : Asia Pacific (Singapore)
8) ap-southeast-2 : Asia Pacific (Sydney)
9) ap-northeast-1 : Asia Pacific (Tokyo)
10) ap-northeast-2 : Asia Pacific (Seoul)
11) sa-east-1 : South America (Sao Paulo)
12) cn-north-1 : China (Beijing)
13) cn-northwest-1 : China (Ningxia)
14) us-east-2 : US East (Ohio)
15) ca-central-1 : Canada (Central)
16) eu-west-2 : EU (London)
17) eu-west-3 : EU (Paris)
18) eu-north-1 : EU (Stockholm)
19) eu-south-1 : EU (Milano)
20) ap-east-1 : Asia Pacific (Hong Kong)
21) me-south-1 : Middle East (Bahrain)
22) af-south-1 : Africa (Cape Town)
23) ap-southeast-3 : Asia Pacific (Jakarta)
24) ap-northeast-3 : Asia Pacific (Osaka)
(default is 3): 9


Select an application to use
1) elasticbeanstalk2
2) elasticbeanstalk
3) [ Create new Application ]
(default is 2): 3


Enter Application Name
(default is "elasticbeanstalk3"): 
Application elasticbeanstalk3 has been created.
Select a platform.
1) .NET Core on Linux
2) .NET on Windows Server
3) Docker
4) Go
5) Java
6) Node.js
7) PHP
8) Packer
9) Python
10) Ruby
11) Tomcat
(make a selection): 7

Select a platform branch.
1) PHP 8.3 running on 64bit Amazon Linux 2023
2) PHP 8.2 running on 64bit Amazon Linux 2023
3) PHP 8.1 running on 64bit Amazon Linux 2023
4) PHP 8.1 running on 64bit Amazon Linux 2
(default is 1): 1

Cannot setup CodeCommit because there is no Source Control setup, continuing with initialization
Do you want to set up SSH for your instances?
(Y/n): n

If "eb init" runs successfully, create a directory called ".ebextensions".

mkdir .ebextensions

Create a file called "options.config" in the ".ebextensions" directory.

cd .ebextensions

cat << EOF > options.config
option_settings:
  aws:autoscaling:launchconfiguration:
    DisableIMDSv1: True
EOF

cd ..

After creating the "options.config" file, run "eb create" to create the environment.

eb create

Enter Environment Name
(default is elasticbeanstalk3-dev): 
Enter DNS CNAME prefix
(default is elasticbeanstalk3-dev): 

Select a load balancer type
1) classic
2) application
3) network
(default is 2): 2


Would you like to enable Spot Fleet requests for this environment? (y/N): y
Enter a list of one or more valid EC2 instance types separated by commas (at least two instance types are recommended).
(Defaults provided on Enter): 

NOTE: The current directory does not contain any source code. Elastic Beanstalk is launching the sample application instead.
Do you want to download the sample application into the current directory? (Y/n): Y

After the deployment is complete, you can confirm that the launch template is being used from the AutoScaling screen.
a

profile picture
EXPERT
published 2 months ago340 views
3 Comments

Followed the same steps, still end up getting the following error

Creating Auto Scaling launch configuration failed Reason: Resource handler returned message: "The Launch Configuration creation operation is not available in your account. Use launch templates to create configuration templates for your Auto Scaling groups. (Service: AutoScaling, Status Code: 400, Request ID: b54ca6aa-7f17-48f0-ba5d-4e23389dd469)" (RequestToken: d99629c8-bc06-6461-8d0a-8f99c69d881f, HandlerErrorCode: GeneralServiceException)

Not sure what is wrong in the default settings

replied 2 months ago

Try committing your .ebextensions/options.config using git commit, then run eb create yourAppName. The error will be resolved.

The reason is:

the EB CLI deploys the latest commit in the current branch, using the commit ID and message as the application version label and description, respectively.

https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb3-cli-git.html

replied 2 months ago

Thanks @easontseng! That's what was missing for me!

@awspriyan try going to S3 and check the bucket elasticbeanstalk-[region]-[account_id] and look for your application name. In that folder you'll find a ".zip" file. Download it and see if the ".ebextensions" folder is there.

If you cannot find it, what @easontseng said is probably the solution.

replied 2 months ago