Skip to content

Latest commit

 

History

History
48 lines (33 loc) · 1.1 KB

README.md

File metadata and controls

48 lines (33 loc) · 1.1 KB

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