Slide 14
Slide 14 text
© LayerX Inc.
plan実行時に差分を減らす工夫
14
例: data sourceが参照しているリソースを変更した場合
resource "aws_s3_bucket" "csv_files" {
bucket = "csv-files"
tags = {
foo = “bar” # -> “baz” に変更すると...
}
}
data “aws_iam_policy_document” “csv_reader” {
statement {
effect = “Allow”
actions = [“s3:GetObject”]
resources = [“${aws_s3_bucket.csv_files.arn}/*”]
}
}
resource “aws_iam_policy” “csv_reader” {
name = “csv-reader”
policy = data.aws_iam_policy_document.csv_reader.json
}
# aws_s3_bucket.sample will be updated in-place
~ resource "aws_s3_bucket" "csv_files" {
~ tags = {
~ "foo" = "bar" -> "baz"
}
# (config refers to values not yet known)
<= data "aws_iam_policy_document" "csv_reader" {
~ id = "232721XXXX" -> (known after apply)
~ json = jsonencode(
{
- Statement = [
- {
- Action = "s3:GetObject"
- Effect = "Allow"
- Resource = "arn:aws:s3:::csv-files/*"
- Sid = ""
},
]
- Version = "2012-10-17"
}
) -> (known after apply)
- version = "2012-10-17" -> null
}
# aws_iam_policy.sample will be updated in-place
~ resource "aws_iam_policy" "csv_reader" {
id = "arn:aws:iam::XXX:policy/csv-reader"
name = "csv-reader"
~ policy = jsonencode(
{
- Statement = [
- {
- Action = "s3:GetObject"
- Effect = "Allow"
- Resource = "arn:aws:s3:::csv-files/*"
- Sid = ""
},
]
- Version = "2012-10-17"
}
) -> (known after apply)
}
Plan: 0 to add, 2 to change
, 0 to destroy.