Terraform是一种流行的Hashicorp工具,用于将基础架构中的云基础架构作为代码范例进行管理。
Terragrunt是Terraform的包装,它提供了其他工具来存储Terraform配置,使用多个Terraform模块以及管理远程状态。
视频:
链接:
- terraform-community-modules + terraform-aws-modules
- antonbabenko/pre-commit-terraform —
- antonbabenko/modules.tf-lambda — Terraform-
- antonbabenko/terragrunt-reference-architecture — Terragrunt reference architecture
- www.terraform-best-practices.com
- https://www.antonbabenko.com
- @antonbabenko — Twitter, Github Slacks
- YouTube, Terraform
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 :
- Terraform.io – , , .
- Learn.hashicorp.com – .
- Terraform-best-practices.com – , 100-500 Terraform, , , - , best practices. Google «Terraform best practices» .
, : « ?». – 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 .
我想向更多人展示这种方法。有一种方法,有第二种方法。而且您知道第二种方法的优势。然后,您可以提出第三种方法,该方法位于中间位置。在现场项目中,我还没有完全完全合而为一。如果将所有事情都分开进行狂热主义,那将是不切实际的。事实证明,可以将许多代码分组。