- AWS administrator account credentials
- aws CLI
export AWS_PAGER=
ssh-keygen -t rsa -C "my-key" -f $HOME/.ssh/my-key
aws ec2 import-key-pair --key-name "my-key" --public-key-material fileb://$HOME/.ssh/my-key.pub
You will have to press
Ctrl+c
to exit after issuing the second command above
aws ec2 run-instances --image-id {AMI_ID} --instance-type=m4.large --key-name my-key
Replace
{AMI_ID}
above with the AMI ID of the image you're hosting in your AWS account and region.
aws ec2 describe-instances
Pay attention to the
InstanceId
andPublicDnsName
in the JSON output returned.
ssh -i $HOME/.ssh/my-key ubuntu@{INSTANCE_PUBLIC_DNS_NAME}
You were paying attention weren't you? The
{INSTANCE_PUBLIC_DNS_NAME}
is available from the output of the prior command you issued.
One time setup
You will need to install the plugins the Tanzu CLI requires after connecting by exploding the tarball and executing tanzu plugin install --local cli all
Any on-demand EC2 instance in a running state can be stopped with
aws ec2 stop-instances --instance-ids {INSTANCE_ID}
And started again with
aws ec2 start-instances --instance-ids {INSTANCE_ID}
Replace
{INSTANCE_ID}
above with the instance ID of the image you intend to stop or start
If we want to remove the instance completely, then we can terminate the instance with
aws ec2 terminate-instances --instance-ids {INSTANCE_ID}
Replace
{INSTANCE_ID}
above with the instance ID of the image you intend to terminate