Skip to content

Commit c0f51dc

Browse files
Rename policy tag to LF tag
1 parent ba62404 commit c0f51dc

6 files changed

+62
-62
lines changed

.changelog/19523.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
```release-note:new-resource
2-
aws_lakeformation_policy_tag
2+
aws_lakeformation_lf_tag
33
```

aws/provider.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ func Provider() *schema.Provider {
832832
"aws_kms_ciphertext": resourceAwsKmsCiphertext(),
833833
"aws_lakeformation_data_lake_settings": resourceAwsLakeFormationDataLakeSettings(),
834834
"aws_lakeformation_permissions": resourceAwsLakeFormationPermissions(),
835-
"aws_lakeformation_policy_tag": resourceAwsLakeFormationPolicyTag(),
835+
"aws_lakeformation_lf_tag": resourceAwsLakeFormationLFTag(),
836836
"aws_lakeformation_resource": resourceAwsLakeFormationResource(),
837837
"aws_lambda_alias": resourceAwsLambdaAlias(),
838838
"aws_lambda_code_signing_config": resourceAwsLambdaCodeSigningConfig(),

aws/resource_aws_lakeformation_policy_tag.go renamed to aws/resource_aws_lakeformation_lf_tag.go

+22-22
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ import (
1212
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
1313
)
1414

15-
func resourceAwsLakeFormationPolicyTag() *schema.Resource {
15+
func resourceAwsLakeFormationLFTag() *schema.Resource {
1616
return &schema.Resource{
17-
Create: resourceAwsLakeFormationPolicyTagCreate,
18-
Read: resourceAwsLakeFormationPolicyTagRead,
19-
Update: resourceAwsLakeFormationPolicyTagUpdate,
20-
Delete: resourceAwsLakeFormationPolicyTagDelete,
17+
Create: resourceAwsLakeFormationLFTagCreate,
18+
Read: resourceAwsLakeFormationLFTagRead,
19+
Update: resourceAwsLakeFormationLFTagUpdate,
20+
Delete: resourceAwsLakeFormationLFTagDelete,
2121
Importer: &schema.ResourceImporter{
2222
State: schema.ImportStatePassthrough,
2323
},
@@ -36,7 +36,7 @@ func resourceAwsLakeFormationPolicyTag() *schema.Resource {
3636
MaxItems: 15,
3737
Elem: &schema.Schema{
3838
Type: schema.TypeString,
39-
ValidateFunc: validatePolicyTagValues(),
39+
ValidateFunc: validateLFTagValues(),
4040
},
4141
Set: schema.HashString,
4242
},
@@ -50,7 +50,7 @@ func resourceAwsLakeFormationPolicyTag() *schema.Resource {
5050
}
5151
}
5252

53-
func resourceAwsLakeFormationPolicyTagCreate(d *schema.ResourceData, meta interface{}) error {
53+
func resourceAwsLakeFormationLFTagCreate(d *schema.ResourceData, meta interface{}) error {
5454
conn := meta.(*AWSClient).lakeformationconn
5555

5656
tagKey := d.Get("key").(string)
@@ -71,18 +71,18 @@ func resourceAwsLakeFormationPolicyTagCreate(d *schema.ResourceData, meta interf
7171

7272
_, err := conn.CreateLFTag(input)
7373
if err != nil {
74-
return fmt.Errorf("Error creating Lake Formation Policy Tag: %w", err)
74+
return fmt.Errorf("Error creating Lake Formation LF-Tag: %w", err)
7575
}
7676

7777
d.SetId(fmt.Sprintf("%s:%s", catalogID, tagKey))
7878

79-
return resourceAwsLakeFormationPolicyTagRead(d, meta)
79+
return resourceAwsLakeFormationLFTagRead(d, meta)
8080
}
8181

82-
func resourceAwsLakeFormationPolicyTagRead(d *schema.ResourceData, meta interface{}) error {
82+
func resourceAwsLakeFormationLFTagRead(d *schema.ResourceData, meta interface{}) error {
8383
conn := meta.(*AWSClient).lakeformationconn
8484

85-
catalogID, tagKey, err := readPolicyTagID(d.Id())
85+
catalogID, tagKey, err := readLFTagID(d.Id())
8686
if err != nil {
8787
return err
8888
}
@@ -95,12 +95,12 @@ func resourceAwsLakeFormationPolicyTagRead(d *schema.ResourceData, meta interfac
9595
output, err := conn.GetLFTag(input)
9696
if err != nil {
9797
if isAWSErr(err, lakeformation.ErrCodeEntityNotFoundException, "") {
98-
log.Printf("[WARN] Lake Formation Policy Tag (%s) not found, removing from state", d.Id())
98+
log.Printf("[WARN] Lake Formation LF-Tag (%s) not found, removing from state", d.Id())
9999
d.SetId("")
100100
return nil
101101
}
102102

103-
return fmt.Errorf("Error reading Lake Formation Policy Tag: %s", err.Error())
103+
return fmt.Errorf("Error reading Lake Formation LF-Tag: %s", err.Error())
104104
}
105105

106106
d.Set("key", output.TagKey)
@@ -110,10 +110,10 @@ func resourceAwsLakeFormationPolicyTagRead(d *schema.ResourceData, meta interfac
110110
return nil
111111
}
112112

113-
func resourceAwsLakeFormationPolicyTagUpdate(d *schema.ResourceData, meta interface{}) error {
113+
func resourceAwsLakeFormationLFTagUpdate(d *schema.ResourceData, meta interface{}) error {
114114
conn := meta.(*AWSClient).lakeformationconn
115115

116-
catalogID, tagKey, err := readPolicyTagID(d.Id())
116+
catalogID, tagKey, err := readLFTagID(d.Id())
117117
if err != nil {
118118
return err
119119
}
@@ -139,16 +139,16 @@ func resourceAwsLakeFormationPolicyTagUpdate(d *schema.ResourceData, meta interf
139139

140140
_, err = conn.UpdateLFTag(input)
141141
if err != nil {
142-
return fmt.Errorf("Error updating Lake Formation Policy Tag (%s): %w", d.Id(), err)
142+
return fmt.Errorf("Error updating Lake Formation LF-Tag (%s): %w", d.Id(), err)
143143
}
144144

145-
return resourceAwsLakeFormationPolicyTagRead(d, meta)
145+
return resourceAwsLakeFormationLFTagRead(d, meta)
146146
}
147147

148-
func resourceAwsLakeFormationPolicyTagDelete(d *schema.ResourceData, meta interface{}) error {
148+
func resourceAwsLakeFormationLFTagDelete(d *schema.ResourceData, meta interface{}) error {
149149
conn := meta.(*AWSClient).lakeformationconn
150150

151-
catalogID, tagKey, err := readPolicyTagID(d.Id())
151+
catalogID, tagKey, err := readLFTagID(d.Id())
152152
if err != nil {
153153
return err
154154
}
@@ -160,21 +160,21 @@ func resourceAwsLakeFormationPolicyTagDelete(d *schema.ResourceData, meta interf
160160

161161
_, err = conn.DeleteLFTag(input)
162162
if err != nil {
163-
return fmt.Errorf("Error deleting Lake Formation Policy Tag (%s): %w", d.Id(), err)
163+
return fmt.Errorf("Error deleting Lake Formation LF-Tag (%s): %w", d.Id(), err)
164164
}
165165

166166
return nil
167167
}
168168

169-
func readPolicyTagID(id string) (catalogID string, tagKey string, err error) {
169+
func readLFTagID(id string) (catalogID string, tagKey string, err error) {
170170
idParts := strings.Split(id, ":")
171171
if len(idParts) != 2 {
172172
return "", "", fmt.Errorf("Unexpected format of ID (%q), expected CATALOG-ID:TAG-KEY", id)
173173
}
174174
return idParts[0], idParts[1], nil
175175
}
176176

177-
func validatePolicyTagValues() schema.SchemaValidateFunc {
177+
func validateLFTagValues() schema.SchemaValidateFunc {
178178
return validation.All(
179179
validation.StringLenBetween(1, 255),
180180
validation.StringMatch(regexp.MustCompile(`^([\p{L}\p{Z}\p{N}_.:\*\/=+\-@%]*)$`), ""),

aws/resource_aws_lakeformation_policy_tag_test.go renamed to aws/resource_aws_lakeformation_lf_tag_test.go

+28-28
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,20 @@ import (
1313
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
1414
)
1515

16-
func testAccAWSLakeFormationPolicyTag_basic(t *testing.T) {
17-
resourceName := "aws_lakeformation_policy_tag.test"
16+
func testAccAWSLakeFormationLFTag_basic(t *testing.T) {
17+
resourceName := "aws_lakeformation_lf_tag.test"
1818
rKey := acctest.RandomWithPrefix("tf-acc-test")
1919

2020
resource.Test(t, resource.TestCase{
2121
PreCheck: func() { testAccPreCheck(t); testAccPartitionHasServicePreCheck(lakeformation.EndpointsID, t) },
2222
ErrorCheck: testAccErrorCheck(t, lakeformation.EndpointsID),
2323
Providers: testAccProviders,
24-
CheckDestroy: testAccCheckAWSLakeFormationPolicyTagsDestroy,
24+
CheckDestroy: testAccCheckAWSLakeFormationLFTagsDestroy,
2525
Steps: []resource.TestStep{
2626
{
27-
Config: testAccAWSLakeFormationPolicyTagConfig_basic(rKey),
27+
Config: testAccAWSLakeFormationLFTagConfig_basic(rKey),
2828
Check: resource.ComposeTestCheckFunc(
29-
testAccCheckAWSLakeFormationPolicyTagExists(resourceName),
29+
testAccCheckAWSLakeFormationLFTagExists(resourceName),
3030
resource.TestCheckResourceAttr(resourceName, "key", rKey),
3131
resource.TestCheckResourceAttr(resourceName, "values.0", "value"),
3232
testAccCheckResourceAttrAccountID(resourceName, "catalog_id"),
@@ -41,43 +41,43 @@ func testAccAWSLakeFormationPolicyTag_basic(t *testing.T) {
4141
})
4242
}
4343

44-
func testAccAWSLakeFormationPolicyTag_disappears(t *testing.T) {
45-
resourceName := "aws_lakeformation_policy_tag.test"
44+
func testAccAWSLakeFormationLFTag_disappears(t *testing.T) {
45+
resourceName := "aws_lakeformation_lf_tag.test"
4646
rKey := acctest.RandomWithPrefix("tf-acc-test")
4747

4848
resource.ParallelTest(t, resource.TestCase{
4949
PreCheck: func() { testAccPreCheck(t); testAccPartitionHasServicePreCheck(lakeformation.EndpointsID, t) },
5050
ErrorCheck: testAccErrorCheck(t, lakeformation.EndpointsID),
5151
Providers: testAccProviders,
52-
CheckDestroy: testAccCheckAWSLakeFormationPolicyTagsDestroy,
52+
CheckDestroy: testAccCheckAWSLakeFormationLFTagsDestroy,
5353
Steps: []resource.TestStep{
5454
{
55-
Config: testAccAWSLakeFormationPolicyTagConfig_basic(rKey),
55+
Config: testAccAWSLakeFormationLFTagConfig_basic(rKey),
5656
Check: resource.ComposeTestCheckFunc(
57-
testAccCheckAWSLakeFormationPolicyTagExists(resourceName),
58-
testAccCheckResourceDisappears(testAccProvider, resourceAwsLakeFormationPolicyTag(), resourceName),
57+
testAccCheckAWSLakeFormationLFTagExists(resourceName),
58+
testAccCheckResourceDisappears(testAccProvider, resourceAwsLakeFormationLFTag(), resourceName),
5959
),
6060
ExpectNonEmptyPlan: true,
6161
},
6262
},
6363
})
6464
}
6565

66-
func testAccAWSLakeFormationPolicyTag_values(t *testing.T) {
67-
resourceName := "aws_lakeformation_policy_tag.test"
66+
func testAccAWSLakeFormationLFTag_values(t *testing.T) {
67+
resourceName := "aws_lakeformation_lf_tag.test"
6868
rKey := acctest.RandomWithPrefix("tf-acc-test")
6969

7070
resource.Test(t, resource.TestCase{
7171
PreCheck: func() { testAccPreCheck(t); testAccPartitionHasServicePreCheck(lakeformation.EndpointsID, t) },
7272
ErrorCheck: testAccErrorCheck(t, lakeformation.EndpointsID),
7373
Providers: testAccProviders,
74-
CheckDestroy: testAccCheckAWSLakeFormationPolicyTagsDestroy,
74+
CheckDestroy: testAccCheckAWSLakeFormationLFTagsDestroy,
7575
Steps: []resource.TestStep{
7676
{
77-
Config: testAccAWSLakeFormationPolicyTagConfig_values(rKey, []string{"value1", "value2"}),
77+
Config: testAccAWSLakeFormationLFTagConfig_values(rKey, []string{"value1", "value2"}),
7878
Destroy: false,
7979
Check: resource.ComposeTestCheckFunc(
80-
testAccCheckAWSLakeFormationPolicyTagExists(resourceName),
80+
testAccCheckAWSLakeFormationLFTagExists(resourceName),
8181
resource.TestCheckResourceAttr(resourceName, "key", rKey),
8282
resource.TestCheckResourceAttr(resourceName, "values.0", "value1"),
8383
testAccCheckResourceAttrAccountID(resourceName, "catalog_id"),
@@ -90,9 +90,9 @@ func testAccAWSLakeFormationPolicyTag_values(t *testing.T) {
9090
},
9191
{
9292
// Test an update that adds, removes and retains a tag value
93-
Config: testAccAWSLakeFormationPolicyTagConfig_values(rKey, []string{"value1", "value3"}),
93+
Config: testAccAWSLakeFormationLFTagConfig_values(rKey, []string{"value1", "value3"}),
9494
Check: resource.ComposeTestCheckFunc(
95-
testAccCheckAWSLakeFormationPolicyTagExists(resourceName),
95+
testAccCheckAWSLakeFormationLFTagExists(resourceName),
9696
resource.TestCheckResourceAttr(resourceName, "key", rKey),
9797
resource.TestCheckResourceAttr(resourceName, "values.0", "value1"),
9898
resource.TestCheckResourceAttr(resourceName, "values.1", "value3"),
@@ -103,15 +103,15 @@ func testAccAWSLakeFormationPolicyTag_values(t *testing.T) {
103103
})
104104
}
105105

106-
func testAccCheckAWSLakeFormationPolicyTagsDestroy(s *terraform.State) error {
106+
func testAccCheckAWSLakeFormationLFTagsDestroy(s *terraform.State) error {
107107
conn := testAccProvider.Meta().(*AWSClient).lakeformationconn
108108

109109
for _, rs := range s.RootModule().Resources {
110-
if rs.Type != "aws_lakeformation_policy_tag" {
110+
if rs.Type != "aws_lakeformation_lf_tag" {
111111
continue
112112
}
113113

114-
catalogID, tagKey, err := readPolicyTagID(rs.Primary.ID)
114+
catalogID, tagKey, err := readLFTagID(rs.Primary.ID)
115115
if err != nil {
116116
return err
117117
}
@@ -131,13 +131,13 @@ func testAccCheckAWSLakeFormationPolicyTagsDestroy(s *terraform.State) error {
131131
}
132132
return err
133133
}
134-
return fmt.Errorf("Lake Formation Policy Tag (%s) still exists", rs.Primary.ID)
134+
return fmt.Errorf("Lake Formation LF-Tag (%s) still exists", rs.Primary.ID)
135135
}
136136

137137
return nil
138138
}
139139

140-
func testAccCheckAWSLakeFormationPolicyTagExists(name string) resource.TestCheckFunc {
140+
func testAccCheckAWSLakeFormationLFTagExists(name string) resource.TestCheckFunc {
141141
return func(s *terraform.State) error {
142142
rs, ok := s.RootModule().Resources[name]
143143
if !ok {
@@ -148,7 +148,7 @@ func testAccCheckAWSLakeFormationPolicyTagExists(name string) resource.TestCheck
148148
return fmt.Errorf("No ID is set")
149149
}
150150

151-
catalogID, tagKey, err := readPolicyTagID(rs.Primary.ID)
151+
catalogID, tagKey, err := readLFTagID(rs.Primary.ID)
152152
if err != nil {
153153
return err
154154
}
@@ -169,15 +169,15 @@ func testAccCheckAWSLakeFormationPolicyTagExists(name string) resource.TestCheck
169169
}
170170
}
171171

172-
func testAccAWSLakeFormationPolicyTagConfig_basic(rKey string) string {
172+
func testAccAWSLakeFormationLFTagConfig_basic(rKey string) string {
173173
return fmt.Sprintf(`
174174
data "aws_caller_identity" "current" {}
175175
176176
resource "aws_lakeformation_data_lake_settings" "test" {
177177
admins = [data.aws_caller_identity.current.arn]
178178
}
179179
180-
resource "aws_lakeformation_policy_tag" "test" {
180+
resource "aws_lakeformation_lf_tag" "test" {
181181
key = %[1]q
182182
values = ["value"]
183183
@@ -187,7 +187,7 @@ resource "aws_lakeformation_policy_tag" "test" {
187187
`, rKey)
188188
}
189189

190-
func testAccAWSLakeFormationPolicyTagConfig_values(rKey string, values []string) string {
190+
func testAccAWSLakeFormationLFTagConfig_values(rKey string, values []string) string {
191191
quotedValues := make([]string, len(values))
192192
for i, v := range values {
193193
quotedValues[i] = strconv.Quote(v)
@@ -200,7 +200,7 @@ resource "aws_lakeformation_data_lake_settings" "test" {
200200
admins = [data.aws_caller_identity.current.arn]
201201
}
202202
203-
resource "aws_lakeformation_policy_tag" "test" {
203+
resource "aws_lakeformation_lf_tag" "test" {
204204
key = %[1]q
205205
values = [%s]
206206

aws/resource_aws_lakeformation_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ func TestAccAWSLakeFormation_serial(t *testing.T) {
3434
"tableDataSource": testAccAWSLakeFormationPermissionsDataSource_table,
3535
"tableWithColumnsDataSource": testAccAWSLakeFormationPermissionsDataSource_tableWithColumns,
3636
},
37-
"PolicyTag": {
38-
"basic": testAccAWSLakeFormationPolicyTag_basic,
39-
"disappears": testAccAWSLakeFormationPolicyTag_disappears,
40-
"values": testAccAWSLakeFormationPolicyTag_values,
37+
"LFTags": {
38+
"basic": testAccAWSLakeFormationLFTag_basic,
39+
"disappears": testAccAWSLakeFormationLFTag_disappears,
40+
"values": testAccAWSLakeFormationLFTag_values,
4141
},
4242
}
4343

website/docs/r/lakeformation_policy_tag.html.markdown renamed to website/docs/r/lakeformation_lf_tag.html.markdow

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
---
22
subcategory: "Lake Formation"
33
layout: "aws"
4-
page_title: "AWS: aws_lakeformation_policy_tag"
4+
page_title: "AWS: aws_lakeformation_lf_tag"
55
description: |-
66
Creates a tag with the specified name and values.
77
---
88

9-
# Resource: aws_lakeformation_policy_tag
9+
# Resource: aws_lakeformation_lf_tag
1010

11-
Creates a policy tag with the specified name and values. Each key must have at least one value. The maximum number of values permitted is 15.
11+
Creates an LF-Tag with the specified name and values. Each key must have at least one value. The maximum number of values permitted is 15.
1212

1313
## Example Usage
1414

1515
```terraform
16-
resource "aws_lakeformation_policy_tag" "example" {
16+
resource "aws_lakeformation_lf_tag" "example" {
1717
key = "module"
1818
values = ["Orders", "Sales", "Customers"]
1919
}
@@ -35,9 +35,9 @@ In addition to all arguments above, the following attributes are exported:
3535

3636
## Import
3737

38-
Lake Formation Policy Tags can be imported using the `catalog_id:key`. If you have not set a Catalog ID specify the AWS Account ID that the database is in, e.g.
38+
Lake Formation LF-Tags can be imported using the `catalog_id:key`. If you have not set a Catalog ID specify the AWS Account ID that the database is in, e.g.
3939

4040
```
41-
$ terraform import aws_lakeformation_policy_tag.example 123456789012:some_key
41+
$ terraform import aws_lakeformation_lf_tag.example 123456789012:some_key
4242
```
4343

0 commit comments

Comments
 (0)