AWS Meetup Terraform & Terragrunt. Anton Babenko (2020)



Terraform ist ein beliebtes Hashicorp-Tool zum Verwalten Ihrer Cloud-Infrastruktur in der Infrastruktur als Code- Paradigma .



Terragrunt ist ein Wrapper für Terraform, der zusätzliche Tools zum Speichern Ihrer Terraform-Konfigurationen, zum Arbeiten mit mehreren Terraform-Modulen und zum Verwalten des Remote-Status bietet.



Video:







Links:





AWS Community Hero. – Terraform-, Terraform. , HashiCorp-.



open source . , Terraform-, community-modules, aws-modules. , - - .



, , , Pre-commit-terraform. , . .



. , , Delivery Excellence. Terraform Terraform.



, GitHub , Linkedin . , open source, open source.





  • All-things Terraform + AWS + DevOps.



  • Consulting.



  • Workshops.



  • Trainings.



  • Mentorship.





Open source – . open source. , : « ? ?». .



- , Terraform, Terraform Terraform workspace, : « workshops , ?». workshops.



- , . ., , - , , - , , pull request, , -. , -.



email: anton [] antonbabanko.com. , , , . . , , .



Betajob.com. .





https://github.com/terraform-aws-modules



https://registry.terraform.io/modules/terraform-aws-modules



Terraform AWS – , 2017- , - , . , VPC Amazon. , - . , , - , , . . .



, . .



, . . .





https://github.com/sponsors/antonbabenko



7 000 000 , 1 000 pull requests issues . 6 , GitHub. -, , . , .





, , Cloudcraft. , , . . , . , , .





Cloudcraft , , AWS-.





https://dzone.com/articles/infrastructure-as-code-the-benefits



, , , , , , . . . , . . , . , Powerpoint. , clickops, – , , . , , .



, – , , , . , . . . cndb, Systems Manager Amazon. .





?



Terraform 0.12 Terraform 0.11.





, Terraform . , . Terraform . , Terraform .



Amazon 2011- : « CloudFormation». , . Spectrum, Fogs . ., JSON, YAML . ., . . - . DSL . . GitHub , , orchestration-cloudformation. . Spectrum – , -.



, Google , , , , Python, Jinja Tempating, . Google.



Azure , , , JSON. , , . , . Azure ARM Terraform . , - , Terraform – , JSON, .



Chef, Ansible, Puppet, . , , . .



: - , public cloud Amazon, Google, Azure . . configuration management - , , . , : , , .





Terraform 2014- , , , , CloudFormation, CloudFormation , , . .





Terraform, , 250 , . . HashiCorp Configuration Language, , .



Terraform , , . Terraform , - . Terraform, . Terraform . CloudFormation . , CloudFormation , 2013-2014- , .



Terraform mainframes, workers . . , , 2014- . , , API , Terraform . Terraform . use cases.





https://www.terraform.io/docs/providers/index.html



API , . . email Google permeation Dropbox, . , , Terraform . use cases.



use cases, . , Minecraft . , -. . , . , Terraform? , . hsale, , . , . Terraform , , , . , .



, - . , . - , , . . Terraform. Terraform , API .



, , . , , - , email, GitHub-, Jira. pull requests Terraform. .





Terraform, 3 :





, : « ?». – best practices . , best practices – , terraform-best-practices. . . . , . , , Terraform . , , , , . , , - .



, , . : « », . ., , - , , email pull request , . , , . - .



. , , Terraform – , . , , , . Terraform , , work space .





?





Terraform 0.11 , . . . s3_bucket.





Terraform 0.12 . , . . , .





https://www.hashicorp.com/blog/announcing-terraform-0-1-2-beta



. ; , , .



Terraform 0.11, , , , , try, false . , . Correct conditional operators , , , , . Terraform AWS . .



? ? 100 -500 , . Terraform plan, Terraform apply environment, . , . test cases : . . . . , Terraform . . . , Terraform - , , review, .



. . , Terraform, . . HashiCorp . , Terraform 0.12 , .



. , HashiCorp – , , . . open source.





https://www.terraform.io/upgrade-guides/0-12.html



, 0.11 0.12 .



-, upgrade guide, , , , . . , 90 % , .



, Terraform 0.12, 0.11 , Terraform state , 0.12. , -, , , state , , .



, . - 0.12, - , , .





https://github.com/tfutils/tfenv



, tfenv. .





https://www.terraform.io/docs/configuration/terraform.html



, , . , . ? -. , AWS. , . . Terraform-, . . .





, : «, , ?», Terraform state , . .





, Terraform , .





, , Terraform , Terraform . , .





, all-in-one, tf Terraform-. , , outputs. , refresh , plan . .





– , 1-in-1. . - , - , . , .





. : all-in-one 1-in-1? , , , all-in-one – , 1-in-1 – .





MFA (Most Frequent Answer) – .





, - , . Google : «Google, - , », terraform.io, - – all-in-one. , . Terraform plan 20 . all-in-one.



, , all-in-one , . , , . , environment. . . - .



1-in-1 , . , Registry terraform.io, VPC-. , , , . . - , . 1-in-1.



, , - Terraform-, - , , .



, , Terragrunt, 1-in-1 .





?





, all-in-one. Terraform plan. 15 . . , - . Terraform apply, 15 , «Yes», .



, , main targets. terraform apply -targets = module.vpc. VPC. , shell-, makefile, PowerShell - Terraform, , war- , . .



1-in-1, mikefile . Terraform apply , Terraform apply . . . . , make terraform apply - . .



? , state input . , , shell-, , . , , Terraform apply, data-source , Terraform remote state . . shell-, makefiles.





? ? . . Terraform Terraform.





, . . ? Terraform . . . , «Terraform apply». -, . , .



, Terraform , , . .





, Terragrunt. .





https://github.com/gruntwork-io/terragrunt



https://github.com/antonbabenko/terragrunt-reference-architecture



– Terraform Terraform-.



, Terragrunt, Terraform-. , , Terraform-. Terragrunt Terraform-.



, . Terragrunt .



, , «star» GitHub, 3 000 . , . .



, , , . .



, , . Terragrunt-reference-architecture , . , . , , . , , .





Terragrunt. .hcl. , - Terraform , .



3 , . inputs 14- , . , , Terragrunt.



: registry, . , 3. , . 14. terragrunt apply .



Terraform, , . , AutoScaling 200-300 , .



, , Terraform, AWS SDK, , .



, Amazon, DevOps, , Terraform-. , , : .



: Terragrunt , , , .





Terragrunt. , hooks . . , hooks , . - hooks .





. 10 , , autoscaling group, VPC. VPC? 11 , VPC. autoscaling group, public subnet . 20 dependency.vpc.outputs.public_subnets.



, - : « , data-source data-source’ - state ?». , terraform output. Terragrunt? , (.vpc) terraform outputs.public_subnets. subnets dependency.vpc. vpc_zone_identifier. data-source . .



. 1-in-1, , , , terragrunt apply, , - , «Yes» . . terragrunt apply all, , , . : « ?». «». , .



Terragrunt pre-commit. pre-commit hooks Terragrunt , .



-, . , . -, . , . -, .





, Terragrunt, , Terraform Cloud. ? Terragrunt , , .



Terraform Cloud, Terragrunt . Terraform Cloud . , , 0 70 . -, .



, , Terraform Cloud – , , open source. , enterprise. , open source , shell-. - workspaces. - open source enterprise, .





workspaces?





, Terraform, Terraform apply. , . , - . «Terraform workspaces new» workspace. «Terraform plan». Terraform plan : « ». . . , workspace, , - workspace. workspace , . 100 .





– , workspaces . shell-, bucket , .



– workspaces, . , Terraform.workspaces = prod, 5, 25. , . , 5 environment , , lookup . lookup , Terraform workspaces. , .



: « workspaces ? production QA environment?». : « , slack». . - : « staging production environment ?». .



, , , Terraform . Terraform.tfvars, , . , instances. .



workspaces, . S3_bucket, state .



, . . : « , , workspaces name». .



workspaces , workspaces – . . workspaces workspaces shell-, AWS-, , , .



use cases, workspaces . , . , , , .



use cases , , pull request. . . pull request, - workspaces, , -, GitHub. - , , . , workspaces. , , . - . , production environment workspaces.



use cases . , . inmem. workspaces. . . workspaces , - - . , , Terraform state, Terraform backend configuration type inmem ( ). , .





workspaces , , , . , , , workspaces. , workspaces, - . , Feature 1. , terraform apply. , . , terraform destroy.



, , , , .



Terraform workspaces . . , 20 , 10 . workspaces, . .





, , . , Terraform. , , .





Terraform developers . , , DevOps-.



DevOps- Terraform 0.12, . . , , , . ? , , .



DevOps- Terraform developers reference architectures, . , ICS-, 100 , Amazon load balancer, . . . cloud- DevOps- , 100 , , . , , , , , . Terraform-, frontend-, , Terraform. : « , - ». , .





Terraform , frontend developer, 0.12 5 , . , , . . Terraform 0.12 – Terraform developer, .



, full stack developer Terraform. - , , frontend application. , . .





, , . - , , , frontend developer, backend developer, machine learning . . DevOps- , , . .





Modules.tf. ? .





- 2 , , .



. , - - , , .





https://github.com/antonbabenko/modules.tf-lambda



https://github.com/antonbabenko/modules.tf-demo



. , , , , , - .



– modules.tf.demo.





, Terraform AWS . Terragrunt’ .





, , . open source .





https://asciinema.org/a/32rkyxIBJ2K4taqZLSlKYNDDI



asciinema.org , .





, , , . Terraform best practices , , Terragrunt.



, , Terraform , . Terragrunt - - .



, , . , , , , open source, , pull requests, issues . .





, , , . , . , . , Amazon. Amazon, . - . , . . 10 , , . . , - close course .



Terraform – . , Terraform-, . . 99 % Terraform , . . , . .





https://github.com/sponsors/antonbabenko



. . . , Delivery excellence.





! . , Terraform Cloud – , . Terraform backend. tfstate, . , S3, Diff, , CI. Terraform pipeline. all-in-one, 1-in-1. Terraform depends_on, . . . , Terragrunt . ?



, . , Terraform Cloud , . , open source community, , 99 % Terraform Cloud , . , Atlantis, GitHub-actions. - .



Terraform Cloud, . , , . Remote state Terraform S3.



, , . , Terraform Cloud, Atlantis, Terraform pull request. . . pull request, atlantis plan. Terraform , - Jenkins. AWS forget instance. Terraform plan pull request. .



Atlassian Terraform. Terraform Cloud. . .



.



? , ?



. , , MasterCard REST Provider. , swagger . Terraform- swagger . swagger , swagger , . . - , .



. Amazon, , - issue , , . upload , : « ? ?». - , , Brian . , .



, . , . open source?



Cloudcraft?



.



Cloudcraft – open source.



. , , , Terraform, AWS. , - AWS. ?



, , , . , , . . . , ? , EC2 instance, 50 : IP-, subnet . . . . - - . . , open source . drowto.io, open source, Cloudcraft, .



! , , . Terraform-. Terraform Helm Charts?



, .



.



. Terraform- Terraform . , provisioning, , shell- – Terraform. , . Helm Charts . , - . , Helm Terraform, - . , , , . Terraform , . . . Helm, Kubernetes, - , Terraform apply. Terraform apply . .



, . - Helm, . issue «Helm 3 provider Terraform», , - . , -, . .



, Kubernetes- Terraform. , , .



. , - use cases. -, Kubernetes-. , - , . Terraform , , . , Kubernetes, Terraform . .



! . , count output , list map?



. . , - ?



, VPC VPC, - , restrictions security group VPC. list.



, - , , Terraform , , , , . , Terragrunt. . . Terragrunt . . output’ . Terragrant , , . , , .



Terraform, , , Terraform .



, . terraform apply -target , terragrunt apply . , Terragrunt. . . –target , . , , , , , .



, ! all-in-one 1-in-1. , . . AWS. , , AWS, . all-in-one . . Terragrunt, , . ? , – all-in-one 1-in-1.



, MFA somewhere in between. , , . use cases – . , 100-500 AM user’ . - . all-in-one . all-in-one, 1-in-1 .



Und ich wollte mehr zeigen, dass es solche Wege gibt. Es gibt einen Weg, es gibt einen zweiten Weg. Und Sie kennen den Vorteil sowohl des einen als auch des zweiten Weges. Und dann können Sie einen dritten Weg finden, der irgendwo in der Mitte liegt. In Live-Projekten habe ich mich nicht vollständig in einem getroffen. Wenn Sie alles vor dem Fanatismus trennen, stellt sich heraus, dass dies unpraktisch ist. Und es stellt sich heraus, dass viel Code gruppiert werden kann.




All Articles