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

r/aws_msk_cluster: Fix crash when tls configuration block is empty #25072

Merged
merged 3 commits into from
May 27, 2022
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/25072.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_msk_cluster: Prevent crash on apply when `client_authentication.tls` is empty
```
2 changes: 1 addition & 1 deletion docs/contributing/data-handling-and-conversion.md
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ To read:
func expandStructure(tfMap map[string]interface{}) *service.Structure {
// ...

if v, ok := tfMap["nested_attribute_name"].([]interface{}); ok && len(v) > 0 {
if v, ok := tfMap["nested_attribute_name"].([]interface{}); ok && len(v) > 0 && v[0] != nil {
apiObject.NestedAttributeName = expandStructure(v[0].(map[string]interface{}))
}

Expand Down
30 changes: 15 additions & 15 deletions internal/service/kafka/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,7 @@ func expandBrokerNodeGroupInfo(tfMap map[string]interface{}) *kafka.BrokerNodeGr
apiObject.ClientSubnets = flex.ExpandStringSet(v)
}

if v, ok := tfMap["connectivity_info"].([]interface{}); ok && len(v) > 0 {
if v, ok := tfMap["connectivity_info"].([]interface{}); ok && len(v) > 0 && v[0] != nil {
apiObject.ConnectivityInfo = expandConnectivityInfo(v[0].(map[string]interface{}))
}

Expand All @@ -993,7 +993,7 @@ func expandBrokerNodeGroupInfo(tfMap map[string]interface{}) *kafka.BrokerNodeGr
}
}

if v, ok := tfMap["storage_info"].([]interface{}); ok && len(v) > 0 {
if v, ok := tfMap["storage_info"].([]interface{}); ok && len(v) > 0 && v[0] != nil {
apiObject.StorageInfo = expandStorageInfo(v[0].(map[string]interface{}))
}

Expand All @@ -1007,7 +1007,7 @@ func expandConnectivityInfo(tfMap map[string]interface{}) *kafka.ConnectivityInf

apiObject := &kafka.ConnectivityInfo{}

if v, ok := tfMap["public_access"].([]interface{}); ok && len(v) > 0 {
if v, ok := tfMap["public_access"].([]interface{}); ok && len(v) > 0 && v[0] != nil {
apiObject.PublicAccess = expandPublicAccess(v[0].(map[string]interface{}))
}

Expand All @@ -1021,7 +1021,7 @@ func expandStorageInfo(tfMap map[string]interface{}) *kafka.StorageInfo {

apiObject := &kafka.StorageInfo{}

if v, ok := tfMap["ebs_storage_info"].([]interface{}); ok && len(v) > 0 {
if v, ok := tfMap["ebs_storage_info"].([]interface{}); ok && len(v) > 0 && v[0] != nil {
apiObject.EbsStorageInfo = expandEBSStorageInfo(v[0].(map[string]interface{}))
}

Expand All @@ -1035,7 +1035,7 @@ func expandEBSStorageInfo(tfMap map[string]interface{}) *kafka.EBSStorageInfo {

apiObject := &kafka.EBSStorageInfo{}

if v, ok := tfMap["provisioned_throughput"].([]interface{}); ok && len(v) > 0 {
if v, ok := tfMap["provisioned_throughput"].([]interface{}); ok && len(v) > 0 && v[0] != nil {
apiObject.ProvisionedThroughput = expandProvisionedThroughput(v[0].(map[string]interface{}))
}

Expand Down Expand Up @@ -1085,11 +1085,11 @@ func expandClientAuthentication(tfMap map[string]interface{}) *kafka.ClientAuthe

apiObject := &kafka.ClientAuthentication{}

if v, ok := tfMap["sasl"].([]interface{}); ok && len(v) > 0 {
if v, ok := tfMap["sasl"].([]interface{}); ok && len(v) > 0 && v[0] != nil {
apiObject.Sasl = expandSasl(v[0].(map[string]interface{}))
}

if v, ok := tfMap["tls"].([]interface{}); ok && len(v) > 0 {
if v, ok := tfMap["tls"].([]interface{}); ok && len(v) > 0 && v[0] != nil {
apiObject.Tls = expandTLS(v[0].(map[string]interface{}))
}

Expand Down Expand Up @@ -1166,7 +1166,7 @@ func expandEncryptionInfo(tfMap map[string]interface{}) *kafka.EncryptionInfo {

apiObject := &kafka.EncryptionInfo{}

if v, ok := tfMap["encryption_in_transit"].([]interface{}); ok && len(v) > 0 {
if v, ok := tfMap["encryption_in_transit"].([]interface{}); ok && len(v) > 0 && v[0] != nil {
apiObject.EncryptionInTransit = expandEncryptionInTransit(v[0].(map[string]interface{}))
}

Expand Down Expand Up @@ -1204,7 +1204,7 @@ func expandLoggingInfo(tfMap map[string]interface{}) *kafka.LoggingInfo {

apiObject := &kafka.LoggingInfo{}

if v, ok := tfMap["broker_logs"].([]interface{}); ok && len(v) > 0 {
if v, ok := tfMap["broker_logs"].([]interface{}); ok && len(v) > 0 && v[0] != nil {
apiObject.BrokerLogs = expandBrokerLogs(v[0].(map[string]interface{}))
}

Expand All @@ -1218,15 +1218,15 @@ func expandBrokerLogs(tfMap map[string]interface{}) *kafka.BrokerLogs {

apiObject := &kafka.BrokerLogs{}

if v, ok := tfMap["cloudwatch_logs"].([]interface{}); ok && len(v) > 0 {
if v, ok := tfMap["cloudwatch_logs"].([]interface{}); ok && len(v) > 0 && v[0] != nil {
apiObject.CloudWatchLogs = expandCloudWatchLogs(v[0].(map[string]interface{}))
}

if v, ok := tfMap["firehose"].([]interface{}); ok && len(v) > 0 {
if v, ok := tfMap["firehose"].([]interface{}); ok && len(v) > 0 && v[0] != nil {
apiObject.Firehose = expandFirehose(v[0].(map[string]interface{}))
}

if v, ok := tfMap["s3"].([]interface{}); ok && len(v) > 0 {
if v, ok := tfMap["s3"].([]interface{}); ok && len(v) > 0 && v[0] != nil {
apiObject.S3 = expandS3(v[0].(map[string]interface{}))
}

Expand Down Expand Up @@ -1298,7 +1298,7 @@ func expandOpenMonitoringInfo(tfMap map[string]interface{}) *kafka.OpenMonitorin

apiObject := &kafka.OpenMonitoringInfo{}

if v, ok := tfMap["prometheus"].([]interface{}); ok && len(v) > 0 {
if v, ok := tfMap["prometheus"].([]interface{}); ok && len(v) > 0 && v[0] != nil {
apiObject.Prometheus = expandPrometheusInfo(v[0].(map[string]interface{}))
}

Expand All @@ -1312,11 +1312,11 @@ func expandPrometheusInfo(tfMap map[string]interface{}) *kafka.PrometheusInfo {

apiObject := &kafka.PrometheusInfo{}

if v, ok := tfMap["jmx_exporter"].([]interface{}); ok && len(v) > 0 {
if v, ok := tfMap["jmx_exporter"].([]interface{}); ok && len(v) > 0 && v[0] != nil {
apiObject.JmxExporter = expandJmxExporterInfo(v[0].(map[string]interface{}))
}

if v, ok := tfMap["node_exporter"].([]interface{}); ok && len(v) > 0 {
if v, ok := tfMap["node_exporter"].([]interface{}); ok && len(v) > 0 && v[0] != nil {
apiObject.NodeExporter = expandNodeExporterInfo(v[0].(map[string]interface{}))
}

Expand Down