@@ -50,6 +50,7 @@ func testAccLFTagExpression_basic(t *testing.T) {
50
50
testAccCheckLFTagExpressionExists (ctx , resourceName , & lftagexpression ),
51
51
resource .TestCheckResourceAttr (resourceName , names .AttrName , rName ),
52
52
resource .TestCheckResourceAttrSet (resourceName , names .AttrCatalogID ),
53
+ resource .TestCheckResourceAttr (resourceName , names .AttrDescription , "test description" ),
53
54
resource .TestCheckResourceAttr (resourceName , "expression.#" , "1" ),
54
55
),
55
56
},
@@ -82,93 +83,30 @@ func testAccLFTagExpression_update(t *testing.T) {
82
83
CheckDestroy : testAccCheckLFTagExpressionDestroy (ctx ),
83
84
Steps : []resource.TestStep {
84
85
{
85
- Config : testAccLFTagExpressionConfig_update1 (rName ),
86
+ Config : testAccLFTagExpressionConfig_basic (rName ),
86
87
Check : resource .ComposeTestCheckFunc (
87
88
testAccCheckLFTagExpressionExists (ctx , resourceName , & lftagexpression ),
88
89
resource .TestCheckResourceAttr (resourceName , names .AttrName , rName ),
89
- resource .TestCheckResourceAttr (resourceName , names .AttrDescription , "Initial description" ),
90
90
resource .TestCheckResourceAttrSet (resourceName , names .AttrCatalogID ),
91
- resource .TestCheckResourceAttrSet (resourceName , names .AttrID ),
92
- resource .TestCheckResourceAttr (resourceName , "tag_expression.%" , "3" ),
93
- resource .TestCheckResourceAttr (resourceName , "tag_expression.domain.#" , "2" ),
94
- resource .TestCheckTypeSetElemAttr (resourceName , "tag_expression.domain.*" , "finance" ),
95
- resource .TestCheckTypeSetElemAttr (resourceName , "tag_expression.domain.*" , "hr" ),
96
- resource .TestCheckResourceAttr (resourceName , "tag_expression.environment.#" , "3" ),
97
- resource .TestCheckTypeSetElemAttr (resourceName , "tag_expression.environment.*" , "dev" ),
98
- resource .TestCheckTypeSetElemAttr (resourceName , "tag_expression.environment.*" , "staging" ),
99
- resource .TestCheckTypeSetElemAttr (resourceName , "tag_expression.environment.*" , "prod" ),
100
- resource .TestCheckResourceAttr (resourceName , "tag_expression.team.#" , "1" ),
101
- resource .TestCheckTypeSetElemAttr (resourceName , "tag_expression.team.*" , "data-eng" ),
91
+ resource .TestCheckResourceAttr (resourceName , names .AttrDescription , "test description" ),
92
+ resource .TestCheckResourceAttr (resourceName , "expression.#" , "1" ),
102
93
),
103
94
},
104
95
{
105
- Config : testAccLFTagExpressionConfig_update2 (rName ),
106
- Check : resource .ComposeTestCheckFunc (
107
- testAccCheckLFTagExpressionExists (ctx , resourceName , & lftagexpression ),
108
- resource .TestCheckResourceAttr (resourceName , names .AttrName , rName ),
109
- resource .TestCheckResourceAttr (resourceName , names .AttrDescription , "Updated description" ),
110
- resource .TestCheckResourceAttrSet (resourceName , names .AttrCatalogID ),
111
- resource .TestCheckResourceAttrSet (resourceName , names .AttrID ),
112
- // Verify tag_expression changes: removed 'team', added 'project', modified 'domain' and 'environment'
113
- resource .TestCheckResourceAttr (resourceName , "tag_expression.%" , "3" ),
114
- resource .TestCheckResourceAttr (resourceName , "tag_expression.domain.#" , "3" ),
115
- resource .TestCheckTypeSetElemAttr (resourceName , "tag_expression.domain.*" , "finance" ),
116
- resource .TestCheckTypeSetElemAttr (resourceName , "tag_expression.domain.*" , "marketing" ),
117
- resource .TestCheckTypeSetElemAttr (resourceName , "tag_expression.domain.*" , "operations" ),
118
- resource .TestCheckResourceAttr (resourceName , "tag_expression.environment.#" , "2" ),
119
- resource .TestCheckTypeSetElemAttr (resourceName , "tag_expression.environment.*" , "prod" ),
120
- resource .TestCheckTypeSetElemAttr (resourceName , "tag_expression.environment.*" , "test" ),
121
- resource .TestCheckResourceAttr (resourceName , "tag_expression.project.#" , "2" ),
122
- resource .TestCheckTypeSetElemAttr (resourceName , "tag_expression.project.*" , "alpha" ),
123
- resource .TestCheckTypeSetElemAttr (resourceName , "tag_expression.project.*" , "beta" ),
124
- ),
96
+ ResourceName : resourceName ,
97
+ ImportState : true ,
98
+ ImportStateIdFunc : acctest .AttrsImportStateIdFunc (resourceName , "," , names .AttrName , names .AttrCatalogID ),
99
+ ImportStateVerify : true ,
100
+ ImportStateVerifyIdentifierAttribute : names .AttrName ,
125
101
},
126
102
{
127
- // Remove LF Tag Expression but keep Data Lake Settings to verify destruction with proper permissions
128
- Config : testAccLFTagExpressionConfig_updateOnlyDataLakeSettings (rName ),
129
- Check : resource .ComposeTestCheckFunc (
130
- // Verify LF Tag Expression is destroyed while admin permissions still exist
131
- testAccCheckLFTagExpressionDestroy (ctx ),
132
- ),
133
- },
134
- },
135
- })
136
- }
137
-
138
- func testAccLFTagExpression_import (t * testing.T ) {
139
- ctx := acctest .Context (t )
140
-
141
- var lftagexpression lakeformation.GetLFTagExpressionOutput
142
- rName := sdkacctest .RandomWithPrefix (acctest .ResourcePrefix )
143
- resourceName := "aws_lakeformation_lf_tag_expression.test"
144
-
145
- resource .Test (t , resource.TestCase {
146
- PreCheck : func () {
147
- acctest .PreCheck (ctx , t )
148
- acctest .PreCheckPartitionHasService (t , names .LakeFormation )
149
- testAccLFTagExpressionPreCheck (ctx , t )
150
- },
151
- ErrorCheck : acctest .ErrorCheck (t , names .LakeFormationServiceID ),
152
- ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories ,
153
- CheckDestroy : testAccCheckLFTagExpressionDestroy (ctx ),
154
- Steps : []resource.TestStep {
155
- {
156
- Config : testAccLFTagExpressionConfig_basic (rName ),
103
+ Config : testAccLFTagExpressionConfig_update (rName ),
157
104
Check : resource .ComposeTestCheckFunc (
158
105
testAccCheckLFTagExpressionExists (ctx , resourceName , & lftagexpression ),
159
- ),
160
- },
161
- {
162
- ResourceName : resourceName ,
163
- ImportState : true ,
164
- ImportStateVerify : true ,
165
- },
166
- {
167
- // Remove LF Tag Expression but keep Data Lake Settings to verify destruction with proper permissions
168
- Config : testAccLFTagExpressionConfig_onlyDataLakeSettings (rName ),
169
- Check : resource .ComposeTestCheckFunc (
170
- // Verify LF Tag Expression is destroyed while admin permissions still exist
171
- testAccCheckLFTagExpressionDestroy (ctx ),
106
+ resource .TestCheckResourceAttr (resourceName , names .AttrName , rName ),
107
+ resource .TestCheckResourceAttrSet (resourceName , names .AttrCatalogID ),
108
+ resource .TestCheckResourceAttr (resourceName , names .AttrDescription , "test description two" ),
109
+ resource .TestCheckResourceAttr (resourceName , "expression.#" , "2" ),
172
110
),
173
111
},
174
112
},
@@ -279,141 +217,36 @@ resource "aws_lakeformation_lf_tag_expression" "test" {
279
217
` , rName ))
280
218
}
281
219
282
- func testAccLFTagExpressionConfig_onlyDataLakeSettings (rName string ) string {
283
- return `
284
- data "aws_caller_identity" "current" {}
285
-
286
- data "aws_iam_session_context" "current" {
287
- arn = data.aws_caller_identity.current.arn
288
- }
289
-
290
- resource "aws_lakeformation_data_lake_settings" "test" {
291
- admins = [data.aws_iam_session_context.current.issuer_arn]
292
- }
293
-
294
- resource "aws_lakeformation_lf_tag" "domain" {
295
- key = "domain"
296
- values = ["prisons"]
297
- depends_on = [aws_lakeformation_data_lake_settings.test]
298
- }
299
- `
300
- }
301
-
302
- func testAccLFTagExpressionConfig_update1 (rName string ) string {
303
- return fmt .Sprintf (`
304
- data "aws_caller_identity" "current" {}
305
-
306
- data "aws_iam_session_context" "current" {
307
- arn = data.aws_caller_identity.current.arn
308
- }
309
-
310
- resource "aws_lakeformation_data_lake_settings" "test" {
311
- admins = [data.aws_iam_session_context.current.issuer_arn]
312
- }
313
-
314
- resource "aws_lakeformation_lf_tag" "domain" {
315
- key = "domain"
316
- values = ["finance", "hr", "marketing", "operations"]
317
- depends_on = [aws_lakeformation_data_lake_settings.test]
318
- }
319
-
320
- resource "aws_lakeformation_lf_tag" "environment" {
321
- key = "environment"
322
- values = ["dev", "staging", "prod", "test"]
323
- depends_on = [aws_lakeformation_data_lake_settings.test]
324
- }
325
-
326
- resource "aws_lakeformation_lf_tag" "team" {
327
- key = "team"
328
- values = ["data-eng"]
329
- depends_on = [aws_lakeformation_data_lake_settings.test]
330
- }
220
+ func testAccLFTagExpressionConfig_update (rName string ) string {
221
+ return acctest .ConfigCompose (testAccLFTagExpression_baseConfig ,
222
+ fmt .Sprintf (`
223
+ resource "aws_lakeformation_lf_tag" "test2" {
224
+ key = "key2"
225
+ values = ["value2"]
331
226
332
- resource "aws_lakeformation_lf_tag" "project" {
333
- key = "project"
334
- values = ["alpha", "beta"]
335
227
depends_on = [aws_lakeformation_data_lake_settings.test]
336
228
}
337
229
338
230
resource "aws_lakeformation_lf_tag_expression" "test" {
339
231
name = %[1]q
340
- description = "Initial description"
341
-
342
- tag_expression = {
343
- domain = ["finance", "hr"]
344
- environment = ["dev", "staging", "prod"]
345
- team = ["data-eng"]
346
- }
347
-
348
- depends_on = [
349
- aws_lakeformation_lf_tag.domain,
350
- aws_lakeformation_lf_tag.environment,
351
- aws_lakeformation_lf_tag.team,
352
- aws_lakeformation_lf_tag.project,
353
- aws_lakeformation_data_lake_settings.test,
354
- ]
355
- }
356
- ` , rName )
357
- }
358
-
359
- func testAccLFTagExpressionConfig_update2 (rName string ) string {
360
- return fmt .Sprintf (`
361
- data "aws_caller_identity" "current" {}
362
-
363
- data "aws_iam_session_context" "current" {
364
- arn = data.aws_caller_identity.current.arn
365
- }
366
-
367
- resource "aws_lakeformation_data_lake_settings" "test" {
368
- admins = [data.aws_iam_session_context.current.issuer_arn]
369
- }
232
+ description = "test description two"
370
233
371
- resource "aws_lakeformation_lf_tag" "domain" {
372
- key = "domain"
373
- values = ["finance", "hr", "marketing", "operations"]
374
- depends_on = [aws_lakeformation_data_lake_settings.test]
375
- }
376
-
377
- resource "aws_lakeformation_lf_tag" "environment" {
378
- key = "environment"
379
- values = ["dev", "staging", "prod", "test"]
380
- depends_on = [aws_lakeformation_data_lake_settings.test]
381
- }
382
-
383
- resource "aws_lakeformation_lf_tag" "team" {
384
- key = "team"
385
- values = ["data-eng"]
386
- depends_on = [aws_lakeformation_data_lake_settings.test]
387
- }
388
-
389
- resource "aws_lakeformation_lf_tag" "project" {
390
- key = "project"
391
- values = ["alpha", "beta"]
392
- depends_on = [aws_lakeformation_data_lake_settings.test]
393
- }
234
+ expression {
235
+ tag_key = aws_lakeformation_lf_tag.test.key
236
+ tag_values = aws_lakeformation_lf_tag.test.values
237
+ }
394
238
395
- resource "aws_lakeformation_lf_tag_expression" "test" {
396
- name = %[1]q
397
- description = "Updated description"
398
-
399
- tag_expression = {
400
- domain = ["finance", "marketing", "operations"]
401
- environment = ["prod", "test"]
402
- project = ["alpha", "beta"]
239
+ expression {
240
+ tag_key = aws_lakeformation_lf_tag.test2.key
241
+ tag_values = aws_lakeformation_lf_tag.test2.values
403
242
}
404
243
405
- depends_on = [
406
- aws_lakeformation_lf_tag.domain,
407
- aws_lakeformation_lf_tag.environment,
408
- aws_lakeformation_lf_tag.team,
409
- aws_lakeformation_lf_tag.project,
410
- aws_lakeformation_data_lake_settings.test,
411
- ]
244
+ depends_on = [aws_lakeformation_data_lake_settings.test]
412
245
}
413
- ` , rName )
246
+ ` , rName ))
414
247
}
415
248
416
- func testAccLFTagExpressionConfig_updateOnlyDataLakeSettings (rName string ) string {
249
+ func testAccLFTagExpressionConfig_onlyDataLakeSettings (rName string ) string {
417
250
return `
418
251
data "aws_caller_identity" "current" {}
419
252
@@ -427,25 +260,7 @@ resource "aws_lakeformation_data_lake_settings" "test" {
427
260
428
261
resource "aws_lakeformation_lf_tag" "domain" {
429
262
key = "domain"
430
- values = ["finance", "hr", "marketing", "operations"]
431
- depends_on = [aws_lakeformation_data_lake_settings.test]
432
- }
433
-
434
- resource "aws_lakeformation_lf_tag" "environment" {
435
- key = "environment"
436
- values = ["dev", "staging", "prod", "test"]
437
- depends_on = [aws_lakeformation_data_lake_settings.test]
438
- }
439
-
440
- resource "aws_lakeformation_lf_tag" "team" {
441
- key = "team"
442
- values = ["data-eng"]
443
- depends_on = [aws_lakeformation_data_lake_settings.test]
444
- }
445
-
446
- resource "aws_lakeformation_lf_tag" "project" {
447
- key = "project"
448
- values = ["alpha", "beta"]
263
+ values = ["prisons"]
449
264
depends_on = [aws_lakeformation_data_lake_settings.test]
450
265
}
451
266
`
0 commit comments