1. Variables
(1) 변수 지정 방법 - 우선순위
- interactive mode
- command line flags
$ terraform apply -var “ami= ____” -var “instancetype=_____”
- Environment Variables
$ export TF_VAR_instance_type=”t2.micro”
$ terraform apply
- Variables definition files
variables.tfvars ⇒ it will automatically loaded by Terraform
ami = “____”
instance_type=”____”
But it the name of the file name is diff (not variables.tfvars but like variable.tfvars)
$ terraform apply -var-file variable.tfvars
- variables.tfvars
- variables.auto.tfvars
(2) Using Variables
a. 다양한 arguments
b. type
- string, number, bool, any(default value)
- list, map, object, set → 중복 없는지 꼭 확인, tuple (안의 요소들의 타입이 달라도 됨)
(3) Output Variables
→ quickly display details about the provision resources
→ feed the output variables to another IaC tools (ansible etc)
output pet0name {
value = random_pet.mypet
description = “blablabla”
}
$ terraform output
$ terraform output pet-name
- running ‘terraform output’ will render the output variables defined
- running terraform plan will not render outputs
- running the terraform apply will render the output variables defined
[MCQ]
The label after the variable keyword should be unique among all variables.
should be unique among the variables in the same module
- cannot use providers as a variable name
variable "providers" {
type= string
}
2. Resource Attributes
(1) Resource Attributes and Dependencies
(2) Resource Targeting ???
Which option best describes the meaning of interpolation syntax?
A way to reference variables, attributes of resources and call functions
Which among the following best explains the need of the dependency concept in terraform?
allows resources to be created and destroyed in the correct order
3. Data Sources
→ 이미 다른 플랫폼에 만들어져 있는 resource들을 읽어들일 수 있음
[MCQ]
The behavior of __ data sources is the same as all other data sources, but their result data exists only temporarily during a Terraform operation, and is re-calculated each time a new plan is created.
→ local only
'[Terraform]' 카테고리의 다른 글
6. Terraform (0) | 2024.04.19 |
---|---|
5. Terraform CLI (0) | 2024.04.19 |
4. Terraform state (0) | 2024.04.19 |
2. Terraform Providers Basics (0) | 2024.04.19 |
1. Understanding IaC (0) | 2024.04.19 |