Skip to content

Commit

Permalink
r/aws_grafana_workspace: fix expander panics
Browse files Browse the repository at this point in the history
The expanders for the `network_access_control` and `vpc_configuration` arguments did not check for a list of one nil item, resulting in a failed type assertion and panic when a single, empty configuration is provided.

```console
% make testacc PKG=grafana TESTS=TestAccGrafana_serial/Workspace
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.22.6 test ./internal/service/grafana/... -v -count 1 -parallel 20 -run='TestAccGrafana_serial/Workspace'  -timeout 360m

--- PASS: TestAccGrafana_serial (6114.72s)
    --- PASS: TestAccGrafana_serial/Workspace (6114.72s)
        --- PASS: TestAccGrafana_serial/Workspace/saml (350.87s)
        --- PASS: TestAccGrafana_serial/Workspace/permissionType (402.51s)
        --- PASS: TestAccGrafana_serial/Workspace/tags (371.33s)
        --- PASS: TestAccGrafana_serial/Workspace/configuration (675.03s)
        --- PASS: TestAccGrafana_serial/Workspace/networkAccess (709.10s)
        --- SKIP: TestAccGrafana_serial/Workspace/sso (0.57s)
        --- PASS: TestAccGrafana_serial/Workspace/disappears (416.76s)
        --- SKIP: TestAccGrafana_serial/Workspace/organization (0.89s)
        --- PASS: TestAccGrafana_serial/Workspace/dataSources (347.22s)
        --- PASS: TestAccGrafana_serial/Workspace/notificationDestinations (397.44s)
        --- PASS: TestAccGrafana_serial/Workspace/vpc (1222.79s)
        --- PASS: TestAccGrafana_serial/Workspace/version (1220.20s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/grafana    6120.565s
```
  • Loading branch information
jar-b committed Aug 8, 2024
1 parent e22df1a commit e279605
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changelog/38775.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
```release-note:bug
resource/aws_grafana_workspace: Fix crash when empty `network_access_control` block is configured
```
```release-note:bug
resource/aws_grafana_workspace: Fix crash when empty `vpc_configuration` block is configured
```
4 changes: 2 additions & 2 deletions internal/service/grafana/workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ func waitWorkspaceDeleted(ctx context.Context, conn *grafana.Client, id string,
}

func expandVPCConfiguration(tfList []interface{}) *awstypes.VpcConfiguration {
if len(tfList) < 1 {
if len(tfList) == 0 || tfList[0] == nil {
return nil
}

Expand Down Expand Up @@ -581,7 +581,7 @@ func flattenVPCConfiguration(apiObject *awstypes.VpcConfiguration) []interface{}
}

func expandNetworkAccessControl(tfList []interface{}) *awstypes.NetworkAccessConfiguration {
if len(tfList) < 1 {
if len(tfList) == 0 || tfList[0] == nil {
return nil
}

Expand Down

0 comments on commit e279605

Please sign in to comment.