A terraform file that creates a VPC and initialises a public subnet in it.
The build has been tested with Terraform v1.4.5.
Steps:
- Install Terraform
- Expose your AWS "access key id" and "secret access key" to the current terminal session with:
export AWS_ACCESS_KEY_ID=yourAccessKeyId
export AWS_SECRET_ACCESS_KEY=yourSecretAccessKey
- Initialise Terraform with:
terraform init
- Preview the changes that Terraform plans to make to your infrastructure with:
terraform plan
- Apply the changes with:
terraform apply
- Create a
.pem
key with the namemain-key
using the AWS Management Console > EC2 > Network & Security > Key Pairs. This key name is associated in the Terraform file while initialising the EC2 instance. - SSH to the server
ssh -i "main-key.pem" [email protected]
- Destory the AWS infrastructure with:
terraform destroy