-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.tf
72 lines (57 loc) · 1.3 KB
/
demo.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
## Terraform demo project
##
## Usage:
##
## $ tf init
## $ tf apply
## $ tf destroy
terraform {
required_version = "~> 1.5"
}
variable "n" {
type = number
description = "number of items"
default = 10
}
locals {
items = [for v in range(var.n) : "${v + 1}s"]
}
## tflint-ignore: terraform_required_providers
resource "time_sleep" "this" {
for_each = toset(local.items)
triggers = {
key = each.key
}
create_duration = each.key
destroy_duration = each.key
}
## tflint-ignore: terraform_required_providers
resource "local_file" "this" {
for_each = toset(local.items)
content = "Content ${time_sleep.this[each.key].triggers.key}"
filename = "./demo-${each.key}.txt"
file_permission = "0664"
}
## tflint-ignore: terraform_required_providers,terraform_unused_declarations
data "local_file" "this" {
for_each = toset(local.items)
filename = local_file.this[each.key].filename
}
output "filenames" {
value = [for i in local.items : data.local_file.this[i].filename]
}
import {
to = time_sleep.this["1s"]
id = "1s,1s"
}
# resource "local_file" "notexisting" {
# content = "Content"
# filename = "./demo-delete.txt"
# file_permission = "0664"
# }
# removed {
# from = local_file.notexisting
# lifecycle {
# destroy = true
# }
# }