Today, I share a way to launch an AWS instance using Terraform, which has following features:
- Use EC2 Spot fleet instance which is cheaper than the on-demand instance.
- Use AWS Session Manager to connect to the instance, so that you don't need to prepare the SSH setting. Also you don't need any bastion host to connect the instance.
Example
You can download the Terraform code on my Github repository.
Terraform example
I made these code with Terraform version v0.12.25.
Download the repository and type following command.
$ cd terraform-examples/spot-ssm-example
$ terraform init
$ terraform plan -var-file=aws.tfvars
$ terraform apply -var-file=aws.tfvars
After that you can connect the instance via Session Manager console in AWS console.You find the way on following short video and AWS document.
Top comments (0)