jeudi 21 septembre 2023

Terraform: Help understanding reading a value from random provide with a r keepers resource

The Terraform docs for random have this example:

resource "random_id" "server" {
  keepers = {
    # Generate a new id each time we switch to a new AMI id
    ami_id = var.ami_id
  }

  byte_length = 8
}

resource "aws_instance" "server" {
  tags = {
    Name = "web-server ${random_id.server.hex}"
  }

  # Read the AMI id "through" the random_id resource to ensure that
  # both will change together.
  ami = random_id.server.keepers.ami_id

  # ... (other aws_instance arguments) ...
}

What is the different in behavior between reading random_id.server.hex and random_id.server.keepers.ami_id?

What does the comment mean by reading a value "through" the random_id resource? Is ami = random_id.server.keepers.ami_id different to ami = var.ami?




Aucun commentaire:

Enregistrer un commentaire