This terraform script will setup an infrastructure for management in AWS and will create following resources:
- Manager Node (CentOS)
- VPC
- Management subnet
- Internet gateway
- An IAM role attached to the Manager node which has the following access.
- ec2
- elasticloadbalancing
- cloudwatch
- autoscaling
- lambda
- logs
- s3
- elasticache
- ecr
- route53
- route53domains
- apigateway
- es
- iam
- events
-
An IAM account with the following access:
- AmazonEC2FullAccess
- IAMFullAccess
- AmazonVPCFullAccess
-
Install terraform on your machine.
-
Public Key Access with Agent support/ Agent Forwarding:
ssh-add <key_pair_name>.pem
- Clone this repo.
cp terraform.dummy terraform.tfvars
- Modify params in
terraform.tfvars
- Modify params in
variable.tf
to change subnet or add AMI accordingly to your aws region - Export AWS credentials as bash variables (e.g.
ap-northeast-1
for Tokyo andap-southeast-1
for Singapore region):
export AWS_ACCESS_KEY_ID="anaccesskey"
export AWS_SECRET_ACCESS_KEY="asecretkey"
export TF_VAR_AWS_DEFAULT_REGION="ap-northeast-1"
- Run
terraform plan
to see the plan to execute. - Run
terraform apply
to run the scripts. - You may have
prod/dev/stage
configurations interraform.tfvars.{prod/dev/stage}
files (already ignored by.gitignore
).
ssh -A centos@<manager_public_ip>
Generate terraform documentation by running bash generate-docs.sh
- SSH into the manager node and check whether
terraform.out
inhome/centos
contains: a record of the VPC, Subnet, Security Group and Nat gateway ID. - More details on terraform-docs.