<aside> <img src="/icons/compose_gray.svg" alt="/icons/compose_gray.svg" width="40px" /> 기본 문법
variable "example" {
default = "hello"
}
resource "aws_instance" "example" {
instance_type = "t2.micro"
ami = "ami-abc123"
}
.tf
<resource type>.<name>
data.<data type>.<name>
var.<name>
local.<name>
module.<module name>.<output>
terraform.workspace
path.module
, path.root
, path.cwd
<aside> 📚 arguments(=attribute)
식별자(argument name) = 값(argument value)
image_id = "abc123"
</aside>
<aside> <img src="/icons/archive_gray.svg" alt="/icons/archive_gray.svg" width="40px" /> blocks
컨텐츠의 묶음
resource "aws_instance" "example" {
ami = "abc123"
network_interface {
# ...
}
}
<aside> <img src="/icons/rename_gray.svg" alt="/icons/rename_gray.svg" width="40px" /> 최상위 Block type
resource, input, output, data, module
<block type> "<block label>" "<block label>" {
<argument name> = "<argument value>"
<nested block type> {
}
}
<block type> "<block label>" "<block label>" {
# Block body
<identifier> = <expression> # Argument
}
<aside> <img src="/icons/brain_gray.svg" alt="/icons/brain_gray.svg" width="40px" /> Resource
가상의 네트워크나 인스턴스같은 객체를 표현
resource type은 provider에 따라 다름
</aside>
<aside> <img src="/icons/chart_gray.svg" alt="/icons/chart_gray.svg" width="40px" /> Data
data "aws_ami" "example" {
most_recent = true
owners = ["self"]
tags = {
Name = "app-server"
Tested = "true"
}
}
</aside>
</aside>
</aside>
</aside>
<aside> <img src="/icons/compose_gray.svg" alt="/icons/compose_gray.svg" width="40px" /> JSON 문법
{
"variable": {
"example": {
"default": "hello"
}
}
}
{
"resource": {
"aws_instance": {
"example": {
"instance_type": "t2.micro",
"ami": "ami-abc123"
}
}
}
}
.tf.json
</aside>