IaaS Terraform deploy
Instead of creating resources on AWS manually or through AWS CLI it was decided to use Terraform. It helps to define every resource via code, and made changes easily trackable through git history, allow not to think which resources you need to create on new ENV. You just need to run a batch of commands and that's it.
General info:
- Infrastructure configuration contained in
infrastructure/terrafromfolder - Resources split on modules, each module contain next files
main.tf- main description of the moduleoutput.tf- information about created resources, that can be used in other modules (created ARN of resource, name, id ...)variables.tf- define variables which are used inmain.tf, they can describe different parameters such as: names, stage,
- Root folder contains next files:
XXX.tfvars- env files, with sensitive information for creating resources (currently there is specified vpc info (it's better to create VPC in file, but since it's already created I keep the old one instead of creating new one ) and stage). XXX isprodordevmain.tf- terraform's entry point, describe terraform required version, terraform state and providers. It assembling all created modules and providing them with required variables.variables.tf- required variables to run app (these variables go to main function from XXX.tfvars file)README.md- contain usefull command
First run
- Install terrafrom >v1.3.3
- run
terraform init- install dependencies and get remote state - terraform workspace select
ENV-- switched to required enviromentprodordev - run
terraform plan -var-file=XXX.tfvarsshow resources that will created - run
terraform apply -var-file=XXX.tfvarsdeploy resources
**If you have 403 Forbidden error -> use VPN, because Terraform doesn't work in some countries (Belarus, Russia etc)