@@ -10,12 +10,14 @@ import (
10
10
"testing"
11
11
12
12
"github.com/aws/aws-sdk-go-v2/service/lakeformation"
13
+ awstypes "github.com/aws/aws-sdk-go-v2/service/lakeformation/types"
13
14
sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest"
14
15
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
15
16
"github.com/hashicorp/terraform-plugin-testing/terraform"
16
17
"github.com/hashicorp/terraform-provider-aws/internal/acctest"
17
18
"github.com/hashicorp/terraform-provider-aws/internal/conns"
18
19
"github.com/hashicorp/terraform-provider-aws/internal/create"
20
+ "github.com/hashicorp/terraform-provider-aws/internal/errs"
19
21
"github.com/hashicorp/terraform-provider-aws/internal/retry"
20
22
tflakeformation "github.com/hashicorp/terraform-provider-aws/internal/service/lakeformation"
21
23
"github.com/hashicorp/terraform-provider-aws/names"
@@ -48,18 +50,15 @@ func testAccLFTagExpression_basic(t *testing.T) {
48
50
testAccCheckLFTagExpressionExists (ctx , resourceName , & lftagexpression ),
49
51
resource .TestCheckResourceAttr (resourceName , names .AttrName , rName ),
50
52
resource .TestCheckResourceAttrSet (resourceName , names .AttrCatalogID ),
51
- resource .TestCheckResourceAttrSet (resourceName , names .AttrID ),
52
- resource .TestCheckResourceAttr (resourceName , "tag_expression.%" , "1" ),
53
- resource .TestCheckResourceAttr (resourceName , "tag_expression.domain.#" , "1" ),
53
+ resource .TestCheckResourceAttr (resourceName , "expression.#" , "1" ),
54
54
),
55
55
},
56
56
{
57
- // Remove LF Tag Expression but keep Data Lake Settings to verify destruction with proper permissions
58
- Config : testAccLFTagExpressionConfig_onlyDataLakeSettings (rName ),
59
- Check : resource .ComposeTestCheckFunc (
60
- // Verify LF Tag Expression is destroyed while admin permissions still exist
61
- testAccCheckLFTagExpressionDestroy (ctx ),
62
- ),
57
+ ResourceName : resourceName ,
58
+ ImportState : true ,
59
+ ImportStateIdFunc : acctest .AttrsImportStateIdFunc (resourceName , "," , names .AttrName , names .AttrCatalogID ),
60
+ ImportStateVerify : true ,
61
+ ImportStateVerifyIdentifierAttribute : names .AttrName ,
63
62
},
64
63
},
65
64
})
@@ -191,6 +190,10 @@ func testAccCheckLFTagExpressionDestroy(ctx context.Context) resource.TestCheckF
191
190
continue
192
191
}
193
192
193
+ if errs .IsAErrorMessageContains [* awstypes.AccessDeniedException ](err , "Insufficient Lake Formation permission(s)" ) {
194
+ continue
195
+ }
196
+
194
197
if err != nil {
195
198
return create .Error (names .LakeFormation , create .ErrActionCheckingDestroyed , ResNameLFTagExpression , rs .Primary .ID , err )
196
199
}
@@ -240,8 +243,7 @@ func testAccLFTagExpressionPreCheck(ctx context.Context, t *testing.T) {
240
243
}
241
244
}
242
245
243
- func testAccLFTagExpressionConfig_basic (rName string ) string {
244
- return fmt .Sprintf (`
246
+ const testAccLFTagExpression_baseConfig = `
245
247
data "aws_caller_identity" "current" {}
246
248
247
249
data "aws_iam_session_context" "current" {
@@ -252,25 +254,29 @@ resource "aws_lakeformation_data_lake_settings" "test" {
252
254
admins = [data.aws_iam_session_context.current.issuer_arn]
253
255
}
254
256
255
- resource "aws_lakeformation_lf_tag" "domain" {
256
- key = "domain"
257
- values = ["prisons"]
257
+ resource "aws_lakeformation_lf_tag" "test" {
258
+ key = "key"
259
+ values = ["value"]
260
+
258
261
depends_on = [aws_lakeformation_data_lake_settings.test]
259
262
}
263
+ `
260
264
265
+ func testAccLFTagExpressionConfig_basic (rName string ) string {
266
+ return acctest .ConfigCompose (testAccLFTagExpression_baseConfig ,
267
+ fmt .Sprintf (`
261
268
resource "aws_lakeformation_lf_tag_expression" "test" {
262
- name = %[1]q
263
-
264
- tag_expression = {
265
- domain = ["prisons"]
269
+ name = %[1]q
270
+ description = "test description"
271
+
272
+ expression {
273
+ tag_key = aws_lakeformation_lf_tag.test.key
274
+ tag_values = aws_lakeformation_lf_tag.test.values
266
275
}
267
276
268
- depends_on = [
269
- aws_lakeformation_lf_tag.domain,
270
- aws_lakeformation_data_lake_settings.test
271
- ]
277
+ depends_on = [aws_lakeformation_data_lake_settings.test]
272
278
}
273
- ` , rName )
279
+ ` , rName ))
274
280
}
275
281
276
282
func testAccLFTagExpressionConfig_onlyDataLakeSettings (rName string ) string {
0 commit comments