Skip to content

Commit 91a8384

Browse files
authored
Merge pull request #26643 from Tonkonozhenko/patch-3
Lakeformation Permissions trigger Force New
2 parents 204da70 + b369b12 commit 91a8384

File tree

6 files changed

+189
-58
lines changed

6 files changed

+189
-58
lines changed

.changelog/26643.txt

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
```release-note:bug
2+
resource/aws_lakeformation_permissions: Change `lf_tag`, `lf_tag.values`, `lf_tag_policy`, `lf_tag_policy.expression.key`, `lf_tag_policy.expression.values` and `lf_tag_policy.resource_type` to [ForceNew](https://developer.hashicorp.com/terraform/plugin/sdkv2/schemas/schema-behaviors#forcenew)
3+
```
4+
5+
```release-note:bug
6+
resource/aws_lakeformation_permissions: Remove limit on number of `lf_tag_policy.expression` blocks
7+
```
8+
9+
```release-note:bug
10+
data-source/aws_lakeformation_permissions: Remove limit on number of `lf_tag_policy.expression` blocks
11+
```
12+
13+
```release-note:bug
14+
resource/aws_lakeformation_permissions: Change `lf_tag_policy.expression` from `TypeList` to `TypeSet` as order is not significant
15+
```
16+
17+
```release-note:bug
18+
data-source/aws_lakeformation_permissions: Change `lf_tag_policy.expression` from `TypeList` to `TypeSet` as order is not significant
19+
```

internal/service/lakeformation/lakeformation_test.go

+9-8
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@ func TestAccLakeFormation_serial(t *testing.T) {
1717
"withoutCatalogId": testAccDataLakeSettings_withoutCatalogID,
1818
},
1919
"PermissionsBasic": {
20-
"basic": testAccPermissions_basic,
21-
"database": testAccPermissions_database,
22-
"databaseIAMAllowed": testAccPermissions_databaseIAMAllowed,
23-
"databaseMultiple": testAccPermissions_databaseMultiple,
24-
"dataLocation": testAccPermissions_dataLocation,
25-
"disappears": testAccPermissions_disappears,
26-
"lfTag": testAccPermissions_lfTag,
27-
"lfTagPolicy": testAccPermissions_lfTagPolicy,
20+
"basic": testAccPermissions_basic,
21+
"database": testAccPermissions_database,
22+
"databaseIAMAllowed": testAccPermissions_databaseIAMAllowed,
23+
"databaseMultiple": testAccPermissions_databaseMultiple,
24+
"dataLocation": testAccPermissions_dataLocation,
25+
"disappears": testAccPermissions_disappears,
26+
"lfTag": testAccPermissions_lfTag,
27+
"lfTagPolicy": testAccPermissions_lfTagPolicy,
28+
"lfTagPolicyMultiple": testAccPermissions_lfTagPolicyMultiple,
2829
},
2930
"PermissionsDataSource": {
3031
"basic": testAccPermissionsDataSource_basic,

internal/service/lakeformation/permissions.go

+15-14
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ func ResourcePermissions() *schema.Resource {
120120
Type: schema.TypeList,
121121
Optional: true,
122122
Computed: true,
123+
ForceNew: true,
123124
MaxItems: 1,
124125
ExactlyOneOf: []string{
125126
"catalog_resource",
@@ -132,6 +133,12 @@ func ResourcePermissions() *schema.Resource {
132133
},
133134
Elem: &schema.Resource{
134135
Schema: map[string]*schema.Schema{
136+
"catalog_id": {
137+
Type: schema.TypeString,
138+
ForceNew: true,
139+
Optional: true,
140+
Computed: true,
141+
},
135142
"key": {
136143
Type: schema.TypeString,
137144
Required: true,
@@ -141,19 +148,13 @@ func ResourcePermissions() *schema.Resource {
141148
"values": {
142149
Type: schema.TypeSet,
143150
Required: true,
151+
ForceNew: true,
144152
MinItems: 1,
145153
MaxItems: 15,
146154
Elem: &schema.Schema{
147155
Type: schema.TypeString,
148156
ValidateFunc: validateLFTagValues(),
149157
},
150-
Set: schema.HashString,
151-
},
152-
"catalog_id": {
153-
Type: schema.TypeString,
154-
ForceNew: true,
155-
Optional: true,
156-
Computed: true,
157158
},
158159
},
159160
},
@@ -162,6 +163,7 @@ func ResourcePermissions() *schema.Resource {
162163
Type: schema.TypeList,
163164
Optional: true,
164165
Computed: true,
166+
ForceNew: true,
165167
MaxItems: 1,
166168
ExactlyOneOf: []string{
167169
"catalog_resource",
@@ -181,34 +183,35 @@ func ResourcePermissions() *schema.Resource {
181183
ValidateFunc: verify.ValidAccountID,
182184
},
183185
"expression": {
184-
Type: schema.TypeList,
186+
Type: schema.TypeSet,
185187
Required: true,
186188
MinItems: 1,
187-
MaxItems: 5,
188189
Elem: &schema.Resource{
189190
Schema: map[string]*schema.Schema{
190191
"key": {
191192
Type: schema.TypeString,
192193
Required: true,
194+
ForceNew: true,
193195
ValidateFunc: validation.StringLenBetween(1, 128),
194196
},
195197
"values": {
196198
Type: schema.TypeSet,
197199
Required: true,
200+
ForceNew: true,
198201
MinItems: 1,
199202
MaxItems: 15,
200203
Elem: &schema.Schema{
201204
Type: schema.TypeString,
202205
ValidateFunc: validateLFTagValues(),
203206
},
204-
Set: schema.HashString,
205207
},
206208
},
207209
},
208210
},
209211
"resource_type": {
210212
Type: schema.TypeString,
211213
Required: true,
214+
ForceNew: true,
212215
ValidateFunc: validation.StringInSlice(lakeformation.ResourceType_Values(), false),
213216
},
214217
},
@@ -320,7 +323,6 @@ func ResourcePermissions() *schema.Resource {
320323
Type: schema.TypeSet,
321324
ForceNew: true,
322325
Optional: true,
323-
Set: schema.HashString,
324326
Elem: &schema.Schema{
325327
Type: schema.TypeString,
326328
ValidateFunc: validation.NoZeroValues,
@@ -339,7 +341,6 @@ func ResourcePermissions() *schema.Resource {
339341
Type: schema.TypeSet,
340342
ForceNew: true,
341343
Optional: true,
342-
Set: schema.HashString,
343344
Elem: &schema.Schema{
344345
Type: schema.TypeString,
345346
ValidateFunc: validation.NoZeroValues,
@@ -888,8 +889,8 @@ func ExpandLFTagPolicyResource(tfMap map[string]interface{}) *lakeformation.LFTa
888889
apiObject.CatalogId = aws.String(v)
889890
}
890891

891-
if v, ok := tfMap["expression"]; ok && v != nil {
892-
apiObject.Expression = ExpandLFTagExpression(v.([]interface{}))
892+
if v, ok := tfMap["expression"].(*schema.Set); ok && v.Len() > 0 {
893+
apiObject.Expression = ExpandLFTagExpression(v.List())
893894
}
894895

895896
if v, ok := tfMap["resource_type"].(string); ok && v != "" {

internal/service/lakeformation/permissions_data_source.go

+20-25
Original file line numberDiff line numberDiff line change
@@ -74,27 +74,18 @@ func DataSourcePermissions() *schema.Resource {
7474
},
7575
},
7676
},
77-
"permissions": {
78-
Type: schema.TypeList,
79-
Computed: true,
80-
Elem: &schema.Schema{
81-
Type: schema.TypeString,
82-
},
83-
},
84-
"permissions_with_grant_option": {
85-
Type: schema.TypeList,
86-
Computed: true,
87-
Elem: &schema.Schema{
88-
Type: schema.TypeString,
89-
},
90-
},
9177
"lf_tag": {
9278
Type: schema.TypeList,
9379
Optional: true,
9480
Computed: true,
9581
MaxItems: 1,
9682
Elem: &schema.Resource{
9783
Schema: map[string]*schema.Schema{
84+
"catalog_id": {
85+
Type: schema.TypeString,
86+
Optional: true,
87+
Computed: true,
88+
},
9889
"key": {
9990
Type: schema.TypeString,
10091
Required: true,
@@ -109,12 +100,6 @@ func DataSourcePermissions() *schema.Resource {
109100
Type: schema.TypeString,
110101
ValidateFunc: validateLFTagValues(),
111102
},
112-
Set: schema.HashString,
113-
},
114-
"catalog_id": {
115-
Type: schema.TypeString,
116-
Optional: true,
117-
Computed: true,
118103
},
119104
},
120105
},
@@ -133,10 +118,9 @@ func DataSourcePermissions() *schema.Resource {
133118
ValidateFunc: verify.ValidAccountID,
134119
},
135120
"expression": {
136-
Type: schema.TypeList,
121+
Type: schema.TypeSet,
137122
Required: true,
138123
MinItems: 1,
139-
MaxItems: 5,
140124
Elem: &schema.Resource{
141125
Schema: map[string]*schema.Schema{
142126
"key": {
@@ -153,7 +137,6 @@ func DataSourcePermissions() *schema.Resource {
153137
Type: schema.TypeString,
154138
ValidateFunc: validateLFTagValues(),
155139
},
156-
Set: schema.HashString,
157140
},
158141
},
159142
},
@@ -166,6 +149,20 @@ func DataSourcePermissions() *schema.Resource {
166149
},
167150
},
168151
},
152+
"permissions": {
153+
Type: schema.TypeList,
154+
Computed: true,
155+
Elem: &schema.Schema{
156+
Type: schema.TypeString,
157+
},
158+
},
159+
"permissions_with_grant_option": {
160+
Type: schema.TypeList,
161+
Computed: true,
162+
Elem: &schema.Schema{
163+
Type: schema.TypeString,
164+
},
165+
},
169166
"principal": {
170167
Type: schema.TypeString,
171168
Required: true,
@@ -217,7 +214,6 @@ func DataSourcePermissions() *schema.Resource {
217214
"column_names": {
218215
Type: schema.TypeSet,
219216
Optional: true,
220-
Set: schema.HashString,
221217
Elem: &schema.Schema{
222218
Type: schema.TypeString,
223219
ValidateFunc: validation.NoZeroValues,
@@ -230,7 +226,6 @@ func DataSourcePermissions() *schema.Resource {
230226
"excluded_column_names": {
231227
Type: schema.TypeSet,
232228
Optional: true,
233-
Set: schema.HashString,
234229
Elem: &schema.Schema{
235230
Type: schema.TypeString,
236231
ValidateFunc: validation.NoZeroValues,

internal/service/lakeformation/permissions_data_source_test.go

-5
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,6 @@ resource "aws_s3_bucket" "test" {
283283
force_destroy = true
284284
}
285285
286-
resource "aws_s3_bucket_acl" "test" {
287-
bucket = aws_s3_bucket.test.id
288-
acl = "private"
289-
}
290-
291286
resource "aws_lakeformation_resource" "test" {
292287
arn = aws_s3_bucket.test.arn
293288
}

0 commit comments

Comments
 (0)