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

[BugFix] Set all parameters to update aws_quicksight_data_source #33061

Merged
Show file tree
Hide file tree
Changes from 2 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/33061.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_quicksight_data_source: Set all parameters to update aws_quicksight_data_source
```
16 changes: 8 additions & 8 deletions internal/service/quicksight/data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -739,20 +739,20 @@ func resourceDataSourceUpdate(ctx context.Context, d *schema.ResourceData, meta
Name: aws.String(d.Get("name").(string)),
}

if d.HasChange("credentials") {
params.Credentials = expandDataSourceCredentials(d.Get("credentials").([]interface{}))
if v, ok := d.GetOk("parameters"); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil {
params.DataSourceParameters = expandDataSourceParameters(v.([]interface{}))
}

if d.HasChange("parameters") {
params.DataSourceParameters = expandDataSourceParameters(d.Get("parameters").([]interface{}))
if v, ok := d.GetOk("credentials"); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil {
params.Credentials = expandDataSourceCredentials(v.([]interface{}))
}

if d.HasChange("ssl_properties") {
params.SslProperties = expandDataSourceSSLProperties(d.Get("ssl_properties").([]interface{}))
if v, ok := d.GetOk("ssl_properties"); ok && len(v.([]interface{})) != 0 && v.([]interface{})[0] != nil {
params.SslProperties = expandDataSourceSSLProperties(v.([]interface{}))
}

if d.HasChange("vpc_connection_properties") {
params.VpcConnectionProperties = expandDataSourceVPCConnectionProperties(d.Get("vpc_connection_properties").([]interface{}))
if v, ok := d.GetOk("vpc_connection_properties"); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil {
params.VpcConnectionProperties = expandDataSourceVPCConnectionProperties(v.([]interface{}))
}

_, err = conn.UpdateDataSourceWithContext(ctx, params)
Expand Down
66 changes: 66 additions & 0 deletions internal/service/quicksight/data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,49 @@ func TestAccQuickSightDataSource_permissions(t *testing.T) {
})
}

func TestAccQuickSightDataSource_name(t *testing.T) {
ctx := acctest.Context(t)
var dataSource quicksight.DataSource
resourceName := "aws_quicksight_data_source.test"
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
rId := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(ctx, t) },
ErrorCheck: acctest.ErrorCheck(t, quicksight.EndpointsID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckDataSourceDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccDataSourceConfig_basic(rId, rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckDataSourceExists(ctx, resourceName, &dataSource),
resource.TestCheckResourceAttr(resourceName, "name", rName),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccDataSourceConfig_updateName(rId, rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckDataSourceExists(ctx, resourceName, &dataSource),
resource.TestCheckResourceAttr(resourceName, "name", "updated-name"),
resource.TestCheckResourceAttr(resourceName, "parameters.#", "1"),
resource.TestCheckResourceAttr(resourceName, "parameters.0.s3.#", "1"),
resource.TestCheckResourceAttr(resourceName, "parameters.0.s3.0.manifest_file_location.#", "1"),
resource.TestCheckResourceAttr(resourceName, "parameters.0.s3.0.manifest_file_location.0.bucket", rName),
resource.TestCheckResourceAttr(resourceName, "parameters.0.s3.0.manifest_file_location.0.key", rName),
resource.TestCheckResourceAttr(resourceName, "type", quicksight.DataSourceTypeS3),
resource.TestCheckResourceAttr(resourceName, "tags.%", "0"),
),
},
},
})
}

func testAccCheckDataSourceExists(ctx context.Context, resourceName string, dataSource *quicksight.DataSource) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[resourceName]
Expand Down Expand Up @@ -503,3 +546,26 @@ resource "aws_quicksight_data_source" "test" {
}
`, rId, rName))
}

func testAccDataSourceConfig_updateName(rId, rName string) string {
return acctest.ConfigCompose(
testAccBaseDataSourceConfig(rName),
testAccDataSource_UserConfig(rName),
fmt.Sprintf(`
resource "aws_quicksight_data_source" "test" {
data_source_id = %[1]q
name = "updated-name"

parameters {
s3 {
manifest_file_location {
bucket = aws_s3_bucket.test.bucket
key = aws_s3_object.test.key
}
}
}

type = "S3"
}
`, rId))
}