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

resource/aws_kinesis_firehose_delivery_stream: Allow processor clearing #11649

Merged
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
16 changes: 12 additions & 4 deletions aws/resource_aws_kinesis_firehose_delivery_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -1749,17 +1749,25 @@ func extractProcessors(processingConfigurationProcessors []interface{}) []*fireh
processors := []*firehose.Processor{}

for _, processor := range processingConfigurationProcessors {
processors = append(processors, extractProcessor(processor.(map[string]interface{})))
extractedProcessor := extractProcessor(processor.(map[string]interface{}))
if extractedProcessor != nil {
processors = append(processors, extractedProcessor)
}
}

return processors
}

func extractProcessor(processingConfigurationProcessor map[string]interface{}) *firehose.Processor {
return &firehose.Processor{
Type: aws.String(processingConfigurationProcessor["type"].(string)),
Parameters: extractProcessorParameters(processingConfigurationProcessor["parameters"].([]interface{})),
var processor *firehose.Processor
processorType := processingConfigurationProcessor["type"].(string)
if processorType != "" {
processor = &firehose.Processor{
Type: aws.String(processorType),
Parameters: extractProcessorParameters(processingConfigurationProcessor["parameters"].([]interface{})),
}
}
return processor
}

func extractProcessorParameters(processorParameters []interface{}) []*firehose.ProcessorParameter {
Expand Down
58 changes: 50 additions & 8 deletions aws/resource_aws_kinesis_firehose_delivery_stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -757,11 +757,14 @@ func TestAccAWSKinesisFirehoseDeliveryStream_ExtendedS3Updates(t *testing.T) {
preConfig := testAccFirehoseAWSLambdaConfigBasic(funcName, policyName, roleName) +
fmt.Sprintf(testAccKinesisFirehoseDeliveryStreamConfig_extendedS3basic,
ri, ri, ri, ri)
postConfig := testAccFirehoseAWSLambdaConfigBasic(funcName, policyName, roleName) +
fmt.Sprintf(testAccKinesisFirehoseDeliveryStreamConfig_extendedS3Updates,
firstUpdateConfig := testAccFirehoseAWSLambdaConfigBasic(funcName, policyName, roleName) +
fmt.Sprintf(testAccKinesisFirehoseDeliveryStreamConfig_extendedS3Updates_Initial,
ri, ri, ri, ri)
removeProcessorsConfig := testAccFirehoseAWSLambdaConfigBasic(funcName, policyName, roleName) +
fmt.Sprintf(testAccKinesisFirehoseDeliveryStreamConfig_extendedS3Updates_RemoveProcessors,
ri, ri, ri, ri)

updatedExtendedS3DestinationConfig := &firehose.ExtendedS3DestinationDescription{
firstUpdateExtendedS3DestinationConfig := &firehose.ExtendedS3DestinationDescription{
BufferingHints: &firehose.BufferingHints{
IntervalInSeconds: aws.Int64(400),
SizeInMBs: aws.Int64(10),
Expand All @@ -783,6 +786,18 @@ func TestAccAWSKinesisFirehoseDeliveryStream_ExtendedS3Updates(t *testing.T) {
S3BackupMode: aws.String("Enabled"),
}

removeProcessorsExtendedS3DestinationConfig := &firehose.ExtendedS3DestinationDescription{
BufferingHints: &firehose.BufferingHints{
IntervalInSeconds: aws.Int64(400),
SizeInMBs: aws.Int64(10),
},
ProcessingConfiguration: &firehose.ProcessingConfiguration{
Enabled: aws.Bool(false),
Processors: []*firehose.Processor{},
},
S3BackupMode: aws.String("Enabled"),
}

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Expand All @@ -801,10 +816,17 @@ func TestAccAWSKinesisFirehoseDeliveryStream_ExtendedS3Updates(t *testing.T) {
ImportStateVerify: true,
},
{
Config: postConfig,
Config: firstUpdateConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckKinesisFirehoseDeliveryStreamExists(resourceName, &stream),
testAccCheckAWSKinesisFirehoseDeliveryStreamAttributes(&stream, nil, firstUpdateExtendedS3DestinationConfig, nil, nil, nil),
),
},
{
Config: removeProcessorsConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckKinesisFirehoseDeliveryStreamExists(resourceName, &stream),
testAccCheckAWSKinesisFirehoseDeliveryStreamAttributes(&stream, nil, updatedExtendedS3DestinationConfig, nil, nil, nil),
testAccCheckAWSKinesisFirehoseDeliveryStreamAttributes(&stream, nil, removeProcessorsExtendedS3DestinationConfig, nil, nil, nil),
),
},
},
Expand Down Expand Up @@ -1656,7 +1678,7 @@ resource "aws_kinesis_firehose_delivery_stream" "test" {
role_arn = "${aws_iam_role.firehose.arn}"
bucket_arn = "${aws_s3_bucket.bucket.arn}"
processing_configuration {
enabled = false
enabled = true
processors {
type = "Lambda"
parameters {
Expand Down Expand Up @@ -2000,7 +2022,7 @@ resource "aws_kinesis_firehose_delivery_stream" "test" {
}
`

var testAccKinesisFirehoseDeliveryStreamConfig_extendedS3Updates = testAccKinesisFirehoseDeliveryStreamBaseConfig + `
var testAccKinesisFirehoseDeliveryStreamConfig_extendedS3Updates_Initial = testAccKinesisFirehoseDeliveryStreamBaseConfig + `
resource "aws_kinesis_firehose_delivery_stream" "test" {
depends_on = ["aws_iam_role_policy.firehose"]
name = "terraform-kinesis-firehose-basictest-%d"
Expand All @@ -2009,7 +2031,7 @@ resource "aws_kinesis_firehose_delivery_stream" "test" {
role_arn = "${aws_iam_role.firehose.arn}"
bucket_arn = "${aws_s3_bucket.bucket.arn}"
processing_configuration {
enabled = false
enabled = true
processors {
type = "Lambda"
parameters {
Expand All @@ -2030,6 +2052,26 @@ resource "aws_kinesis_firehose_delivery_stream" "test" {
}
`

var testAccKinesisFirehoseDeliveryStreamConfig_extendedS3Updates_RemoveProcessors = testAccKinesisFirehoseDeliveryStreamBaseConfig + `
resource "aws_kinesis_firehose_delivery_stream" "test" {
depends_on = ["aws_iam_role_policy.firehose"]
name = "terraform-kinesis-firehose-basictest-%d"
destination = "extended_s3"
extended_s3_configuration {
role_arn = "${aws_iam_role.firehose.arn}"
bucket_arn = "${aws_s3_bucket.bucket.arn}"
buffer_size = 10
buffer_interval = 400
compression_format = "GZIP"
s3_backup_mode = "Enabled"
s3_backup_configuration {
role_arn = "${aws_iam_role.firehose.arn}"
bucket_arn = "${aws_s3_bucket.bucket.arn}"
}
}
}
`

var testAccKinesisFirehoseDeliveryStreamBaseRedshiftConfig = testAccKinesisFirehoseDeliveryStreamBaseConfig + `
resource "aws_redshift_cluster" "test_cluster" {
cluster_identifier = "tf-redshift-cluster-%d"
Expand Down