Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New resource aws_quicksight_folder #30400

Merged
merged 7 commits into from
Apr 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/30400.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:new-resource
aws_quicksight_folder
```
19 changes: 2 additions & 17 deletions internal/service/quicksight/data_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ func ResourceDataSet() *schema.Resource {
"tags": tftags.TagsSchema(),
"tags_all": tftags.TagsSchemaComputed(),
},
CustomizeDiff: verify.SetTagsDiff,
}
}

Expand Down Expand Up @@ -795,7 +796,7 @@ func resourceDataSetCreate(ctx context.Context, d *schema.ResourceData, meta int
}

if v, ok := d.GetOk("permissions"); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil {
input.Permissions = expandDataSetPermissions(v.([]interface{}))
input.Permissions = expandResourcePermissions(v.([]interface{}))
}

if v, ok := d.GetOk("row_level_permission_data_set"); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil {
Expand Down Expand Up @@ -1710,22 +1711,6 @@ func expandDataSetUploadSettings(tfMap map[string]interface{}) *quicksight.Uploa
return uploadSettings
}

func expandDataSetPermissions(tfList []interface{}) []*quicksight.ResourcePermission {
permissions := make([]*quicksight.ResourcePermission, len(tfList))

for i, tfListRaw := range tfList {
tfMap := tfListRaw.(map[string]interface{})

permission := &quicksight.ResourcePermission{
Actions: flex.ExpandStringSet(tfMap["actions"].(*schema.Set)),
Principal: aws.String(tfMap["principal"].(string)),
}

permissions[i] = permission
}
return permissions
}

func expandDataSetRowLevelPermissionDataSet(tfList []interface{}) *quicksight.RowLevelPermissionDataSet {
if len(tfList) == 0 || tfList[0] == nil {
return nil
Expand Down
53 changes: 50 additions & 3 deletions internal/service/quicksight/data_set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ func TestAccQuickSightDataSet_tags(t *testing.T) {
CheckDestroy: testAccCheckDataSetDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccDataSetConfigTags(rId, rName, "key1", "value1"),
Config: testAccDataSetConfigTags1(rId, rName, "key1", "value1"),
Check: resource.ComposeTestCheckFunc(
testAccCheckDataSetExists(ctx, resourceName, &dataSet),
resource.TestCheckResourceAttr(resourceName, "tags.%", "1"),
Expand All @@ -366,6 +366,23 @@ func TestAccQuickSightDataSet_tags(t *testing.T) {
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccDataSetConfigTags2(rId, rName, "key1", "value1updated", "key2", "value2"),
Check: resource.ComposeTestCheckFunc(
testAccCheckDataSetExists(ctx, resourceName, &dataSet),
resource.TestCheckResourceAttr(resourceName, "tags.%", "2"),
resource.TestCheckResourceAttr(resourceName, "tags.key1", "value1updated"),
resource.TestCheckResourceAttr(resourceName, "tags.key2", "value2"),
),
},
{
Config: testAccDataSetConfigTags1(rId, rName, "key2", "value2"),
Check: resource.ComposeTestCheckFunc(
testAccCheckDataSetExists(ctx, resourceName, &dataSet),
resource.TestCheckResourceAttr(resourceName, "tags.%", "1"),
resource.TestCheckResourceAttr(resourceName, "tags.key2", "value2"),
),
},
},
})
}
Expand Down Expand Up @@ -770,7 +787,36 @@ resource "aws_quicksight_data_set" "test" {
`, rId, rName))
}

func testAccDataSetConfigTags(rId, rName, key, value string) string {
func testAccDataSetConfigTags1(rId, rName, key1, value1 string) string {
return acctest.ConfigCompose(
testAccDataSetConfigBase(rId, rName),
fmt.Sprintf(`
resource "aws_quicksight_data_set" "test" {
data_set_id = %[1]q
name = %[2]q
import_mode = "SPICE"

physical_table_map {
physical_table_map_id = %[1]q
s3_source {
data_source_arn = aws_quicksight_data_source.test.arn
input_columns {
name = "Column1"
type = "STRING"
}
upload_settings {
format = "JSON"
}
}
}
tags = {
%[3]q = %[4]q
}
}
`, rId, rName, key1, value1))
}

func testAccDataSetConfigTags2(rId, rName, key1, value1, key2, value2 string) string {
return acctest.ConfigCompose(
testAccDataSetConfigBase(rId, rName),
fmt.Sprintf(`
Expand All @@ -794,7 +840,8 @@ resource "aws_quicksight_data_set" "test" {
}
tags = {
%[3]q = %[4]q
%[5]q = %[6]q
}
}
`, rId, rName, key, value))
`, rId, rName, key1, value1, key2, value2))
}
47 changes: 1 addition & 46 deletions internal/service/quicksight/data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/hashicorp/terraform-provider-aws/internal/conns"
"github.com/hashicorp/terraform-provider-aws/internal/flex"
tftags "github.com/hashicorp/terraform-provider-aws/internal/tags"
"github.com/hashicorp/terraform-provider-aws/internal/verify"
)
Expand Down Expand Up @@ -632,7 +631,7 @@ func resourceDataSourceCreate(ctx context.Context, d *schema.ResourceData, meta
}

if v, ok := d.GetOk("permission"); ok && v.(*schema.Set).Len() > 0 {
params.Permissions = expandDataSourcePermissions(v.(*schema.Set).List())
params.Permissions = expandResourcePermissions(v.(*schema.Set).List())
}

if v, ok := d.GetOk("ssl_properties"); ok && len(v.([]interface{})) != 0 && v.([]interface{})[0] != nil {
Expand Down Expand Up @@ -1274,22 +1273,6 @@ func expandDataSourceParameters(tfList []interface{}) *quicksight.DataSourcePara
return dataSourceParams
}

func expandDataSourcePermissions(tfList []interface{}) []*quicksight.ResourcePermission {
permissions := make([]*quicksight.ResourcePermission, len(tfList))

for i, tfListRaw := range tfList {
tfMap := tfListRaw.(map[string]interface{})
permission := &quicksight.ResourcePermission{
Actions: flex.ExpandStringSet(tfMap["actions"].(*schema.Set)),
Principal: aws.String(tfMap["principal"].(string)),
}

permissions[i] = permission
}

return permissions
}

func expandDataSourceSSLProperties(tfList []interface{}) *quicksight.SslProperties {
if len(tfList) == 0 {
return nil
Expand Down Expand Up @@ -1570,34 +1553,6 @@ func flattenParameters(parameters *quicksight.DataSourceParameters) []interface{
return params
}

func flattenPermissions(perms []*quicksight.ResourcePermission) []interface{} {
if len(perms) == 0 {
return []interface{}{}
}

values := make([]interface{}, 0)

for _, p := range perms {
if p == nil {
continue
}

perm := make(map[string]interface{})

if p.Principal != nil {
perm["principal"] = aws.StringValue(p.Principal)
}

if p.Actions != nil {
perm["actions"] = flex.FlattenStringList(p.Actions)
}

values = append(values, perm)
}

return values
}

func flattenSSLProperties(props *quicksight.SslProperties) []interface{} {
if props == nil {
return []interface{}{}
Expand Down
Loading