Will create multiple set of scripts for clarity. Version details:
- OS: Win10 Home
- Terraform: v0.12.18
- Packer: 1.5.1
- AWS: aws-cli/1.16.303 Python/3.6.0 Windows/10 botocore/1.13.39
For details check my blog: http://sv-technical.blogspot.com/2019/12/terraform.html
This folder contains terraform sample scripts that
- creates roles, users (not using for security reasons)
- creates instance using ssh
- creates groups
- ami
- ec2 etc
Commands:
terraform plan -no-color -refresh=true -out=infra.tfplan
terraform apply -refresh=true -auto-approve "infra.tfplan"
terraform destroy -auto-approve
This folder contains terraform sample scripts that
- terraform files arranged as modules
- outputs.tf is at root only as terraform 0.12+ does not support modules outputs
- packer scripts that creates ami after some script changes you want
- ec2 creates based on newly created by packer ami
- make ec2 public and connect with public subnet so able to ssh without any inbound rule modification
- build-infra.bat that has packer and terraform commands to build complete infrastructure
Commands:
packer validate FILENAME
packer build FILENAME
This folder contains terraform sample scripts that
- creates asg, elb, user-data, custom ssl
- EC2 attaches to ELB and ELB in-turns attaches to ASG
- User can access EC2 website via ELB on port 80 (http), port 443 (https), port 8000 (http).
- SSL is custom generated so you will experience ssl warning on port 443
- creates launch configuration
This folder contains terraform sample scripts that
- encrypt ami
- create kms key
- use default i.e. aws or custom managed kms key
- create and use custom managed kms key
This folder contains terraform sample scripts that
- has proper steps for SSL
- create separate modules for admin tasks, iam and infra etc
- infra module managed so it can be called multiple times with param
This folder contains terraform (packer) sample scripts that
- ami is changed to have custom httpd conf
- configuration to disable logging for
- (internal dummy connection)
- "ELB-HealthChecker/1.0"
- 408 (in-progress)
This folder contains terraform sample scripts that
- has configuration to log rotate httpd logs
- compress logs datewise and restart httpd after that
- create S3 bucket
- configure EC2 to connect with S3
- move logs to S3 bucket
- packer module updated to have httpd logrotate conf
- scripts for logrotate and S£
- user data to configure aws
- Note: Four properties added to logrotate
- rotate 5 -> So files after logrotate do not delete
- maxage 5 -> To keep rotate files for how many dates
- dateext -> To attach date to gzip files
- dateformat -%Y%m%d-%s -> format of date