Skip to content

FallPrediction/terraform-aws-example

Repository files navigation

使用Terraform建立VPC與EC2 instance

架構圖

image

使用

複製secret.tfvars.example為secret.tfvars,然後填上SSH public key

建立infrastructure

terraform apply -var-file="secret.tfvars"

測試

  1. 從本地連到app_server
ssh -i ~/.ssh/terraform ubuntu@{app-server IPv4}
  1. 從app_server連接到db_server
telnet {test-server IP} 22
  1. 修改ssh config,然後用nat instance當作堡壘機,從本地連到db_server
Host nat-instance
Hostname {nat的IP}
User ec2-user
Port 22
identityfile {path to private key}

Host test-server
Hostname {test-server的IP}
User ubuntu
Port 22
ProxyCommand ssh -q -W %h:%p nat-instance
identityfile {path to private key}

SSH進入test server

ssh test-server
  1. test server能否連至外網
curl https://www.google.com
  1. 檢查S3 bucket的terraform.tfstate

銷毀資源

terraform destroy -var-file="secret.tfvars" 

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published