Skip to content

Commit 65dad82

Browse files
authored
Merge pull request #43613 from hashicorp/f-r/aws_quicksight_custom_permissions
QuickSight custom permissions
2 parents e973a0b + 0739855 commit 65dad82

File tree

63 files changed

+4850
-698
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+4850
-698
lines changed

.changelog/43613.txt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
```release-note:new-resource
2+
aws_quicksight_custom_permissions
3+
```
4+
5+
```release-note:new-resource
6+
aws_quicksight_role_custom_permission
7+
```
8+
9+
```release-note:new-resource
10+
aws_quicksight_user_custom_permission
11+
```
12+
13+
```release-note:enhancement
14+
resource/aws_quicksight_user: Change `user_name` to Optional and Computed
15+
```
16+
17+
```release-note:enhancement
18+
resource/aws_quicksight_user: Support `IAM_IDENTITY_CENTER` as a valid value for `identity_type`
19+
```
20+
21+
```release-note:enhancement
22+
resource/aws_quicksight_user: Support `RESTRICTED_AUTHOR` and `RESTRICTED_READER` as valid values for `user_role`
23+
```
24+
25+
```release-note:enhancement
26+
resource/aws_quicksight_user: Add plan-time validation of `iam_arn`
27+
```
28+
29+
```release-note:enhancement
30+
data-source/aws_quicksight_user: Add `custom_permissions_name` attribute
31+
```

internal/acctest/state_id.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ package acctest
55

66
import (
77
"fmt"
8+
"strings"
89

910
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
1011
"github.com/hashicorp/terraform-plugin-testing/terraform"
12+
tfslices "github.com/hashicorp/terraform-provider-aws/internal/slices"
1113
"github.com/hashicorp/terraform-provider-aws/names"
1214
)
1315

@@ -23,6 +25,20 @@ func AttrImportStateIdFunc(resourceName, attrName string) resource.ImportStateId
2325
}
2426
}
2527

28+
// AttrsImportStateIdFunc is a resource.ImportStateIdFunc that returns the values of the specified attributes concatenated with a separator
29+
func AttrsImportStateIdFunc(resourceName, sep string, attrNames ...string) resource.ImportStateIdFunc {
30+
return func(s *terraform.State) (string, error) {
31+
rs, ok := s.RootModule().Resources[resourceName]
32+
if !ok {
33+
return "", fmt.Errorf("Not found: %s", resourceName)
34+
}
35+
36+
return strings.Join(tfslices.ApplyToAll(attrNames, func(attrName string) string {
37+
return rs.Primary.Attributes[attrName]
38+
}), sep), nil
39+
}
40+
}
41+
2642
// CrossRegionAttrImportStateIdFunc is a resource.ImportStateIdFunc that returns the value
2743
// of the specified attribute and appends the region
2844
func CrossRegionAttrImportStateIdFunc(resourceName, attrName string) resource.ImportStateIdFunc {

internal/service/quicksight/account_settings.go

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,13 @@ import (
1616
"github.com/hashicorp/terraform-plugin-framework/resource"
1717
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
1818
"github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault"
19-
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
20-
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault"
21-
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
22-
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
2319
"github.com/hashicorp/terraform-plugin-framework/types"
2420
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
2521
"github.com/hashicorp/terraform-provider-aws/internal/errs"
2622
"github.com/hashicorp/terraform-provider-aws/internal/errs/fwdiag"
2723
"github.com/hashicorp/terraform-provider-aws/internal/framework"
2824
fwflex "github.com/hashicorp/terraform-provider-aws/internal/framework/flex"
29-
fwvalidators "github.com/hashicorp/terraform-provider-aws/internal/framework/validators"
25+
quicksightschema "github.com/hashicorp/terraform-provider-aws/internal/service/quicksight/schema"
3026
"github.com/hashicorp/terraform-provider-aws/internal/tfresource"
3127
"github.com/hashicorp/terraform-provider-aws/names"
3228
)
@@ -55,25 +51,8 @@ type accountSettingsResource struct {
5551
func (r *accountSettingsResource) Schema(ctx context.Context, request resource.SchemaRequest, response *resource.SchemaResponse) {
5652
response.Schema = schema.Schema{
5753
Attributes: map[string]schema.Attribute{
58-
names.AttrAWSAccountID: schema.StringAttribute{
59-
Optional: true,
60-
Computed: true,
61-
Validators: []validator.String{
62-
fwvalidators.AWSAccountID(),
63-
},
64-
PlanModifiers: []planmodifier.String{
65-
stringplanmodifier.UseStateForUnknown(),
66-
stringplanmodifier.RequiresReplace(),
67-
},
68-
},
69-
"default_namespace": schema.StringAttribute{
70-
Optional: true,
71-
Computed: true,
72-
Default: stringdefault.StaticString("default"),
73-
PlanModifiers: []planmodifier.String{
74-
stringplanmodifier.RequiresReplace(),
75-
},
76-
},
54+
names.AttrAWSAccountID: quicksightschema.AWSAccountIDAttribute(),
55+
"default_namespace": quicksightschema.NamespaceAttribute(),
7756
"termination_protection_enabled": schema.BoolAttribute{
7857
Optional: true,
7958
Computed: true,
@@ -95,7 +74,9 @@ func (r *accountSettingsResource) Create(ctx context.Context, request resource.C
9574
if response.Diagnostics.HasError() {
9675
return
9776
}
98-
data.AWSAccountID = types.StringValue(r.Meta().AccountID(ctx))
77+
if data.AWSAccountID.IsUnknown() {
78+
data.AWSAccountID = fwflex.StringValueToFramework(ctx, r.Meta().AccountID(ctx))
79+
}
9980

10081
conn := r.Meta().QuickSightClient(ctx)
10182

internal/service/quicksight/account_settings_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/hashicorp/terraform-plugin-testing/terraform"
1515
"github.com/hashicorp/terraform-plugin-testing/tfjsonpath"
1616
"github.com/hashicorp/terraform-provider-aws/internal/acctest"
17+
tfquicksight "github.com/hashicorp/terraform-provider-aws/internal/service/quicksight"
1718
"github.com/hashicorp/terraform-provider-aws/names"
1819
)
1920

@@ -42,7 +43,7 @@ func testAccAccountSettings_basic(t *testing.T) {
4243
},
4344
ConfigStateChecks: []statecheck.StateCheck{
4445
statecheck.ExpectKnownValue(resourceName, tfjsonpath.New(names.AttrAWSAccountID), knownvalue.NotNull()),
45-
statecheck.ExpectKnownValue(resourceName, tfjsonpath.New("default_namespace"), knownvalue.StringExact("default")),
46+
statecheck.ExpectKnownValue(resourceName, tfjsonpath.New("default_namespace"), knownvalue.StringExact(tfquicksight.DefaultNamespace)),
4647
statecheck.ExpectKnownValue(resourceName, tfjsonpath.New("termination_protection_enabled"), knownvalue.Bool(false)),
4748
},
4849
},

internal/service/quicksight/account_subscription.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ import (
1919
"github.com/hashicorp/terraform-provider-aws/internal/errs"
2020
"github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag"
2121
"github.com/hashicorp/terraform-provider-aws/internal/flex"
22+
quicksightschema "github.com/hashicorp/terraform-provider-aws/internal/service/quicksight/schema"
2223
"github.com/hashicorp/terraform-provider-aws/internal/tfresource"
23-
"github.com/hashicorp/terraform-provider-aws/internal/verify"
2424
"github.com/hashicorp/terraform-provider-aws/names"
2525
)
2626

@@ -77,13 +77,7 @@ func resourceAccountSubscription() *schema.Resource {
7777
Elem: &schema.Schema{Type: schema.TypeString},
7878
ForceNew: true,
7979
},
80-
names.AttrAWSAccountID: {
81-
Type: schema.TypeString,
82-
Optional: true,
83-
Computed: true,
84-
ForceNew: true,
85-
ValidateFunc: verify.ValidAccountID,
86-
},
80+
names.AttrAWSAccountID: quicksightschema.AWSAccountIDSchema(),
8781
"contact_number": {
8882
Type: schema.TypeString,
8983
Optional: true,

internal/service/quicksight/account_subscription_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,9 @@ func testAccCheckAccountSubscriptionDisableTerminationProtection(ctx context.Con
125125

126126
conn := acctest.Provider.Meta().(*conns.AWSClient).QuickSightClient(ctx)
127127

128-
defaultNs := "default"
129128
input := &quicksight.UpdateAccountSettingsInput{
130129
AwsAccountId: aws.String(rs.Primary.ID),
131-
DefaultNamespace: aws.String(defaultNs),
130+
DefaultNamespace: aws.String(tfquicksight.DefaultNamespace),
132131
TerminationProtectionEnabled: false,
133132
}
134133

internal/service/quicksight/analysis.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
tfslices "github.com/hashicorp/terraform-provider-aws/internal/slices"
2727
tftags "github.com/hashicorp/terraform-provider-aws/internal/tags"
2828
"github.com/hashicorp/terraform-provider-aws/internal/tfresource"
29-
"github.com/hashicorp/terraform-provider-aws/internal/verify"
3029
"github.com/hashicorp/terraform-provider-aws/names"
3130
)
3231

@@ -65,13 +64,7 @@ func resourceAnalysis() *schema.Resource {
6564
Type: schema.TypeString,
6665
Computed: true,
6766
},
68-
names.AttrAWSAccountID: {
69-
Type: schema.TypeString,
70-
Optional: true,
71-
Computed: true,
72-
ForceNew: true,
73-
ValidateFunc: verify.ValidAccountID,
74-
},
67+
names.AttrAWSAccountID: quicksightschema.AWSAccountIDSchema(),
7568
names.AttrCreatedTime: {
7669
Type: schema.TypeString,
7770
Computed: true,

internal/service/quicksight/analysis_data_source.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag"
1414
quicksightschema "github.com/hashicorp/terraform-provider-aws/internal/service/quicksight/schema"
1515
tftags "github.com/hashicorp/terraform-provider-aws/internal/tags"
16-
"github.com/hashicorp/terraform-provider-aws/internal/verify"
1716
"github.com/hashicorp/terraform-provider-aws/names"
1817
)
1918

@@ -33,12 +32,7 @@ func dataSourceAnalysis() *schema.Resource {
3332
Type: schema.TypeString,
3433
Computed: true,
3534
},
36-
names.AttrAWSAccountID: {
37-
Type: schema.TypeString,
38-
Optional: true,
39-
Computed: true,
40-
ValidateFunc: verify.ValidAccountID,
41-
},
35+
names.AttrAWSAccountID: quicksightschema.AWSAccountIDDataSourceSchema(),
4236
names.AttrCreatedTime: {
4337
Type: schema.TypeString,
4438
Computed: true,

0 commit comments

Comments
 (0)