-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
aws_lambda_event_source_mapping: maximum_batching_window_in_seconds #10051
Merged
bflad
merged 13 commits into
hashicorp:master
from
tiny-dancer:feature/eventsourcemapping-batch-window
Nov 20, 2019
+70
−1
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
009e1d8
u[dates
tiny-dancer fe19139
updates
tiny-dancer f1d02d4
updates
tiny-dancer 0217ff7
Update lambda_event_source_mapping.html.markdown
tiny-dancer 752013e
updates
tiny-dancer 17f0a09
update name
tiny-dancer 575ac32
docs
tiny-dancer f4d5c9f
conditionally add maximum batch window
tiny-dancer 4a8171a
Merge tag 'v2.33.0' into feature/eventsourcemapping-batch-window
tiny-dancer f56c030
better handling of sqs check
tiny-dancer cde4f69
Merge branch 'master' into feature/eventsourcemapping-batch-window
tiny-dancer 39067e4
Update aws/resource_aws_lambda_event_source_mapping.go
tiny-dancer 5a6478e
updates
tiny-dancer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -311,6 +311,45 @@ 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) | ||
batchWindowUpdate := int64(10) | ||
|
||
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, "maximum_batching_window_in_seconds", strconv.Itoa(int(batchWindow))), | ||
), | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be great if there was an additional test step to verify updating |
||
{ | ||
ResourceName: resourceName, | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{ | ||
"starting_position", | ||
"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))), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccCheckAWSLambdaEventSourceMappingIsBeingDisabled(conf *lambda.EventSourceMappingConfiguration) resource.TestCheckFunc { | ||
return func(s *terraform.State) error { | ||
conn := testAccProvider.Meta().(*AWSClient).lambdaconn | ||
|
@@ -554,6 +593,19 @@ 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 | ||
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) | ||
} | ||
|
||
func testAccAWSLambdaEventSourceMappingConfig_kinesis(roleName, policyName, attName, streamName, | ||
funcName, uFuncName string) string { | ||
return fmt.Sprintf(` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bflad your proposed change swallows the
err
here if it were to exist, was that intentional?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vs returning the
err
or printing a warning of sortsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry if this was confusing, I should have elaborated on swallowing the error -- if anything, potentially returning a warning log would feel appropriate here since the ARN should have gone through multiple forms of validation at this point (either from Terraform or the API itself). Returning an error could leave operators in a potentially unrecoverable state if for some reason the event source ARN was not an ARN and they made it this far. Hope this makes sense. 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense - thanks for the explanation!