From bf2020cc9239635b7b80251da44f18a63908c64e Mon Sep 17 00:00:00 2001 From: Radek Simko Date: Thu, 18 Jan 2018 11:00:52 +0000 Subject: [PATCH] resource/aws_kinesis_firehose_delivery_stream: Prevent crash on empty CW logging opts --- ...ce_aws_kinesis_firehose_delivery_stream.go | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/aws/resource_aws_kinesis_firehose_delivery_stream.go b/aws/resource_aws_kinesis_firehose_delivery_stream.go index 34de17beba6..0ba21640121 100644 --- a/aws/resource_aws_kinesis_firehose_delivery_stream.go +++ b/aws/resource_aws_kinesis_firehose_delivery_stream.go @@ -186,21 +186,22 @@ func flattenCloudwatchLoggingOptions(clo firehose.CloudWatchLoggingOptions) *sch return schema.NewSet(cloudwatchLoggingOptionsHash, []interface{}{cloudwatchLoggingOptions}) } -func flattenFirehoseS3Configuration(s3 firehose.S3DestinationDescription) []map[string]interface{} { - s3Configuration := make([]map[string]interface{}, 1) - s3Configuration[0] = map[string]interface{}{ - "role_arn": *s3.RoleARN, - "bucket_arn": *s3.BucketARN, - "prefix": *s3.Prefix, - "buffer_size": *s3.BufferingHints.SizeInMBs, - "buffer_interval": *s3.BufferingHints.IntervalInSeconds, - "compression_format": *s3.CompressionFormat, - "cloudwatch_logging_options": flattenCloudwatchLoggingOptions(*s3.CloudWatchLoggingOptions), +func flattenFirehoseS3Configuration(s3 firehose.S3DestinationDescription) []interface{} { + s3Configuration := map[string]interface{}{ + "role_arn": *s3.RoleARN, + "bucket_arn": *s3.BucketARN, + "prefix": *s3.Prefix, + "buffer_size": *s3.BufferingHints.SizeInMBs, + "buffer_interval": *s3.BufferingHints.IntervalInSeconds, + "compression_format": *s3.CompressionFormat, + } + if s3.CloudWatchLoggingOptions != nil { + s3Configuration["cloudwatch_logging_options"] = flattenCloudwatchLoggingOptions(*s3.CloudWatchLoggingOptions) } if s3.EncryptionConfiguration.KMSEncryptionConfig != nil { - s3Configuration[0]["kms_key_arn"] = *s3.EncryptionConfiguration.KMSEncryptionConfig + s3Configuration["kms_key_arn"] = *s3.EncryptionConfiguration.KMSEncryptionConfig } - return s3Configuration + return []interface{}{s3Configuration} } func flattenProcessingConfiguration(pc firehose.ProcessingConfiguration, roleArn string) []map[string]interface{} {