Subtubes
Subtubes

Reputation: 16883

Is it possible to create and Auto Scaling Group Launch config with the CLI and define the instance tags in one command?

Is it possible to create and Auto Scaling Group Launch config with the CLI and define the instance tags in one command?

Maybe I am missing something but right now it looks like have to do it in two steps.

i.e.

aws autoscaling create-launch-configuration ...

and then

aws autoscaling create-or-update-tags --tags ...

Upvotes: 0

Views: 218

Answers (1)

AmigoSe
AmigoSe

Reputation: 366

Since you need to have asg LC created first to tag it, it is two step process as you mentioned. https://docs.aws.amazon.com/cli/latest/reference/autoscaling/create-launch-configuration.html

This example creates a launch configuration based on an existing instance. In addition, it also specifies launch configuration attributes such as a security group, tenancy, Amazon EBS optimization, and a bootstrapping script:

https://docs.aws.amazon.com/autoscaling/ec2/userguide/autoscaling-tagging.html

aws autoscaling create-launch-configuration --launch-configuration-name my-launch-config --key-name my-key-pair --instance-id i-7e13c876 --security-groups sg-eb2af88e --instance-type m1.small --user-data file://myuserdata.txt --instance-monitoring Enabled=true --no-ebs-optimized --no-associate-public-ip-address --placement-tenancy dedicated --iam-instance-profile my-autoscaling-role

aws autoscaling create-or-update-tags --tags "ResourceId=my-asg,ResourceType=auto-scaling-group,Key=environment,Value=test,PropagateAtLaunch=true"

Upvotes: 1

Related Questions