Skip to content

Commit

Permalink
Merge pull request #36341 from acwwat/b-aws_ecs_cluster-fix_empty_blo…
Browse files Browse the repository at this point in the history
…ck_nil_crashes

fix: Add nil check for empty blocks to fix crashes for aws_ecs_cluster
  • Loading branch information
ewbankkit authored Mar 13, 2024
2 parents cd5f213 + 53e2a39 commit 5a6965b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 7 additions & 0 deletions .changelog/36341.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
```release-note:bug
resource/aws_ecs_cluster: Fix `panic: interface conversion: interface {} is nil, not map[string]interface {}` when `configuration`, `configuration.execute_command_configuration`, or `configuration.execute_command_configuration.log_configuration` are empty
```

```release-note:enhancement
resource/aws_ecs_cluster: Add default value (`DEFAULT`) for `configuration.execute_command_configuration.logging`
```
7 changes: 4 additions & 3 deletions internal/service/ecs/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ func ResourceCluster() *schema.Resource {
"logging": {
Type: schema.TypeString,
Optional: true,
Default: ecs.ExecuteCommandLoggingDefault,
ValidateFunc: validation.StringInSlice(ecs.ExecuteCommandLogging_Values(), false),
},
},
Expand Down Expand Up @@ -576,7 +577,7 @@ func flattenClusterConfigurationExecuteCommandConfigurationLogConfiguration(apiO
}

func expandClusterConfiguration(nc []interface{}) *ecs.ClusterConfiguration {
if len(nc) == 0 {
if len(nc) == 0 || nc[0] == nil {
return &ecs.ClusterConfiguration{}
}
raw := nc[0].(map[string]interface{})
Expand All @@ -590,7 +591,7 @@ func expandClusterConfiguration(nc []interface{}) *ecs.ClusterConfiguration {
}

func expandClusterConfigurationExecuteCommandConfiguration(nc []interface{}) *ecs.ExecuteCommandConfiguration {
if len(nc) == 0 {
if len(nc) == 0 || nc[0] == nil {
return &ecs.ExecuteCommandConfiguration{}
}
raw := nc[0].(map[string]interface{})
Expand All @@ -612,7 +613,7 @@ func expandClusterConfigurationExecuteCommandConfiguration(nc []interface{}) *ec
}

func expandClusterConfigurationExecuteCommandLogConfiguration(nc []interface{}) *ecs.ExecuteCommandLogConfiguration {
if len(nc) == 0 {
if len(nc) == 0 || nc[0] == nil {
return &ecs.ExecuteCommandLogConfiguration{}
}
raw := nc[0].(map[string]interface{})
Expand Down

0 comments on commit 5a6965b

Please sign in to comment.