Last active
November 29, 2021 22:18
-
-
Save froop/e2d231a02d6a7be8c2b337378da791ea to your computer and use it in GitHub Desktop.
[AWS][Windows] Launch EC2 instance from template
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
set /P TEMPLATE_ID=Template ID: | |
aws ec2 run-instances ^ | |
--launch-template LaunchTemplateId=%TEMPLATE_ID% ^ | |
> ec2-run-instance.log | |
REM change instance type: --instance-type t3.nano ^ | |
aws ec2 describe-instances ^ | |
--filters ^ | |
"Name=tag:aws:ec2launchtemplate:id,Values=%TEMPLATE_ID%" ^ | |
"Name=instance-state-name,Values=pending,running" ^ | |
--query "Reservations[].Instances[].InstanceId" ^ | |
--output text ^ | |
> AWS_EC2_INSTANCE.txt | |
set /P INSTANCE_ID=<AWS_EC2_INSTANCE.txt | |
aws ec2 wait instance-running ^ | |
--instance-ids %INSTANCE_ID% | |
aws ec2 describe-instances ^ | |
--instance-ids %INSTANCE_ID% ^ | |
--query "Reservations[].Instances[].PublicIpAddress" ^ | |
--output text ^ | |
> AWS_EC2_IP.txt | |
set /P IP_ADDRESS=<AWS_EC2_IP.txt | |
setx AWS_EC2_IP %IP_ADDRESS% | |
Pause |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment