Parece que os desenvolvedores do Terraform oferecem práticas recomendadas bastante convenientes para trabalhar com a infraestrutura da AWS. Só existe uma nuance. Com o tempo, o número de ambientes aumenta, cada um possui recursos. Quase uma cópia da pilha de aplicativos na região vizinha aparece. E o código do Terraform precisa ser copiado e editado com cuidado de acordo com os novos requisitos, ou para fazer um floco de neve.
Terraform .
:
40, 20 IT. 12 Ixtens. ecommerce-driven-development. 5 DevOps-.
, , .
, . , , Amazon.
4 . , . , , . , - .
, , . , 4 .
.
, , time to market. , DevOps- . Terraform Puppet.
Terraform – open source HashiCorp. , , , .
– , - , , .
, . , .
Amazon. Terraform plan. Terraform plan : «, ». , , . .
, , Terraform apply Terraform instance, .
. - . instances, 53 .
. plan. , . . .
Terraform state-. . . , Amazon, , , , , Amazon. - , Terraform , Amazon.
state- . Git, . - , .
, . . Terraform bucket, state-. Terraform , state-, .
. . , .
Terraform , . . - .
, , Terraform apply . .
production - , instances, production instances .
. , . - , : , maintenance , , . , , .
, HashiCorp, - , .
production .
, - . , , , instance, , . . , .
Terraform . , IP-, , instance, IP- route53 .
, . , , 8 – .
. Jenkins job . pull request , , , , . performance , instances . , - , . . .
Jenkins shell-, Terraform. , . Terraform apply .
, .
- , , production, , , .
, , production. , production . , production operation . , , production, .
, , - . , , .
, Terraform – . . - , . .
- , pull request, , . , . , , -, . , Terraform-. , Terraform breaking chain , . . . pull request, , Terraform.
, , Terraform-, , - .
, operation, , pull request, . , . DevOps, , , . - .
, . , . : « , ».
, , - Terraform. , , , , Terraform-, , , .
, , Symlinks. Terraform . , , , . . , Symlinks .
, production assume role, - Amazon-. , , , , Terraform Amazon- .
Symlinks ? , Terraform state-. - . , Terraform . - , .
, - , . bucket. , sandbox sandbox-, production. , bucket production sandbox. , . - , - .
? , Terraform . Terraform . - . Terraform init, , .
shell-, , -, . Shell- . , -, . , state-, , , .
? JSON-. Terraform hcl (HashiCorp Configuration Language), JSON.
JSON shell-. , - bucket. bucket Terraform-, shell- .
bucket Terraform? remote state-. . . - , , Amazon: «, , instance», .
- . : «Terraform, , , state- ». environments.
state-. , VPC. Terraform-, VPC, VPC, , .
. . , VPC , , instance.
state- . , , , .
. Terraform ? , , 4 .
HashiCorp , Terraform-. Terraform fmt , . , , , HashiCorp, . .
– Terraform validate. , – , . ? . . Terraform validate.
, , , .
– , .
, Terraform, HashiCorp : « ? , – ?». .
Terraform , , Terraform : «, , , . , Terraform-».
, Terraform-, . , , , - , Terraform : « - , ».
– Terraform plan. , – . . , .
- , , - - - . Terraform plan , .
. , , Python, . , : Terraform- - , .
Terraform plan . , , .
, , , , – . pull request : «, ». . attach , .
– . , Terraform Amazon : « instance ? autoscale ?». , , refresh=false. , Terraform S3 state. , state , Amazon.
Terraform plan , state , . . -, - Terraform refresh. Terraform refresh , state , .
. . , Terraform, Terraform , . . . , , . pull request - , , . , Terraform plan.
, , user-data.
user-data? Amazon, instance, instance – -. instance , cloud init instances. Cloud init : «, – load balancer». - .
, , Terraform plan Terraform apply, user-data , . . . . , , - .
, Amazon, - .
, , template. : «, template». , Amazon.
– user-data. . . . , - user-data, : «, - – ».
, , Automate Terraform apply.
, Terraform apply , , , .
– . . . job, , , . , « » — , , , , - . , : «, , , ».
production, sandbox , , , , - . : autoscale-, security-, roles, route53 . , , .
, , , - persistent, , , - . jobs, .
Amazon Terminate protection. . . . Terraform Amazon : « instance, ». Amazon : «Sorry, . Terminate protection».
– . Terraform-, . , , - . , , , , .
. review. , - review , . , .
, . . . - , , - environment.
, , , . . , .
, Terraform, locals. output’ - , . .
, . . , ( ), , . : « , ». , , , , - , . , . , . : «, !». : «, . , ».
, , , , . , . . , , , , , .
:
- . , , - .
- . . . - , . , - - , Elasticsearch, Terraform plan, , . , .
- . , , . .
- production- . , - production - , . - .
- Terraform- , refactoring .
- Immutable infrastructure. AMI .
- route53, , .
- API rate limits. Amazon : «-, , , ». , .
- Spot instances. Amazon – spots . .
- IAM roles.
- , Amazone instances , . instances 100-150 – 1 000 . – .
- instances.
. Terraform – , . !
! state- S3, , state- ?
-, . -, flags, , - . . . , , , - - . – , state- Git . , - state-, , . . , Terraform . - , locks, , .
enterprise?
enterprise, . . , .
. . Amazon, instance . Terraform, Life Second , .
. .
. -, . - ? Test Kitchen. , - . Local Values. Input Variables? - Local Values? , - .
. – . , . , , -, , , , . , . . - , , - .
Local Values .
! ! . , . ?
, ! , , , , , . , , , , . , , , . , , . , . .
jsonnet -?
.
, . , .
– , , . . . , . . , , . .
. !
, . , Terraform . Ansible?
. Ansible , Puppet Amazon. Terraform .
Amazon?
, Amazon. Amazon. , Terraform . Ansible, : « 5 instances», , : « 3». Terraform : «, 2 », Ansible : «, 3». 8.
! ! Terraform. , Terraform - , Terraform .
. . . , , . ., .
. Remote backend, S 3. ?
?
Terraform Cloud .
?
4 .
4 , , , .
locks, state -. . .
, . .
, branch? ?
, . Terraform, Puppet, , - , . , , . branches, . , , -. , .
. . ?
.
branch . . . , , – , , . , , . . . .
! ! ! . , . , , ? - , ?
. , , - - . - .
. . ?
. . . , .
! ! . , . Puppet ?
User-data.
. . - ?
User-data – , . . , Daemon , , , load balancer.
. . - , ?
. .
! User — data. , , - - . - user — data Git, , User-data?
User-data template. . . - . Terraform . template , , , , , . – –-, -, , . , , - , . autoscale- , - instances autoscale- . , - . .
, – ?
, , . . . output’ . , , - – , User-data .
. , , Terraform .
.
, , , . . , tfvars, . . , tfvars ?
. . (: Production/environment/settings.tf) : domain = , domain vpcnetwork, vpcnetwork stvars – ?
. setting source, .
, tfvars. Tfvars testing-. tfvars instances, . . , . , , . , , tfvars.
, ?
, tfvars – . . tfvars . – . .
! , , Terraform ’? , - . ssh -. Google -, . Terraform , . , , , .
, – , , . . Terraform . . .
. . , , ?
, .
! . Mail. ru Group. …, ? , User — data, host name, Puppet ? . SG, . . SG, instances, ?
instances, , . , , , autoscale-. , .
, , . - , . , , , . , , , - .
?
SG instances, - ?
, . instance , , . , , , IP- . . -, Consul Discovery, , Kubernetes. Consul IP- instance.
. . IP, host name ?
host name, . . . instance – AE . . - , .
! , Terraform – , .
.
. , , Bare Metal instances? ? - , , Ansible, ?
Ansible . . . Ansible , instance . Terraform , instance . Bare Metal – .
, : «».
– , . Terraform-, - .
, – , . . , - : «, N , Amazon».
Terraform Front-End jobs, PagerDuty, data doc . . . .
! 4 Terraform. Terraform, , , , - - , plan. - . ? , ?
Principalmente com as mãos e os olhos, se vemos algo estranho no relatório, então analisamos o que está acontecendo ali, ou simplesmente matamos. Em geral, as solicitações pull são comuns.
Se houver um erro, você está fazendo rollback? Você já tentou isso?
Não, é uma decisão de uma pessoa no momento em que ela vê um problema.