About
An example aws ec2 ubuntu virtual machine.
Usage (on a Ubuntu Desktop)
Install the tools:
./provision-tools.sh
Set the account:
# set the account credentials.
# NB get these from your aws account iam console.
# see Managing access keys (console) at
# https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html#Using_CreateAccessKey
export AWS_ACCESS_KEY_ID='TODO'
export AWS_SECRET_ACCESS_KEY='TODO'
# set the default region.
export AWS_DEFAULT_REGION='eu-west-1'
# show the user, user amazon resource name (arn), and the account id.
aws sts get-caller-identity
Review main.tf
.
Initialize terraform:
make terraform-init
Launch the example:
make terraform-apply
At VM initialization time cloud-init will run the provision-app.sh
script to launch the example application.
After VM initialization is done (check the instance system log for cloud-init entries), test the app
endpoint:
wget -qO- "http://$(terraform output --raw app_ip_address)/test"
And open a shell inside the VM:
ssh "ubuntu@$(terraform output --raw app_ip_address)"
cloud-init status --wait
tail /var/log/cloud-init-output.log
exit
Destroy the example:
make terraform-destroy
References
- Environment variables to configure the AWS CLI
- Managing access keys (console)
- AWS General Reference
- Connect to the internet using an internet gateway