Last active
April 23, 2020 14:25
-
-
Save ErickWendel/d028b2f5ce74198eb6e3111c7d6577cd to your computer and use it in GitHub Desktop.
This file contains hidden or 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
aws ec2 create-security-group --group-name jenkins-group --description "security group for CI in EC2" | |
# sg-2452a250 | |
MY_IP=$(curl ipinfo.io/ip) | |
aws ec2 authorize-security-group-ingress --group-name jenkins-group \ | |
--protocol tcp --port 8080 --cidr $MY_IP/32 \ | |
aws ec2 authorize-security-group-ingress --group-name jenkins-group \ | |
--protocol tcp --port 22 --cidr $MY_IP/32 | |
aws ec2 create-key-pair --key-name jenkins-key --query 'KeyMaterial' \ | |
--output text > jenkins-key.pem | |
chmod 400 jenkins-key.pem | |
echo 'Running Ubuntu Server 16' \ | |
aws ec2 run-instances --image-id ami-aa2ea6d0 --security-group-ids sg-2452a250 \ | |
--count 1 --instance-type t2.micro --key-name jenkins-key \ | |
--query 'Instances[0].InstanceId' | |
aws ec2 describe-instances --instance-ids "i-03b4544bea7c0cea9" \ | |
--query 'Reservations[*].{instanceId: Instances[0].InstanceId, publicDnsName: Instances[0].PublicDnsName, state: Instances[0].State.Name, publicIpAddress: Instances[0].PublicIpAddress}' | |
ssh -i "jenkins-key.pem" [email protected] | |
aws ec2 terminate-instances --instance-ids "i-0dbb4de5688d021ad" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment