Skip to content

lantrix/terraform-ec2-ssm

Repository files navigation

terraform-ec2-ssm

Sets up an EC2 workstation with CentOS 7 (x86_64) in ap-southeast-2

Setup

Remote State

Ensure using S3 remote state

export accountId=$(aws sts get-caller-identity --query Account --output text)
terraform init \
    -backend-config="region=ap-southeast-2" \
    -backend-config="bucket=terraform-state-${accountId}" \
    -backend-config="key=terraform.tfstate" \
    -backend-config="dynamodb_table=terraform-state"

Local State

If you don't want to sync your state remotely just:

terraform init

Deploy

terraform plan
terraform apply

It will run and spit out the EC2 instance ID

terraform-apply.png

Connect to EC2 with SSM Session Manager

Install Session Manager plugin for AWS CLI first.

Start the session using the output instance_id

aws ssm start-session \
    --document-name ec2-workstation \
    --target i-053cc3cc379ef0069

About

A workstation on AWS EC2 accessable using SSM - created with Terraform

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published