Last active
July 5, 2021 16:04
-
-
Save immanuelpotter/3b36c3199ff5a86efef79d3411c021da to your computer and use it in GitHub Desktop.
quickly launch an amazon linux 1 instance that doesn't need to be in terraform on ec2 for messing around
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
KEY_NAME=blah | |
SG_ID=blah | |
SUBNET_ID=blah | |
AWS_PROFILE=blah | |
AWS_REGION=eu-west-2 | |
aws_cmd(){ | |
aws --profile $AWS_PROFILE --region $AWS_REGION "$@" | |
} | |
get_image_id(){ | |
aws_cmd ec2 describe-images \ | |
--filters \ | |
Name=name,Values='*-image-name-we-made' \ | |
Name=architecture,Values=x86_64 \ | |
Name=root-device-type,Values=ebs \ | |
--query 'sort_by(Images, &Name)[-1].ImageId' \ | |
--output text | |
} | |
main(){ | |
aws_cmd ec2 run-instances \ | |
--image-id "$(get_image_id)" \ | |
--instance-type m5.large \ | |
--count 1 \ | |
--key-name $KEY_NAME \ | |
--security-group-ids $SG_ID \ | |
--subnet-id $SUBNET_ID \ | |
--block-device-mappings 'DeviceName=/dev/sda1,Ebs={VolumeSize=40}' | |
} | |
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
KEY_NAME=<set this> | |
aws ec2 run-instances --image-id | |
"$(aws ec2 describe-images \ | |
--filters \ | |
Name=name,Values='Amazon Linux*' \ | |
Name=architecture,Values=x86_64 \ | |
Name=root-device-type,Values=ebs \ | |
--query 'sort_by(Images, &Name)[-1].ImageId' \ | |
--output text)" \ | |
--instance-type t2.micro --count 1 --key-name $KEY_NAME --security-groups default |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment