Reputation: 13573
I want to use boto3 to change the EC2 instance types in an Elastic Beanstalk environment.
However, I can't find the correct function to do that.
update_environment
doesn't seem to provide the ability to change EC2 instance type.
All the update_*
functions don't seem to provide this functionality.
My Environment type
is Load balanced
, and I use Combine purchase options and instances
for Fleet composition
.
Anyone knows how to change the instance types used by elastic beanstalk?
Upvotes: 3
Views: 1241
Reputation: 238209
You can use update_environment to update instance type.
Verified example (i.e. I used it on my own EB env):
import boto3
eb = boto3.client('elasticbeanstalk')
response = eb.update_environment(
ApplicationName='<your-eb-app-name>',
EnvironmentName='<your-eb-env-name>',
OptionSettings=[
{
'Namespace': 'aws:autoscaling:launchconfiguration',
'OptionName': 'InstanceType',
'Value': 't2.small'
},
]
)
print(response)
The spot settings for EB env are set using aws:ec2:instances.
response = eb.update_environment(
ApplicationName='<your-eb-app-name>',
EnvironmentName='<your-eb-env-name>',
OptionSettings=[
{
'Namespace': 'aws:ec2:instances',
'OptionName': 'EnableSpot',
'Value': 'true'
},
{
'Namespace': 'aws:ec2:instances',
'OptionName': 'InstanceTypes',
'Value': 't2.large,t3.large'
}
]
)
There are more options to be set, which depend on your exact requirements.
Upvotes: 3