From 009e1d8c55efb3c42045771cd81c6946cbe1b9ac Mon Sep 17 00:00:00 2001 From: mgrose Date: Mon, 9 Sep 2019 21:58:57 -0500 Subject: [PATCH 01/11] u[dates --- ...esource_aws_lambda_event_source_mapping.go | 8 ++++ ...ce_aws_lambda_event_source_mapping_test.go | 45 +++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/aws/resource_aws_lambda_event_source_mapping.go b/aws/resource_aws_lambda_event_source_mapping.go index 0c39bf0c0f0..feed98dc0f2 100644 --- a/aws/resource_aws_lambda_event_source_mapping.go +++ b/aws/resource_aws_lambda_event_source_mapping.go @@ -96,6 +96,10 @@ func resourceAwsLambdaEventSourceMapping() *schema.Resource { Optional: true, Default: true, }, + "batch_window": { + Type: schema.TypeInt, + Optional: true, + }, "function_arn": { Type: schema.TypeString, Computed: true, @@ -144,6 +148,10 @@ func resourceAwsLambdaEventSourceMappingCreate(d *schema.ResourceData, meta inte params.BatchSize = aws.Int64(int64(batchSize.(int))) } + if batchWindow, ok := d.GetOk("batch_window"); ok { + params.MaximumBatchingWindowInSeconds = aws.Int64(int64(batchWindow.(int))) + } + if startingPosition, ok := d.GetOk("starting_position"); ok { params.StartingPosition = aws.String(startingPosition.(string)) } diff --git a/aws/resource_aws_lambda_event_source_mapping_test.go b/aws/resource_aws_lambda_event_source_mapping_test.go index 94a2275f3a8..138c17366cc 100644 --- a/aws/resource_aws_lambda_event_source_mapping_test.go +++ b/aws/resource_aws_lambda_event_source_mapping_test.go @@ -317,6 +317,37 @@ func TestAccAWSLambdaEventSourceMapping_StartingPositionTimestamp(t *testing.T) }) } +func TestAccAWSLambdaEventSourceMapping_BatchWindow(t *testing.T) { + var conf lambda.EventSourceMappingConfiguration + rName := acctest.RandomWithPrefix("tf-acc-test") + resourceName := "aws_lambda_event_source_mapping.test" + batchWindow := int64(5) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckLambdaEventSourceMappingDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSLambdaEventSourceMappingConfigKinesisBatchWindow(rName, batchWindow), + Check: resource.ComposeTestCheckFunc( + testAccCheckAwsLambdaEventSourceMappingExists(resourceName, &conf), + resource.TestCheckResourceAttr(resourceName, "batch_window", strconv.Itoa(int(batchWindow))), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{ + "starting_position", + "starting_position_timestamp", + }, + }, + }, + }) +} + func testAccCheckAWSLambdaEventSourceMappingIsBeingDisabled(conf *lambda.EventSourceMappingConfiguration) resource.TestCheckFunc { return func(s *terraform.State) error { conn := testAccProvider.Meta().(*AWSClient).lambdaconn @@ -560,6 +591,20 @@ resource "aws_lambda_event_source_mapping" "test" { `, startingPositionTimestamp) } +func testAccAWSLambdaEventSourceMappingConfigKinesisBatchWindow(rName string, batchWindow int64) string { + return testAccAWSLambdaEventSourceMappingConfigKinesisBase(rName) + fmt.Sprintf(` +resource "aws_lambda_event_source_mapping" "test" { + batch_size = 100 + batch_window = %v + enabled = true + event_source_arn = "${aws_kinesis_stream.test.arn}" + function_name = "${aws_lambda_function.test.arn}" + starting_position = "TRIM_HORIZON" +} +`, batchWindow) +} + + func testAccAWSLambdaEventSourceMappingConfig_kinesis(roleName, policyName, attName, streamName, funcName, uFuncName string) string { return fmt.Sprintf(` From fe19139edefdd037409ccec799f4b7431902d319 Mon Sep 17 00:00:00 2001 From: mgrose Date: Mon, 9 Sep 2019 22:14:52 -0500 Subject: [PATCH 02/11] updates --- website/docs/r/lambda_event_source_mapping.html.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/website/docs/r/lambda_event_source_mapping.html.markdown b/website/docs/r/lambda_event_source_mapping.html.markdown index e653aa0b32f..0de59f9d5e0 100644 --- a/website/docs/r/lambda_event_source_mapping.html.markdown +++ b/website/docs/r/lambda_event_source_mapping.html.markdown @@ -47,6 +47,7 @@ resource "aws_lambda_event_source_mapping" "example" { ## Argument Reference * `batch_size` - (Optional) The largest number of records that Lambda will retrieve from your event source at the time of invocation. Defaults to `100` for DynamoDB and Kinesis, `10` for SQS. +* `batch_window` - (Optional) The amount of minutes the event source will buffer records for. Records will continue to buffer until either `batch_window` (time in minutes) expires or `batch_size` has been met. Defaults to as soon as records are available in the stream. If the batch it reads from the stream only has one record in it, Lambda only sends one record to the function. * `event_source_arn` - (Required) The event source ARN - can either be a Kinesis or DynamoDB stream. * `enabled` - (Optional) Determines if the mapping will be enabled on creation. Defaults to `true`. * `function_name` - (Required) The name or the ARN of the Lambda function that will be subscribing to events. From f1d02d47f2a4083cb27b9e0e3d256f8e4721b7ed Mon Sep 17 00:00:00 2001 From: mgrose Date: Mon, 9 Sep 2019 23:07:50 -0500 Subject: [PATCH 03/11] updates --- aws/resource_aws_lambda_event_source_mapping_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aws/resource_aws_lambda_event_source_mapping_test.go b/aws/resource_aws_lambda_event_source_mapping_test.go index 138c17366cc..c754f54f0e0 100644 --- a/aws/resource_aws_lambda_event_source_mapping_test.go +++ b/aws/resource_aws_lambda_event_source_mapping_test.go @@ -340,6 +340,7 @@ func TestAccAWSLambdaEventSourceMapping_BatchWindow(t *testing.T) { ImportState: true, ImportStateVerify: true, ImportStateVerifyIgnore: []string{ + "batch_window", "starting_position", "starting_position_timestamp", }, @@ -604,7 +605,6 @@ resource "aws_lambda_event_source_mapping" "test" { `, batchWindow) } - func testAccAWSLambdaEventSourceMappingConfig_kinesis(roleName, policyName, attName, streamName, funcName, uFuncName string) string { return fmt.Sprintf(` From 0217ff789e0235653389b84280cb9556a71d2142 Mon Sep 17 00:00:00 2001 From: mg Date: Tue, 10 Sep 2019 12:29:51 -0500 Subject: [PATCH 04/11] Update lambda_event_source_mapping.html.markdown --- website/docs/r/lambda_event_source_mapping.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/r/lambda_event_source_mapping.html.markdown b/website/docs/r/lambda_event_source_mapping.html.markdown index 0de59f9d5e0..01461a9e92c 100644 --- a/website/docs/r/lambda_event_source_mapping.html.markdown +++ b/website/docs/r/lambda_event_source_mapping.html.markdown @@ -47,7 +47,7 @@ resource "aws_lambda_event_source_mapping" "example" { ## Argument Reference * `batch_size` - (Optional) The largest number of records that Lambda will retrieve from your event source at the time of invocation. Defaults to `100` for DynamoDB and Kinesis, `10` for SQS. -* `batch_window` - (Optional) The amount of minutes the event source will buffer records for. Records will continue to buffer until either `batch_window` (time in minutes) expires or `batch_size` has been met. Defaults to as soon as records are available in the stream. If the batch it reads from the stream only has one record in it, Lambda only sends one record to the function. +* `batch_window` - (Optional) The maximum amount of time to gather records before invoking the function, in seconds. Records will continue to buffer until either `batch_window` (time in minutes) expires or `batch_size` has been met. Defaults to as soon as records are available in the stream. If the batch it reads from the stream only has one record in it, Lambda only sends one record to the function. * `event_source_arn` - (Required) The event source ARN - can either be a Kinesis or DynamoDB stream. * `enabled` - (Optional) Determines if the mapping will be enabled on creation. Defaults to `true`. * `function_name` - (Required) The name or the ARN of the Lambda function that will be subscribing to events. From 752013e5e094c5d5d9a20998175d47aa18fefa7c Mon Sep 17 00:00:00 2001 From: mgrose Date: Tue, 10 Sep 2019 16:27:48 -0500 Subject: [PATCH 05/11] updates --- aws/resource_aws_lambda_event_source_mapping.go | 10 ++++++---- aws/resource_aws_lambda_event_source_mapping_test.go | 1 - 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/aws/resource_aws_lambda_event_source_mapping.go b/aws/resource_aws_lambda_event_source_mapping.go index feed98dc0f2..67df4e522ca 100644 --- a/aws/resource_aws_lambda_event_source_mapping.go +++ b/aws/resource_aws_lambda_event_source_mapping.go @@ -218,6 +218,7 @@ func resourceAwsLambdaEventSourceMappingRead(d *schema.ResourceData, meta interf } d.Set("batch_size", eventSourceMappingConfiguration.BatchSize) + d.Set("batch_window", eventSourceMappingConfiguration.MaximumBatchingWindowInSeconds) d.Set("event_source_arn", eventSourceMappingConfiguration.EventSourceArn) d.Set("function_arn", eventSourceMappingConfiguration.FunctionArn) d.Set("last_modified", eventSourceMappingConfiguration.LastModified) @@ -280,10 +281,11 @@ func resourceAwsLambdaEventSourceMappingUpdate(d *schema.ResourceData, meta inte log.Printf("[DEBUG] Updating Lambda event source mapping: %s", d.Id()) params := &lambda.UpdateEventSourceMappingInput{ - UUID: aws.String(d.Id()), - BatchSize: aws.Int64(int64(d.Get("batch_size").(int))), - FunctionName: aws.String(d.Get("function_name").(string)), - Enabled: aws.Bool(d.Get("enabled").(bool)), + UUID: aws.String(d.Id()), + BatchSize: aws.Int64(int64(d.Get("batch_size").(int))), + MaximumBatchingWindowInSeconds: aws.Int64(int64(d.Get("batch_window").(int))), + FunctionName: aws.String(d.Get("function_name").(string)), + Enabled: aws.Bool(d.Get("enabled").(bool)), } err := resource.Retry(5*time.Minute, func() *resource.RetryError { diff --git a/aws/resource_aws_lambda_event_source_mapping_test.go b/aws/resource_aws_lambda_event_source_mapping_test.go index c754f54f0e0..7f1ef600ede 100644 --- a/aws/resource_aws_lambda_event_source_mapping_test.go +++ b/aws/resource_aws_lambda_event_source_mapping_test.go @@ -340,7 +340,6 @@ func TestAccAWSLambdaEventSourceMapping_BatchWindow(t *testing.T) { ImportState: true, ImportStateVerify: true, ImportStateVerifyIgnore: []string{ - "batch_window", "starting_position", "starting_position_timestamp", }, From 17f0a09e41d54e3982033efa6c0957bbd93129c7 Mon Sep 17 00:00:00 2001 From: mgrose Date: Tue, 10 Sep 2019 16:48:39 -0500 Subject: [PATCH 06/11] update name --- aws/resource_aws_lambda_event_source_mapping.go | 8 ++++---- ...esource_aws_lambda_event_source_mapping_test.go | 14 +++++++------- .../r/lambda_event_source_mapping.html.markdown | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/aws/resource_aws_lambda_event_source_mapping.go b/aws/resource_aws_lambda_event_source_mapping.go index 67df4e522ca..4ec2db84295 100644 --- a/aws/resource_aws_lambda_event_source_mapping.go +++ b/aws/resource_aws_lambda_event_source_mapping.go @@ -96,7 +96,7 @@ func resourceAwsLambdaEventSourceMapping() *schema.Resource { Optional: true, Default: true, }, - "batch_window": { + "maximum_batching_window_in_seconds": { Type: schema.TypeInt, Optional: true, }, @@ -148,7 +148,7 @@ func resourceAwsLambdaEventSourceMappingCreate(d *schema.ResourceData, meta inte params.BatchSize = aws.Int64(int64(batchSize.(int))) } - if batchWindow, ok := d.GetOk("batch_window"); ok { + if batchWindow, ok := d.GetOk("maximum_batching_window_in_seconds"); ok { params.MaximumBatchingWindowInSeconds = aws.Int64(int64(batchWindow.(int))) } @@ -218,7 +218,7 @@ func resourceAwsLambdaEventSourceMappingRead(d *schema.ResourceData, meta interf } d.Set("batch_size", eventSourceMappingConfiguration.BatchSize) - d.Set("batch_window", eventSourceMappingConfiguration.MaximumBatchingWindowInSeconds) + d.Set("maximum_batching_window_in_seconds", eventSourceMappingConfiguration.MaximumBatchingWindowInSeconds) d.Set("event_source_arn", eventSourceMappingConfiguration.EventSourceArn) d.Set("function_arn", eventSourceMappingConfiguration.FunctionArn) d.Set("last_modified", eventSourceMappingConfiguration.LastModified) @@ -283,7 +283,7 @@ func resourceAwsLambdaEventSourceMappingUpdate(d *schema.ResourceData, meta inte params := &lambda.UpdateEventSourceMappingInput{ UUID: aws.String(d.Id()), BatchSize: aws.Int64(int64(d.Get("batch_size").(int))), - MaximumBatchingWindowInSeconds: aws.Int64(int64(d.Get("batch_window").(int))), + MaximumBatchingWindowInSeconds: aws.Int64(int64(d.Get("maximum_batching_window_in_seconds").(int))), FunctionName: aws.String(d.Get("function_name").(string)), Enabled: aws.Bool(d.Get("enabled").(bool)), } diff --git a/aws/resource_aws_lambda_event_source_mapping_test.go b/aws/resource_aws_lambda_event_source_mapping_test.go index 7f1ef600ede..610a8a828c8 100644 --- a/aws/resource_aws_lambda_event_source_mapping_test.go +++ b/aws/resource_aws_lambda_event_source_mapping_test.go @@ -332,7 +332,7 @@ func TestAccAWSLambdaEventSourceMapping_BatchWindow(t *testing.T) { Config: testAccAWSLambdaEventSourceMappingConfigKinesisBatchWindow(rName, batchWindow), Check: resource.ComposeTestCheckFunc( testAccCheckAwsLambdaEventSourceMappingExists(resourceName, &conf), - resource.TestCheckResourceAttr(resourceName, "batch_window", strconv.Itoa(int(batchWindow))), + resource.TestCheckResourceAttr(resourceName, "maximum_batching_window_in_seconds", strconv.Itoa(int(batchWindow))), ), }, { @@ -594,12 +594,12 @@ resource "aws_lambda_event_source_mapping" "test" { func testAccAWSLambdaEventSourceMappingConfigKinesisBatchWindow(rName string, batchWindow int64) string { return testAccAWSLambdaEventSourceMappingConfigKinesisBase(rName) + fmt.Sprintf(` resource "aws_lambda_event_source_mapping" "test" { - batch_size = 100 - batch_window = %v - enabled = true - event_source_arn = "${aws_kinesis_stream.test.arn}" - function_name = "${aws_lambda_function.test.arn}" - starting_position = "TRIM_HORIZON" + batch_size = 100 + maximum_batching_window_in_seconds = %v + enabled = true + event_source_arn = "${aws_kinesis_stream.test.arn}" + function_name = "${aws_lambda_function.test.arn}" + starting_position = "TRIM_HORIZON" } `, batchWindow) } diff --git a/website/docs/r/lambda_event_source_mapping.html.markdown b/website/docs/r/lambda_event_source_mapping.html.markdown index 01461a9e92c..648f8e37349 100644 --- a/website/docs/r/lambda_event_source_mapping.html.markdown +++ b/website/docs/r/lambda_event_source_mapping.html.markdown @@ -47,7 +47,7 @@ resource "aws_lambda_event_source_mapping" "example" { ## Argument Reference * `batch_size` - (Optional) The largest number of records that Lambda will retrieve from your event source at the time of invocation. Defaults to `100` for DynamoDB and Kinesis, `10` for SQS. -* `batch_window` - (Optional) The maximum amount of time to gather records before invoking the function, in seconds. Records will continue to buffer until either `batch_window` (time in minutes) expires or `batch_size` has been met. Defaults to as soon as records are available in the stream. If the batch it reads from the stream only has one record in it, Lambda only sends one record to the function. +* `maximum_batching_window_in_seconds` - (Optional) The maximum amount of time to gather records before invoking the function, in seconds. Records will continue to buffer until either `batch_window` (time in minutes) expires or `batch_size` has been met. Defaults to as soon as records are available in the stream. If the batch it reads from the stream only has one record in it, Lambda only sends one record to the function. * `event_source_arn` - (Required) The event source ARN - can either be a Kinesis or DynamoDB stream. * `enabled` - (Optional) Determines if the mapping will be enabled on creation. Defaults to `true`. * `function_name` - (Required) The name or the ARN of the Lambda function that will be subscribing to events. From 575ac321234b901b072025a8fd0315e18b37b083 Mon Sep 17 00:00:00 2001 From: mgrose Date: Tue, 10 Sep 2019 16:54:44 -0500 Subject: [PATCH 07/11] docs --- website/docs/r/lambda_event_source_mapping.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/r/lambda_event_source_mapping.html.markdown b/website/docs/r/lambda_event_source_mapping.html.markdown index 648f8e37349..264dcfdcdd4 100644 --- a/website/docs/r/lambda_event_source_mapping.html.markdown +++ b/website/docs/r/lambda_event_source_mapping.html.markdown @@ -47,7 +47,7 @@ resource "aws_lambda_event_source_mapping" "example" { ## Argument Reference * `batch_size` - (Optional) The largest number of records that Lambda will retrieve from your event source at the time of invocation. Defaults to `100` for DynamoDB and Kinesis, `10` for SQS. -* `maximum_batching_window_in_seconds` - (Optional) The maximum amount of time to gather records before invoking the function, in seconds. Records will continue to buffer until either `batch_window` (time in minutes) expires or `batch_size` has been met. Defaults to as soon as records are available in the stream. If the batch it reads from the stream only has one record in it, Lambda only sends one record to the function. +* `maximum_batching_window_in_seconds` - (Optional) The maximum amount of time to gather records before invoking the function, in seconds. Records will continue to buffer until either `maximum_batching_window_in_seconds` expires or `batch_size` has been met. Defaults to as soon as records are available in the stream. If the batch it reads from the stream only has one record in it, Lambda only sends one record to the function. * `event_source_arn` - (Required) The event source ARN - can either be a Kinesis or DynamoDB stream. * `enabled` - (Optional) Determines if the mapping will be enabled on creation. Defaults to `true`. * `function_name` - (Required) The name or the ARN of the Lambda function that will be subscribing to events. From f4d5c9fac60df008bac663111dd3295e36adc727 Mon Sep 17 00:00:00 2001 From: mgrose Date: Fri, 1 Nov 2019 11:37:26 -0500 Subject: [PATCH 08/11] conditionally add maximum batch window --- aws/resource_aws_lambda_event_source_mapping.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/aws/resource_aws_lambda_event_source_mapping.go b/aws/resource_aws_lambda_event_source_mapping.go index 4ec2db84295..3fb0423da3e 100644 --- a/aws/resource_aws_lambda_event_source_mapping.go +++ b/aws/resource_aws_lambda_event_source_mapping.go @@ -3,6 +3,7 @@ package aws import ( "fmt" "log" + "strings" "time" "github.com/aws/aws-sdk-go/aws" @@ -281,11 +282,15 @@ func resourceAwsLambdaEventSourceMappingUpdate(d *schema.ResourceData, meta inte log.Printf("[DEBUG] Updating Lambda event source mapping: %s", d.Id()) params := &lambda.UpdateEventSourceMappingInput{ - UUID: aws.String(d.Id()), - BatchSize: aws.Int64(int64(d.Get("batch_size").(int))), - MaximumBatchingWindowInSeconds: aws.Int64(int64(d.Get("maximum_batching_window_in_seconds").(int))), - FunctionName: aws.String(d.Get("function_name").(string)), - Enabled: aws.Bool(d.Get("enabled").(bool)), + UUID: aws.String(d.Id()), + BatchSize: aws.Int64(int64(d.Get("batch_size").(int))), + FunctionName: aws.String(d.Get("function_name").(string)), + Enabled: aws.Bool(d.Get("enabled").(bool)), + } + + // AWS API will fail if this parameter is set (even as default value) for sqs event source. Ideally this should be implemented in GO SDK or AWS API itself. + if !strings.Contains(d.Get("event_source_arn").(string), "sqs") { + params.MaximumBatchingWindowInSeconds = aws.Int64(int64(d.Get("maximum_batching_window_in_seconds").(int))) } err := resource.Retry(5*time.Minute, func() *resource.RetryError { From f56c030488326efb4f235d26d78e0bd67451eb43 Mon Sep 17 00:00:00 2001 From: mgrose Date: Fri, 1 Nov 2019 11:44:37 -0500 Subject: [PATCH 09/11] better handling of sqs check --- aws/resource_aws_lambda_event_source_mapping.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aws/resource_aws_lambda_event_source_mapping.go b/aws/resource_aws_lambda_event_source_mapping.go index 43e2766665a..b6258a52dff 100644 --- a/aws/resource_aws_lambda_event_source_mapping.go +++ b/aws/resource_aws_lambda_event_source_mapping.go @@ -289,7 +289,7 @@ func resourceAwsLambdaEventSourceMappingUpdate(d *schema.ResourceData, meta inte } // AWS API will fail if this parameter is set (even as default value) for sqs event source. Ideally this should be implemented in GO SDK or AWS API itself. - if !strings.Contains(d.Get("event_source_arn").(string), "sqs") { + if !strings.HasPrefix(d.Get("event_source_arn").(string), "arn:aws:sqs:") { params.MaximumBatchingWindowInSeconds = aws.Int64(int64(d.Get("maximum_batching_window_in_seconds").(int))) } From 39067e40c2d55d6d76977d95cdfb5ecc90f2135b Mon Sep 17 00:00:00 2001 From: mg Date: Tue, 19 Nov 2019 16:57:16 -0600 Subject: [PATCH 10/11] Update aws/resource_aws_lambda_event_source_mapping.go Co-Authored-By: Brian Flad --- aws/resource_aws_lambda_event_source_mapping.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/aws/resource_aws_lambda_event_source_mapping.go b/aws/resource_aws_lambda_event_source_mapping.go index b6258a52dff..6cb5326250e 100644 --- a/aws/resource_aws_lambda_event_source_mapping.go +++ b/aws/resource_aws_lambda_event_source_mapping.go @@ -289,7 +289,9 @@ func resourceAwsLambdaEventSourceMappingUpdate(d *schema.ResourceData, meta inte } // AWS API will fail if this parameter is set (even as default value) for sqs event source. Ideally this should be implemented in GO SDK or AWS API itself. - if !strings.HasPrefix(d.Get("event_source_arn").(string), "arn:aws:sqs:") { + eventSourceArn, err := arn.Parse(d.Get("event_source_arn").(string)) + + if err == nil && eventSourceArn.Service != "sqs" { params.MaximumBatchingWindowInSeconds = aws.Int64(int64(d.Get("maximum_batching_window_in_seconds").(int))) } From 5a6478e7260290b538ebf81af085ebd27c1c927e Mon Sep 17 00:00:00 2001 From: mgrose Date: Tue, 19 Nov 2019 17:39:45 -0600 Subject: [PATCH 11/11] updates --- aws/resource_aws_lambda_event_source_mapping.go | 3 +-- aws/resource_aws_lambda_event_source_mapping_test.go | 8 ++++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/aws/resource_aws_lambda_event_source_mapping.go b/aws/resource_aws_lambda_event_source_mapping.go index 6cb5326250e..0285455eb06 100644 --- a/aws/resource_aws_lambda_event_source_mapping.go +++ b/aws/resource_aws_lambda_event_source_mapping.go @@ -3,7 +3,6 @@ package aws import ( "fmt" "log" - "strings" "time" "github.com/aws/aws-sdk-go/aws" @@ -295,7 +294,7 @@ func resourceAwsLambdaEventSourceMappingUpdate(d *schema.ResourceData, meta inte params.MaximumBatchingWindowInSeconds = aws.Int64(int64(d.Get("maximum_batching_window_in_seconds").(int))) } - err := resource.Retry(5*time.Minute, func() *resource.RetryError { + err = resource.Retry(5*time.Minute, func() *resource.RetryError { _, err := conn.UpdateEventSourceMapping(params) if err != nil { if isAWSErr(err, lambda.ErrCodeInvalidParameterValueException, "") || diff --git a/aws/resource_aws_lambda_event_source_mapping_test.go b/aws/resource_aws_lambda_event_source_mapping_test.go index 3b84a033259..03d9bd3055b 100644 --- a/aws/resource_aws_lambda_event_source_mapping_test.go +++ b/aws/resource_aws_lambda_event_source_mapping_test.go @@ -316,6 +316,7 @@ func TestAccAWSLambdaEventSourceMapping_BatchWindow(t *testing.T) { rName := acctest.RandomWithPrefix("tf-acc-test") resourceName := "aws_lambda_event_source_mapping.test" batchWindow := int64(5) + batchWindowUpdate := int64(10) resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -338,6 +339,13 @@ func TestAccAWSLambdaEventSourceMapping_BatchWindow(t *testing.T) { "starting_position_timestamp", }, }, + { + Config: testAccAWSLambdaEventSourceMappingConfigKinesisBatchWindow(rName, batchWindowUpdate), + Check: resource.ComposeTestCheckFunc( + testAccCheckAwsLambdaEventSourceMappingExists(resourceName, &conf), + resource.TestCheckResourceAttr(resourceName, "maximum_batching_window_in_seconds", strconv.Itoa(int(batchWindowUpdate))), + ), + }, }, }) }