@@ -10,26 +10,28 @@ import (
10
10
11
11
func TestAccAWSDataElasticsearchDomain_basic (t * testing.T ) {
12
12
rInt := acctest .RandInt ()
13
+ datasourceName := "data.aws_elasticsearch_domain.test"
14
+ resourceName := "aws_elasticsearch_domain.test"
13
15
14
- resource .Test (t , resource.TestCase {
16
+ resource .ParallelTest (t , resource.TestCase {
15
17
PreCheck : func () { testAccPreCheck (t ) },
16
18
Providers : testAccProviders ,
17
19
Steps : []resource.TestStep {
18
20
{
19
21
Config : testAccAWSElasticsearchDomainConfigWithDataSource (rInt ),
20
22
Check : resource .ComposeAggregateTestCheckFunc (
21
- resource .TestCheckResourceAttr ( "data.aws_elasticsearch_domain.bar" , "elasticsearch_version" , "1.5 " ),
22
- resource .TestCheckResourceAttr ( "data.aws_elasticsearch_domain.bar" , "cluster_config.#" , "1 " ),
23
- resource .TestCheckResourceAttr ( "data.aws_elasticsearch_domain.bar" , "cluster_config.0.instance_type" , "t2.micro.elasticsearch " ),
24
- resource .TestCheckResourceAttr ( "data.aws_elasticsearch_domain.bar" , "cluster_config.0.instance_count" , "2 " ),
25
- resource .TestCheckResourceAttr ( "data.aws_elasticsearch_domain.bar" , "cluster_config.0.dedicated_master_enabled" , "false " ),
26
- resource .TestCheckResourceAttr ( "data.aws_elasticsearch_domain.bar" , "cluster_config.0.zone_awareness_enabled" , "true " ),
27
- resource .TestCheckResourceAttr ( "data.aws_elasticsearch_domain.bar" , "ebs_options.#" , "1 " ),
28
- resource .TestCheckResourceAttr ( "data.aws_elasticsearch_domain.bar" , "ebs_options.0.ebs_enabled" , "true " ),
29
- resource .TestCheckResourceAttr ( "data.aws_elasticsearch_domain.bar" , "ebs_options.0.volume_type" , "gp2 " ),
30
- resource .TestCheckResourceAttr ( "data.aws_elasticsearch_domain.bar" , "ebs_options.0.volume_size" , "20 " ),
31
- resource .TestCheckResourceAttr ( "data.aws_elasticsearch_domain.bar" , "snapshot_options.#" , "1 " ),
32
- resource .TestCheckResourceAttr ( "data.aws_elasticsearch_domain.bar" , "snapshot_options.0.automated_snapshot_start_hour" , "23 " ),
23
+ resource .TestCheckResourceAttrPair ( datasourceName , "elasticsearch_version" , resourceName , "elasticsearch_version " ),
24
+ resource .TestCheckResourceAttrPair ( datasourceName , "cluster_config.#" , resourceName , "cluster_config.# " ),
25
+ resource .TestCheckResourceAttrPair ( datasourceName , "cluster_config.0.instance_type" , resourceName , "cluster_config.0.instance_type " ),
26
+ resource .TestCheckResourceAttrPair ( datasourceName , "cluster_config.0.instance_count" , resourceName , "cluster_config.0.instance_count " ),
27
+ resource .TestCheckResourceAttrPair ( datasourceName , "cluster_config.0.dedicated_master_enabled" , resourceName , "cluster_config.0.dedicated_master_enabled " ),
28
+ resource .TestCheckResourceAttrPair ( datasourceName , "cluster_config.0.zone_awareness_enabled" , resourceName , "cluster_config.0.zone_awareness_enabled " ),
29
+ resource .TestCheckResourceAttrPair ( datasourceName , "ebs_options.#" , resourceName , "ebs_options.# " ),
30
+ resource .TestCheckResourceAttrPair ( datasourceName , "ebs_options.0.ebs_enabled" , resourceName , "ebs_options.0.ebs_enabled " ),
31
+ resource .TestCheckResourceAttrPair ( datasourceName , "ebs_options.0.volume_type" , resourceName , "ebs_options.0.volume_type " ),
32
+ resource .TestCheckResourceAttrPair ( datasourceName , "ebs_options.0.volume_size" , resourceName , "ebs_options.0.volume_size " ),
33
+ resource .TestCheckResourceAttrPair ( datasourceName , "snapshot_options.#" , resourceName , "snapshot_options.# " ),
34
+ resource .TestCheckResourceAttrPair ( datasourceName , "snapshot_options.0.automated_snapshot_start_hour" , resourceName , "snapshot_options.0.automated_snapshot_start_hour " ),
33
35
),
34
36
},
35
37
},
@@ -38,29 +40,31 @@ func TestAccAWSDataElasticsearchDomain_basic(t *testing.T) {
38
40
39
41
func TestAccAWSDataElasticsearchDomain_advanced (t * testing.T ) {
40
42
rInt := acctest .RandInt ()
43
+ datasourceName := "data.aws_elasticsearch_domain.test"
44
+ resourceName := "aws_elasticsearch_domain.test"
41
45
42
- resource .Test (t , resource.TestCase {
46
+ resource .ParallelTest (t , resource.TestCase {
43
47
PreCheck : func () { testAccPreCheck (t ) },
44
48
Providers : testAccProviders ,
45
49
Steps : []resource.TestStep {
46
50
{
47
51
Config : testAccAWSElasticsearchDomainConfigAdvancedWithDataSource (rInt ),
48
52
Check : resource .ComposeAggregateTestCheckFunc (
49
- resource .TestCheckResourceAttr ( "data.aws_elasticsearch_domain.bar" , "elasticsearch_version" , "1.5 " ),
50
- resource .TestCheckResourceAttr ( "data.aws_elasticsearch_domain.bar" , "cluster_config.#" , "1 " ),
51
- resource .TestCheckResourceAttr ( "data.aws_elasticsearch_domain.bar" , "cluster_config.0.instance_type" , "t2.micro.elasticsearch " ),
52
- resource .TestCheckResourceAttr ( "data.aws_elasticsearch_domain.bar" , "cluster_config.0.instance_count" , "2 " ),
53
- resource .TestCheckResourceAttr ( "data.aws_elasticsearch_domain.bar" , "cluster_config.0.dedicated_master_enabled" , "false " ),
54
- resource .TestCheckResourceAttr ( "data.aws_elasticsearch_domain.bar" , "cluster_config.0.zone_awareness_enabled" , "true " ),
55
- resource .TestCheckResourceAttr ( "data.aws_elasticsearch_domain.bar" , "ebs_options.#" , "1 " ),
56
- resource .TestCheckResourceAttr ( "data.aws_elasticsearch_domain.bar" , "ebs_options.0.ebs_enabled" , "true " ),
57
- resource .TestCheckResourceAttr ( "data.aws_elasticsearch_domain.bar" , "ebs_options.0.volume_type" , "gp2 " ),
58
- resource .TestCheckResourceAttr ( "data.aws_elasticsearch_domain.bar" , "ebs_options.0.volume_size" , "20 " ),
59
- resource .TestCheckResourceAttr ( "data.aws_elasticsearch_domain.bar" , "snapshot_options.#" , "1 " ),
60
- resource .TestCheckResourceAttr ( "data.aws_elasticsearch_domain.bar" , "snapshot_options.0.automated_snapshot_start_hour" , "23 " ),
61
- resource .TestCheckResourceAttr ( "data.aws_elasticsearch_domain.bar" , "log_publishing_options.#" , "1 " ),
62
- resource .TestCheckResourceAttr ( "data.aws_elasticsearch_domain.bar" , "log_publishing_options.0.log_type" , "INDEX_SLOW_LOGS " ),
63
- resource .TestCheckResourceAttr ( "data.aws_elasticsearch_domain.bar" , "vpc_options.#" , "1 " ),
53
+ resource .TestCheckResourceAttrPair ( datasourceName , "elasticsearch_version" , resourceName , "elasticsearch_version " ),
54
+ resource .TestCheckResourceAttrPair ( datasourceName , "cluster_config.#" , resourceName , "cluster_config.# " ),
55
+ resource .TestCheckResourceAttrPair ( datasourceName , "cluster_config.0.instance_type" , resourceName , "cluster_config.0.instance_type " ),
56
+ resource .TestCheckResourceAttrPair ( datasourceName , "cluster_config.0.instance_count" , resourceName , "cluster_config.0.instance_count " ),
57
+ resource .TestCheckResourceAttrPair ( datasourceName , "cluster_config.0.dedicated_master_enabled" , resourceName , "cluster_config.0.dedicated_master_enabled " ),
58
+ resource .TestCheckResourceAttrPair ( datasourceName , "cluster_config.0.zone_awareness_enabled" , resourceName , "cluster_config.0.zone_awareness_enabled " ),
59
+ resource .TestCheckResourceAttrPair ( datasourceName , "ebs_options.#" , resourceName , "ebs_options.# " ),
60
+ resource .TestCheckResourceAttrPair ( datasourceName , "ebs_options.0.ebs_enabled" , resourceName , "ebs_options.0.ebs_enabled " ),
61
+ resource .TestCheckResourceAttrPair ( datasourceName , "ebs_options.0.volume_type" , resourceName , "ebs_options.0.volume_type " ),
62
+ resource .TestCheckResourceAttrPair ( datasourceName , "ebs_options.0.volume_size" , resourceName , "ebs_options.0.volume_size " ),
63
+ resource .TestCheckResourceAttrPair ( datasourceName , "snapshot_options.#" , resourceName , "snapshot_options.# " ),
64
+ resource .TestCheckResourceAttrPair ( datasourceName , "snapshot_options.0.automated_snapshot_start_hour" , resourceName , "snapshot_options.0.automated_snapshot_start_hour " ),
65
+ resource .TestCheckResourceAttrPair ( datasourceName , "log_publishing_options.#" , resourceName , "log_publishing_options.# " ),
66
+ resource .TestCheckResourceAttrPair ( datasourceName , "log_publishing_options.0.log_type" , resourceName , "log_publishing_options.0.log_type " ),
67
+ resource .TestCheckResourceAttrPair ( datasourceName , "vpc_options.#" , resourceName , "vpc_options.# " ),
64
68
),
65
69
},
66
70
},
@@ -81,7 +85,7 @@ data "aws_region" "current" {}
81
85
82
86
data "aws_caller_identity" "current" {}
83
87
84
- resource "aws_elasticsearch_domain" "bar " {
88
+ resource "aws_elasticsearch_domain" "test " {
85
89
domain_name = "${local.random_name}"
86
90
elasticsearch_version = "1.5"
87
91
@@ -95,7 +99,7 @@ resource "aws_elasticsearch_domain" "bar" {
95
99
"Effect": "Allow",
96
100
"Resource": "arn:aws:es:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:domain/${local.random_name}/*",
97
101
"Condition": {
98
- "IpAddress": {"aws:SourceIp": ["66.193.100.22/32 "]}
102
+ "IpAddress": {"aws:SourceIp": ["127.0.0.0/8 "]}
99
103
}
100
104
}
101
105
]
@@ -105,7 +109,10 @@ POLICY
105
109
cluster_config {
106
110
instance_type = "t2.micro.elasticsearch"
107
111
instance_count = 2
108
- dedicated_master_enabled = false
112
+ dedicated_master_enabled = false
113
+ zone_awareness_config {
114
+ availability_zone_count = 2
115
+ }
109
116
zone_awareness_enabled = true
110
117
}
111
118
ebs_options {
@@ -118,8 +125,8 @@ POLICY
118
125
}
119
126
}
120
127
121
- data "aws_elasticsearch_domain" "bar " {
122
- domain_name = "${aws_elasticsearch_domain.bar .domain_name}"
128
+ data "aws_elasticsearch_domain" "test " {
129
+ domain_name = "${aws_elasticsearch_domain.test .domain_name}"
123
130
}
124
131
` , rInt )
125
132
}
@@ -138,11 +145,11 @@ locals {
138
145
random_name = "test-es-%d"
139
146
}
140
147
141
- resource "aws_cloudwatch_log_group" "bar " {
148
+ resource "aws_cloudwatch_log_group" "test " {
142
149
name = "${local.random_name}"
143
150
}
144
151
145
- resource "aws_cloudwatch_log_resource_policy" "bar " {
152
+ resource "aws_cloudwatch_log_resource_policy" "test " {
146
153
policy_name = "${local.random_name}"
147
154
policy_document = <<CONFIG
148
155
{
@@ -165,40 +172,40 @@ resource "aws_cloudwatch_log_resource_policy" "bar" {
165
172
CONFIG
166
173
}
167
174
168
- resource "aws_vpc" "bar " {
175
+ resource "aws_vpc" "test " {
169
176
cidr_block = "10.0.0.0/16"
170
177
}
171
178
172
- resource "aws_subnet" "bar " {
173
- vpc_id = "${aws_vpc.bar .id}"
179
+ resource "aws_subnet" "test " {
180
+ vpc_id = "${aws_vpc.test .id}"
174
181
cidr_block = "10.0.0.0/24"
175
182
}
176
183
177
- resource "aws_subnet" "baz " {
178
- vpc_id = "${aws_vpc.bar .id}"
184
+ resource "aws_subnet" "test2 " {
185
+ vpc_id = "${aws_vpc.test .id}"
179
186
cidr_block = "10.0.1.0/24"
180
187
}
181
188
182
- resource "aws_security_group" "bar " {
189
+ resource "aws_security_group" "test " {
183
190
name = "${local.random_name}"
184
- vpc_id = "${aws_vpc.bar .id}"
191
+ vpc_id = "${aws_vpc.test .id}"
185
192
}
186
193
187
- resource "aws_security_group_rule" "bar " {
194
+ resource "aws_security_group_rule" "test " {
188
195
type = "ingress"
189
196
from_port = 443
190
197
to_port = 443
191
198
protocol = "tcp"
192
199
cidr_blocks = [ "0.0.0.0/0" ]
193
200
194
- security_group_id = "${aws_security_group.bar .id}"
201
+ security_group_id = "${aws_security_group.test .id}"
195
202
}
196
203
197
- resource "aws_iam_service_linked_role" "bar " {
204
+ resource "aws_iam_service_linked_role" "test " {
198
205
aws_service_name = "es.amazonaws.com"
199
206
}
200
207
201
- resource "aws_elasticsearch_domain" "bar " {
208
+ resource "aws_elasticsearch_domain" "test " {
202
209
domain_name = "${local.random_name}"
203
210
elasticsearch_version = "1.5"
204
211
@@ -220,6 +227,9 @@ POLICY
220
227
instance_type = "t2.micro.elasticsearch"
221
228
instance_count = 2
222
229
dedicated_master_enabled = false
230
+ zone_awareness_config {
231
+ availability_zone_count = 2
232
+ }
223
233
zone_awareness_enabled = true
224
234
}
225
235
ebs_options {
@@ -231,30 +241,30 @@ POLICY
231
241
automated_snapshot_start_hour = 23
232
242
}
233
243
log_publishing_options {
234
- cloudwatch_log_group_arn = "${aws_cloudwatch_log_group.bar .arn}"
244
+ cloudwatch_log_group_arn = "${aws_cloudwatch_log_group.test .arn}"
235
245
log_type = "INDEX_SLOW_LOGS"
236
246
}
237
247
vpc_options {
238
248
security_group_ids = [
239
- "${aws_security_group.bar .id}"
249
+ "${aws_security_group.test .id}"
240
250
]
241
251
subnet_ids = [
242
- "${aws_subnet.bar .id}",
243
- "${aws_subnet.baz .id}"
252
+ "${aws_subnet.test .id}",
253
+ "${aws_subnet.test2 .id}"
244
254
]
245
255
}
246
256
247
- tags {
248
- Domain = "TestDomain"
249
- }
257
+ tags = {
258
+ Domain = "TestDomain"
259
+ }
250
260
251
- depends_on = [
252
- "aws_iam_service_linked_role.bar ",
261
+ depends_on = [
262
+ "aws_iam_service_linked_role.test ",
253
263
]
254
264
}
255
265
256
- data "aws_elasticsearch_domain" "bar " {
257
- domain_name = "${aws_elasticsearch_domain.bar .domain_name}"
266
+ data "aws_elasticsearch_domain" "test " {
267
+ domain_name = "${aws_elasticsearch_domain.test .domain_name}"
258
268
}
259
269
` , rInt )
260
270
}
0 commit comments