AWS Meetup Terraform & Terragrunt. Anton Babenko (2020)



Terraform adalah alat Hashicorp yang populer untuk mengelola infrastruktur cloud Anda dalam paradigma Infrastruktur sebagai Kode .



Terragrunt adalah pembungkus Terraform yang menyediakan alat tambahan untuk menyimpan konfigurasi Terraform Anda, bekerja dengan beberapa modul Terraform, dan mengelola status jarak jauh.



Video:







Tautan:





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 .



Dan saya ingin menunjukkan lebih banyak bahwa ada cara seperti itu. Ada satu cara, ada cara kedua. Dan Anda tahu keuntungan dari cara satu dan kedua. Dan kemudian Anda dapat menemukan cara ketiga, yang berada di tengah-tengah. Dalam proyek langsung, saya belum pernah bertemu sepenuhnya dengan all-in-one. Jika Anda memisahkan semuanya ke titik fanatisme, ternyata tidak praktis. Dan ternyata banyak sekali kode yang bisa dikelompokkan.




All Articles