- Open the aws-provider.tf file and enter the access_key and secret_key of your AWS account.
- Enter the ssh key name used by AWS in key_name of the instance.tf file.
- Prepare terraform with the init command
terraform init
- Create AWS infrastructure and instances written in code with the apply command
terraform apply
-
When you run the command, the AWS structure and instance as shown in the figure below are created.
-
ssh connection to bastion server command
ssh -i ssh_key.pem ubuntu@public_ip
- ssh connection to privates subnet instance command through bastion server
ssh -i ssh_key.pem ec2-user@private_ip
- You can delete AWS resources created with terraform at once
terraform destroy