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"
}
"${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
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"
}
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"
}
"${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
status | not learned | measured difficulty | 37% [default] | last interval [days] | |||
---|---|---|---|---|---|---|---|
repetition number in this series | 0 | memorised on | scheduled repetition | ||||
scheduled repetition interval | last repetition or drill |