Skip to content

Commit

Permalink
Merge pull request #35969 from acwwat/f-aws_kinesis_firehose_delivery…
Browse files Browse the repository at this point in the history
…_stream-add_ext_s3_cfg_attrs

feat: Add custom_time_zone & file_extension to extended_S3_configuration block for aws_kinesis_firehose_delivery_stream
  • Loading branch information
ewbankkit authored Feb 26, 2024
2 parents 2fe1f6d + afbcc5e commit be60d1a
Show file tree
Hide file tree
Showing 4 changed files with 255 additions and 83 deletions.
3 changes: 3 additions & 0 deletions .changelog/35969.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
aws_kinesis_firehose_delivery_stream: Add `custom_time_zone` and `file_extension` arguments to the `extended_S3_configuration` configuration block
```
20 changes: 20 additions & 0 deletions internal/service/firehose/delivery_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,12 @@ func resourceDeliveryStream() *schema.Resource {
Default: types.CompressionFormatUncompressed,
ValidateDiagFunc: enum.Validate[types.CompressionFormat](),
},
"custom_time_zone": {
Type: schema.TypeString,
Optional: true,
Default: "UTC",
ValidateFunc: validation.StringLenBetween(0, 50),
},
"data_format_conversion_configuration": {
Type: schema.TypeList,
Optional: true,
Expand Down Expand Up @@ -688,6 +694,14 @@ func resourceDeliveryStream() *schema.Resource {
Optional: true,
ValidateFunc: validation.StringLenBetween(0, 1024),
},
"file_extension": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.All(
validation.StringLenBetween(0, 50),
validation.StringMatch(regexache.MustCompile(`^$|\.[0-9a-z!\-_.*'()]+`), ""),
),
},
"kms_key_arn": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -1775,8 +1789,10 @@ func expandExtendedS3DestinationConfiguration(s3 map[string]interface{}) *types.
},
Prefix: expandPrefix(s3),
CompressionFormat: types.CompressionFormat(s3["compression_format"].(string)),
CustomTimeZone: aws.String(s3["custom_time_zone"].(string)),
DataFormatConversionConfiguration: expandDataFormatConversionConfiguration(s3["data_format_conversion_configuration"].([]interface{})),
EncryptionConfiguration: expandEncryptionConfiguration(s3),
FileExtension: aws.String(s3["file_extension"].(string)),
}

if _, ok := s3["processing_configuration"]; ok {
Expand Down Expand Up @@ -1864,7 +1880,9 @@ func expandExtendedS3DestinationUpdate(s3 map[string]interface{}) *types.Extende
IntervalInSeconds: aws.Int32(int32(s3["buffering_interval"].(int))),
SizeInMBs: aws.Int32(int32(s3["buffering_size"].(int))),
},
CustomTimeZone: aws.String(s3["custom_time_zone"].(string)),
ErrorOutputPrefix: aws.String(s3["error_output_prefix"].(string)),
FileExtension: aws.String(s3["file_extension"].(string)),
Prefix: expandPrefix(s3),
CompressionFormat: types.CompressionFormat(s3["compression_format"].(string)),
EncryptionConfiguration: expandEncryptionConfiguration(s3),
Expand Down Expand Up @@ -3057,8 +3075,10 @@ func flattenExtendedS3DestinationDescription(description *types.ExtendedS3Destin
"bucket_arn": aws.ToString(description.BucketARN),
"cloudwatch_logging_options": flattenCloudWatchLoggingOptions(description.CloudWatchLoggingOptions),
"compression_format": description.CompressionFormat,
"custom_time_zone": aws.ToString(description.CustomTimeZone),
"data_format_conversion_configuration": flattenDataFormatConversionConfiguration(description.DataFormatConversionConfiguration),
"error_output_prefix": aws.ToString(description.ErrorOutputPrefix),
"file_extension": aws.ToString(description.FileExtension),
"prefix": aws.ToString(description.Prefix),
"processing_configuration": flattenProcessingConfiguration(description.ProcessingConfiguration, destinationTypeExtendedS3, aws.ToString(description.RoleARN)),
"dynamic_partitioning_configuration": flattenDynamicPartitioningConfiguration(description.DynamicPartitioningConfiguration),
Expand Down
86 changes: 86 additions & 0 deletions internal/service/firehose/delivery_stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ func TestAccFirehoseDeliveryStream_basic(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "extended_s3_configuration.0.cloudwatch_logging_options.0.log_group_name", ""),
resource.TestCheckResourceAttr(resourceName, "extended_s3_configuration.0.cloudwatch_logging_options.0.log_stream_name", ""),
resource.TestCheckResourceAttr(resourceName, "extended_s3_configuration.0.compression_format", "UNCOMPRESSED"),
resource.TestCheckResourceAttr(resourceName, "extended_s3_configuration.0.custom_time_zone", "UTC"),
resource.TestCheckResourceAttr(resourceName, "extended_s3_configuration.0.data_format_conversion_configuration.#", "0"),
resource.TestCheckResourceAttr(resourceName, "extended_s3_configuration.0.dynamic_partitioning_configuration.#", "0"),
resource.TestCheckResourceAttr(resourceName, "extended_s3_configuration.0.error_output_prefix", ""),
resource.TestCheckResourceAttr(resourceName, "extended_s3_configuration.0.file_extension", ""),
resource.TestCheckResourceAttr(resourceName, "extended_s3_configuration.0.kms_key_arn", ""),
resource.TestCheckResourceAttr(resourceName, "extended_s3_configuration.0.prefix", ""),
resource.TestCheckResourceAttr(resourceName, "extended_s3_configuration.0.processing_configuration.#", "1"),
Expand Down Expand Up @@ -888,6 +890,58 @@ func TestAccFirehoseDeliveryStream_extendedS3Updates(t *testing.T) {
})
}

func TestAccFirehoseDeliveryStream_extendedS3CustomTimeZoneAndFileExtensionUpdates(t *testing.T) {
ctx := acctest.Context(t)
var stream types.DeliveryStreamDescription
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
resourceName := "aws_kinesis_firehose_delivery_stream.test"
customTimeZone := "America/Los_Angeles"
fileExtension := ".json"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(ctx, t) },
ErrorCheck: acctest.ErrorCheck(t, names.FirehoseServiceID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckDeliveryStreamDestroy_ExtendedS3(ctx),
Steps: []resource.TestStep{
{
Config: testAccDeliveryStreamConfig_extendedS3CustomTimeZoneAndFileExtensionUpdates(rName, customTimeZone, fileExtension),
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckDeliveryStreamExists(ctx, resourceName, &stream),
resource.TestCheckResourceAttr(resourceName, "extended_s3_configuration.0.custom_time_zone", customTimeZone),
resource.TestCheckResourceAttr(resourceName, "extended_s3_configuration.0.file_extension", fileExtension),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccDeliveryStreamConfig_extendedS3CustomTimeZoneAndFileExtensionUpdatesNoValues(rName),
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckDeliveryStreamExists(ctx, resourceName, &stream),
resource.TestCheckResourceAttr(resourceName, "extended_s3_configuration.0.custom_time_zone", "UTC"),
resource.TestCheckResourceAttr(resourceName, "extended_s3_configuration.0.file_extension", ""),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccDeliveryStreamConfig_extendedS3CustomTimeZoneAndFileExtensionUpdates(rName, customTimeZone, fileExtension),
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckDeliveryStreamExists(ctx, resourceName, &stream),
resource.TestCheckResourceAttr(resourceName, "extended_s3_configuration.0.custom_time_zone", customTimeZone),
resource.TestCheckResourceAttr(resourceName, "extended_s3_configuration.0.file_extension", fileExtension),
),
},
},
})
}

func TestAccFirehoseDeliveryStream_ExtendedS3_kinesisStreamSource(t *testing.T) {
ctx := acctest.Context(t)
var stream types.DeliveryStreamDescription
Expand Down Expand Up @@ -3354,6 +3408,38 @@ resource "aws_kinesis_firehose_delivery_stream" "test" {
`, rName))
}

func testAccDeliveryStreamConfig_extendedS3CustomTimeZoneAndFileExtensionUpdates(rName, customTimeZone, fileExtension string) string {
return acctest.ConfigCompose(testAccDeliveryStreamConfig_base(rName), fmt.Sprintf(`
resource "aws_kinesis_firehose_delivery_stream" "test" {
depends_on = [aws_iam_role_policy.firehose]
name = %[1]q
destination = "extended_s3"
extended_s3_configuration {
role_arn = aws_iam_role.firehose.arn
bucket_arn = aws_s3_bucket.bucket.arn
custom_time_zone = %[2]q
file_extension = %[3]q
}
}
`, rName, customTimeZone, fileExtension))
}

func testAccDeliveryStreamConfig_extendedS3CustomTimeZoneAndFileExtensionUpdatesNoValues(rName string) string {
return acctest.ConfigCompose(testAccDeliveryStreamConfig_base(rName), fmt.Sprintf(`
resource "aws_kinesis_firehose_delivery_stream" "test" {
depends_on = [aws_iam_role_policy.firehose]
name = %[1]q
destination = "extended_s3"
extended_s3_configuration {
role_arn = aws_iam_role.firehose.arn
bucket_arn = aws_s3_bucket.bucket.arn
}
}
`, rName))
}

func testAccDeliveryStreamConfig_baseRedshift(rName string) string {
return acctest.ConfigCompose(
testAccDeliveryStreamConfig_base(rName),
Expand Down
Loading

0 comments on commit be60d1a

Please sign in to comment.