Day 4 assignment for the subject Fundamentals in Developer Tools in PowerX Program
Requires:
- Terraform 1.0.5
- AWS CLI with login credentials configured
If you are loading this for the first time, follow these instructions to set things up.
-
Make the following changes to
providers.tf
: Line 10 change tobackend "local" {
-
Run the following commands:
terraform init terraform plan terraform apply
-
Create an EC2 Key-Pair by running the command below:
aws ec2 create-key-pair --key-name devtools4 --query 'KeyMaterial' --output text > devtools4.pem chmod 400 devtools4.pem
Here, the name of the key is "devtools4".
-
Make the following changes to
providers.tf
: Line 10 change back to -
backend "s3" {
-
Run the following command to migrate the local state to S3 bucket
terraform init -migrate-state
-
Login to AWS console and check if the S3 bucket is created with the name "
terraform-state-bucket-alkaff
" and with 1 object "devtools-day4.tfstate
"
-
Run the following commands:
terraform init terraform plan terraform apply
This will spin up an EC2 Instance. on the console, the Public and Private IP address will be printed.
-
SSH into the Public IP Address:
ssh -A -i "devtools4.pem" ec2-user@[public_ip]
-
SSH into the Private IP Address:
ssh -i "devtools4.pem" ec2-user@[private_ip]