Mostra la pàginaRevisions anteriorsQuè hi enllaçaExporta a PDFTorna dalt Aquesta pàgina és només de lectura. Podeu veure'n el codi font, però no podeu canviar-la. Consulteu el vostre administrador si penseu que això és degut a algun error. = TERRAFORM {{tag> devops info}} * [[tech:terraform:aws]] * [[tech:terraform:azure]] == documentación * [[tech:terraform:cli]] * [[tech:terraform:terraform-state]] * [[tech:terraform:variables]] * [[tech:terraform:data-sources]] * [[tech:terraform:modules]] ===PoC * [[tech:terraform:poc:workspaces]] === related {{topic>terraform +cursos&nodate&nouser&tags&sort}} {{topic>terraform +libros&nodate&nouser&tags&sort}} === enlaces documentación * 0.12: [[https://www.terraform.io/docs/configuration/index.html]] * 0.11: [[https://www.terraform.io/docs/configuration-0-11/interpolation.html: interpolación (referenciar variables, atributos de recursos, llamar funciones)]] == de interés === output * volcar información a fichero:<code properties>resource "local_file" "foo" { content = "${tls_private_key.vm_adwriter.private_key_pem}" filename = "${path.cwd}/vm_adwriter.key" } </code> * desencriptar password windows:<code properties>output "ec2_password" { value = "${rsadecrypt(aws_instance.vm_adwriter.password_data, file("${path.cwd}/vm_adwriter.key"))}" } </code> === mapas * usando **var.aws_region** como índice del mapa para seleccionar la imagen adecuada en función de la región <code properties; terraform.tfvars> aws_region = "eu-west-3" # París </code> <code properties; main.tf> variable "aws_region" { type = "string" } variable "amis-aws-windows2016base" { # Windows_Server-2016-English-Full-Base-2019.02.13 type = "map" default = { us-east-1 = "ami-0bf148826ef491d16" # Virigina eu-west-3 = "ami-0e3f0a08a6950f3e2" # París } } </code> <code properties> resource "aws_instance" "bastion_ad" { ami = "${lookup(var.amis-aws-windows2016base, var.aws_region)}" instance_type = "t2.micro" ... } </code> === dynamic <code properties> variable "virtual_network_rule_ids" { type = list(map(string)) default = [ { id = "x.x.x.x" },{ id = "y.y.y.y" } ] } } resource "..." { dynamic "virtual_network_rule" { for_each = var.virtual_network_rule_ids content { id = virtual_network_rule.value["id"] # etiqueta dynamic + value + key } } } </code> === casos de uso * [[tech:terraform:casos-uso]] == ejemplos * [[tech:terraform:poc-ad]] * [[tech:terraform:win-instance]] tech/terraform/start.txt Darrera modificació: 15/05/2020 03:19per mate