cloud(aws) level 1 lab 39
how to perform steps
- Before you can change the instance type, the EC2 instance must be in a stopped state.
aws ec2 stop-instances --instance-ids <instance-id>
Replace <instance-id>
with the ID of the EC2 instance you want to modify.
- Once the instance is stopped, you can change its instance type using the following command:
aws ec2 modify-instance-attribute --instance-id <instance-id> --instance-type "{\"Value\": \"<new-instance-type>\"}"*
Replace <instance-id>
with the ID of the instance you want to modify and <new-instance-type>
with the desired EC2 instance type (e.g., t3.medium
).
- After modifying the instance type, start the EC2 instance again
aws ec2 start-instances --instance-id <instance-id>
-
Stop the EC2 instance
aws ec2 stop-instances --instance-ids $(aws ec2 describe-instances --filters “Name=tag:Name,Values=devops-ec2” --query “Reservations[].Instances[].InstanceId” --output text) -
Modify the instance type
aws ec2 modify-instance-attribute --instance-id $(aws ec2 describe-instances --filters “Name=tag:Name,Values=devops-ec2” --query “Reservations[].Instances[].InstanceId” --output text) --instance-type “t2.nano” -
Start the EC2 instance
aws ec2 start-instances --instance-ids $(aws ec2 describe-instances --filters “Name=tag:Name,Values=devops-ec2” --query “Reservations[].Instances[].InstanceId” --output text) -
Verify the instance state (optional)
aws ec2 describe-instances --filters “Name=tag:Name,Values=devops-ec2” --query “Reservations[].Instances[].[InstanceId,State.Name,InstanceType]” --output table