Local Values Flashcards

1
Q

Is it a good idea to hard code tags?

A

No its not. It’s always best to centralize common values using variables

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are local values?

A

they are similar to variables in a sense that it allows you to store data centrally and can be referenced in multiple parts of configuration

Ex:
locals {
default = {
Team = “security-team”
}
}

tags = local.default

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Why do we need local values instead of variables?

A

You can add expressions to locals, which allows you to compute values dynamically

Ex: locals {
instance_ids = concat(aws_instance.blue..id, aws_instance.green..id)
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Locals vs Variables

A

Variable values can be defined in wide variety of places like terraform.tfvars, ENV variables, CLI, and so on

Locals are more of a private resource and have to change by directly modifying the code

Locals are often referred as just “locals”.

Locals are created by a locals block (plural) but if you reference the block you type local (singular)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly