public ip -> ssh 22 -> jump host -> application host
git clone https://github.com/zetan503/terraform-mysite.git cd terraform-mysite
~/.aws/config
[profile mysite]
region = us-east-1
Export your AWS access key into the environment
export AWS_ACCESS_KEY=XXXXXXXXXXXX
export AWS_SECRET_ACCESS_KEY=YYYYYYYYYYYY
aws sts get-caller-identity --profile mysite
aws s3 list --profile mysite
TODO Make not publicliy available
aws s3api create-bucket --bucket mysite-terraform-state-bucket --profile mysite
Configure backend.tf to use your bucket name.
terraform {
backend "s3" {
bucket = "mysite-terraform-state"
key = "terraform.tfstate"
region = "us-east-1"
}
}
terraform init
terraform plan
terraformm apply
Get the private key from the terraform state
terraform output ssh_private_key_pem > ~/.ssh/aws_private_key.rsa
chmod 0600 ~/.ssh/aws_private_key.rsa
cat ~/.ssh/aws_config
Host jumphost
Hostname 44.234.233.76
User ubuntu
IdentityFile ~/.ssh/aws_private_key.rsa
Host dvr
Hostname 10.0.1.192
User ubuntu
IdentityFile ~/.ssh/aws_private_key.rsa
ProxyJump jumphost
SSH to dvr will proxy the connection through the jump host using the generated key.
ssh dvr