-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
59 lines (49 loc) · 1.08 KB
/
main.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
# count without variable
resource "aws_s3_bucket" "count111" {
count = 4
bucket = "s3-bucket-shreyaa-${count.index}"
tags = {
Name = "Shreya"
Environment = "Development"
}
}
#count with variable
resource "aws_s3_bucket" "count2222" {
count = length(var.count2-var)
bucket = var.count2-var[count.index]
tags = {
Name = "Shreya"
Environment = "Development"
}
}
# for each loop without variable
resource "aws_s3_bucket" "for-each1" {
for_each = {
"suraj15235" = "ap-south-1"
"karan134532" = "ap-south-1"
"srishti16435" = "ap-south-1"
}
bucket = each.key
tags = {
Name = each.value
Environment = "Development"
}
}
# for each loop with variable
resource "aws_s3_bucket" "for-each2" {
for_each = var.for-each2
bucket = each.key
tags = {
Name = each.value
Environment = "Development"
}
}
# Count using for expression
resource "aws_s3_bucket" "count111" {
for_each = { for idx in range(3): idx => "s3-bucket-shreyaa-${idx}" }
bucket = each.value
tags = {
Name = each.value
Environment = "Development"
}
}