@@ -10,122 +10,21 @@ 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"
14
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
15
13
sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest"
16
14
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
17
15
"github.com/hashicorp/terraform-plugin-testing/terraform"
18
16
"github.com/hashicorp/terraform-provider-aws/internal/acctest"
19
17
"github.com/hashicorp/terraform-provider-aws/internal/conns"
20
18
"github.com/hashicorp/terraform-provider-aws/internal/create"
21
- "github.com/hashicorp/terraform-provider-aws/internal/errs "
22
- "github.com/hashicorp/terraform-provider-aws/internal/tfresource "
19
+ "github.com/hashicorp/terraform-provider-aws/internal/retry "
20
+ tflakeformation "github.com/hashicorp/terraform-provider-aws/internal/service/lakeformation "
23
21
"github.com/hashicorp/terraform-provider-aws/names"
24
- "strings"
25
22
)
26
23
27
24
const (
28
25
ResNameLFTagExpression = "LF Tag Expression"
29
26
)
30
27
31
- //// FindLFTagExpressionByID retrieves an LF Tag Expression by parsing the ID (catalog_id:name)
32
- //func FindLFTagExpressionByID(ctx context.Context, conn *lakeformation.Client, id string) (*lakeformation.GetLFTagExpressionOutput, error) {
33
- // input := &lakeformation.GetLFTagExpressionInput{}
34
- //
35
- // // Check if ID contains catalog_id:name format or just name
36
- // if parts := strings.SplitN(id, ":", 2); len(parts) == 2 {
37
- // catalogId := parts[0]
38
- // name := parts[1]
39
- // input.CatalogId = &catalogId
40
- // input.Name = &name
41
- // } else {
42
- // // Treat entire ID as name, no catalog specified
43
- // input.Name = &id
44
- // }
45
- //
46
- // output, err := conn.GetLFTagExpression(ctx, input)
47
- //
48
- // if errs.IsA[*awstypes.EntityNotFoundException](err) {
49
- // return nil, &retry.NotFoundError{
50
- // LastError: err,
51
- // LastRequest: input,
52
- // }
53
- // }
54
- //
55
- // if err != nil {
56
- // return nil, err
57
- // }
58
- //
59
- // return output, nil
60
- //}
61
-
62
- func testAccLFTagExpressionPreCheck (ctx context.Context , t * testing.T ) {
63
- conn := acctest .Provider .Meta ().(* conns.AWSClient ).LakeFormationClient (ctx )
64
-
65
- input := & lakeformation.ListLFTagExpressionsInput {}
66
- _ , err := conn .ListLFTagExpressions (ctx , input )
67
-
68
- if acctest .PreCheckSkipError (err ) {
69
- t .Skipf ("skipping acceptance testing: %s" , err )
70
- }
71
- if err != nil {
72
- t .Fatalf ("unexpected PreCheck error: %s" , err )
73
- }
74
- }
75
-
76
- func testAccLFTagExpressionConfig_basic (rName string ) string {
77
- return fmt .Sprintf (`
78
- data "aws_caller_identity" "current" {}
79
-
80
- data "aws_iam_session_context" "current" {
81
- arn = data.aws_caller_identity.current.arn
82
- }
83
-
84
- resource "aws_lakeformation_data_lake_settings" "test" {
85
- admins = [data.aws_iam_session_context.current.issuer_arn]
86
- }
87
-
88
- resource "aws_lakeformation_lf_tag" "domain" {
89
- key = "domain"
90
- values = ["prisons"]
91
- depends_on = [aws_lakeformation_data_lake_settings.test]
92
- }
93
-
94
- resource "aws_lakeformation_lf_tag_expression" "test" {
95
- name = %[1]q
96
-
97
- tag_expression = {
98
- domain = ["prisons"]
99
- }
100
-
101
- depends_on = [
102
- aws_lakeformation_lf_tag.domain,
103
- aws_lakeformation_data_lake_settings.test
104
- ]
105
- }
106
- ` , rName )
107
- }
108
-
109
- func testAccLFTagExpressionConfig_onlyDataLakeSettings (rName string ) string {
110
- return `
111
- data "aws_caller_identity" "current" {}
112
-
113
- data "aws_iam_session_context" "current" {
114
- arn = data.aws_caller_identity.current.arn
115
- }
116
-
117
- resource "aws_lakeformation_data_lake_settings" "test" {
118
- admins = [data.aws_iam_session_context.current.issuer_arn]
119
- }
120
-
121
- resource "aws_lakeformation_lf_tag" "domain" {
122
- key = "domain"
123
- values = ["prisons"]
124
- depends_on = [aws_lakeformation_data_lake_settings.test]
125
- }
126
- `
127
- }
128
-
129
28
func testAccLFTagExpression_basic (t * testing.T ) {
130
29
ctx := acctest .Context (t )
131
30
@@ -286,10 +185,10 @@ func testAccCheckLFTagExpressionDestroy(ctx context.Context) resource.TestCheckF
286
185
continue
287
186
}
288
187
289
- _ , err := FindLFTagExpressionByID (ctx , conn , rs .Primary .ID )
188
+ _ , err := tflakeformation . FindLFTagExpression (ctx , conn , rs .Primary .Attributes [ names . AttrName ], rs . Primary . Attributes [ names . AttrCatalogID ] )
290
189
291
- if tfresource .NotFound (err ) {
292
- return nil
190
+ if retry .NotFound (err ) {
191
+ continue
293
192
}
294
193
295
194
if err != nil {
@@ -315,7 +214,7 @@ func testAccCheckLFTagExpressionExists(ctx context.Context, name string, lftagex
315
214
}
316
215
317
216
conn := acctest .Provider .Meta ().(* conns.AWSClient ).LakeFormationClient (ctx )
318
- resp , err := FindLFTagExpressionByID (ctx , conn , rs .Primary .ID )
217
+ resp , err := tflakeformation . FindLFTagExpression (ctx , conn , rs .Primary .Attributes [ names . AttrName ], rs . Primary . Attributes [ names . AttrCatalogID ] )
319
218
320
219
if err != nil {
321
220
return create .Error (names .LakeFormation , create .ErrActionCheckingExistence , ResNameLFTagExpression , rs .Primary .ID , err )
@@ -327,6 +226,73 @@ func testAccCheckLFTagExpressionExists(ctx context.Context, name string, lftagex
327
226
}
328
227
}
329
228
229
+ func testAccLFTagExpressionPreCheck (ctx context.Context , t * testing.T ) {
230
+ conn := acctest .Provider .Meta ().(* conns.AWSClient ).LakeFormationClient (ctx )
231
+
232
+ input := lakeformation.ListLFTagExpressionsInput {}
233
+ _ , err := conn .ListLFTagExpressions (ctx , & input )
234
+
235
+ if acctest .PreCheckSkipError (err ) {
236
+ t .Skipf ("skipping acceptance testing: %s" , err )
237
+ }
238
+ if err != nil {
239
+ t .Fatalf ("unexpected PreCheck error: %s" , err )
240
+ }
241
+ }
242
+
243
+ func testAccLFTagExpressionConfig_basic (rName string ) string {
244
+ return fmt .Sprintf (`
245
+ data "aws_caller_identity" "current" {}
246
+
247
+ data "aws_iam_session_context" "current" {
248
+ arn = data.aws_caller_identity.current.arn
249
+ }
250
+
251
+ resource "aws_lakeformation_data_lake_settings" "test" {
252
+ admins = [data.aws_iam_session_context.current.issuer_arn]
253
+ }
254
+
255
+ resource "aws_lakeformation_lf_tag" "domain" {
256
+ key = "domain"
257
+ values = ["prisons"]
258
+ depends_on = [aws_lakeformation_data_lake_settings.test]
259
+ }
260
+
261
+ resource "aws_lakeformation_lf_tag_expression" "test" {
262
+ name = %[1]q
263
+
264
+ tag_expression = {
265
+ domain = ["prisons"]
266
+ }
267
+
268
+ depends_on = [
269
+ aws_lakeformation_lf_tag.domain,
270
+ aws_lakeformation_data_lake_settings.test
271
+ ]
272
+ }
273
+ ` , rName )
274
+ }
275
+
276
+ func testAccLFTagExpressionConfig_onlyDataLakeSettings (rName string ) string {
277
+ return `
278
+ data "aws_caller_identity" "current" {}
279
+
280
+ data "aws_iam_session_context" "current" {
281
+ arn = data.aws_caller_identity.current.arn
282
+ }
283
+
284
+ resource "aws_lakeformation_data_lake_settings" "test" {
285
+ admins = [data.aws_iam_session_context.current.issuer_arn]
286
+ }
287
+
288
+ resource "aws_lakeformation_lf_tag" "domain" {
289
+ key = "domain"
290
+ values = ["prisons"]
291
+ depends_on = [aws_lakeformation_data_lake_settings.test]
292
+ }
293
+ `
294
+ }
295
+
330
296
func testAccLFTagExpressionConfig_update1 (rName string ) string {
331
297
return fmt .Sprintf (`
332
298
data "aws_caller_identity" "current" {}
0 commit comments