Do you want BuboFlash to help you learning these things? Or do you want to add or correct something? Click here to log in or create user.



Question

In terraform, say you have a declared (and assigned values via the default argument) a variabled called "amis", as
follows:

variable "amis" {
  default = {
    "us-east-1" = "ami-b374d5a5"
    "us-west-2" = "ami-4b32be2b"
  }
}

And you have declared region variable as follows:

variable "region" {}

Complete the configure code block below to assign the right AMI to your EC2 resource, based on the "region" input variable give at "terraform apply" runtime:

resource "aws_instance" "example" {
ami = [...]
instance_type = "t2.micro"
}

Answer

"${lookup(var.amis, var.region)}"

^^ note use of built-in lookup function that takes a map argument and a key argument and returns the value for the key
^^^ note the outer double-quote enclosing to denote a returned string value
^^^^ note the inner ${} enclosing to denote that the value is derived/computed


Question

In terraform, say you have a declared (and assigned values via the default argument) a variabled called "amis", as
follows:

variable "amis" {
  default = {
    "us-east-1" = "ami-b374d5a5"
    "us-west-2" = "ami-4b32be2b"
  }
}

And you have declared region variable as follows:

variable "region" {}

Complete the configure code block below to assign the right AMI to your EC2 resource, based on the "region" input variable give at "terraform apply" runtime:

resource "aws_instance" "example" {
ami = [...]
instance_type = "t2.micro"
}

Answer
?

Question

In terraform, say you have a declared (and assigned values via the default argument) a variabled called "amis", as
follows:

variable "amis" {
  default = {
    "us-east-1" = "ami-b374d5a5"
    "us-west-2" = "ami-4b32be2b"
  }
}

And you have declared region variable as follows:

variable "region" {}

Complete the configure code block below to assign the right AMI to your EC2 resource, based on the "region" input variable give at "terraform apply" runtime:

resource "aws_instance" "example" {
ami = [...]
instance_type = "t2.micro"
}

Answer

"${lookup(var.amis, var.region)}"

^^ note use of built-in lookup function that takes a map argument and a key argument and returns the value for the key
^^^ note the outer double-quote enclosing to denote a returned string value
^^^^ note the inner ${} enclosing to denote that the value is derived/computed


Summary

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

Details

No repetitions


Discussion

Do you want to join discussion? Click here to log in or create user.