Skip to content
Open
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
3 changes: 3 additions & 0 deletions .changelog/45313.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_lambda_event_source_mapping: extend `provisioned_poller_config` with optional string param `poller_group_name`
```
14 changes: 14 additions & 0 deletions internal/service/lambda/event_source_mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,12 @@ func resourceEventSourceMapping() *schema.Resource {
Computed: true,
ValidateFunc: validation.IntBetween(1, 200),
},
"poller_group_name": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringLenBetween(1, 128),
},
},
},
},
Expand Down Expand Up @@ -1277,6 +1283,10 @@ func expandProvisionedPollerConfig(tfMap map[string]any) *awstypes.ProvisionedPo
apiObject.MinimumPollers = aws.Int32(int32(v))
}

if v, ok := tfMap["poller_group_name"].(string); ok && v != "" {
apiObject.PollerGroupName = aws.String(v)
}

return apiObject
}

Expand All @@ -1295,6 +1305,10 @@ func flattenProvisionedPollerConfig(apiObject *awstypes.ProvisionedPollerConfig)
tfMap["minimum_pollers"] = aws.ToInt32(v)
}

if v := apiObject.PollerGroupName; v != nil {
tfMap["poller_group_name"] = aws.ToString(v)
}

return tfMap
}

Expand Down
18 changes: 14 additions & 4 deletions internal/service/lambda/event_source_mapping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1283,12 +1283,13 @@ func TestAccLambdaEventSourceMapping_selfManagedKafkaWithProvisionedPollerConfig
CheckDestroy: testAccCheckEventSourceMappingDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccEventSourceMappingConfig_selfManagedKafkaWithProvisionedPollerConfig(rName, "100", "test1:9092,test2:9092", "123", "null"),
Config: testAccEventSourceMappingConfig_selfManagedKafkaWithProvisionedPollerConfig(rName, "100", "test1:9092,test2:9092", "123", "null", "null"),
Check: resource.ComposeTestCheckFunc(
testAccCheckEventSourceMappingExists(ctx, resourceName, &v),
resource.TestCheckResourceAttr(resourceName, "provisioned_poller_config.#", "1"),
resource.TestCheckResourceAttr(resourceName, "provisioned_poller_config.0.maximum_pollers", "123"),
resource.TestCheckResourceAttrSet(resourceName, "provisioned_poller_config.0.minimum_pollers"),
resource.TestCheckResourceAttrSet(resourceName, "provisioned_poller_config.0.poller_group_name"),
),
},
{
Expand All @@ -1298,12 +1299,13 @@ func TestAccLambdaEventSourceMapping_selfManagedKafkaWithProvisionedPollerConfig
ImportStateVerifyIgnore: []string{"last_modified"},
},
{
Config: testAccEventSourceMappingConfig_selfManagedKafkaWithProvisionedPollerConfig(rName, "100", "test1:9092,test2:9092", "150", "15"),
Config: testAccEventSourceMappingConfig_selfManagedKafkaWithProvisionedPollerConfig(rName, "100", "test1:9092,test2:9092", "150", "15", "group-name-123"),
Check: resource.ComposeTestCheckFunc(
testAccCheckEventSourceMappingExists(ctx, resourceName, &v),
resource.TestCheckResourceAttr(resourceName, "provisioned_poller_config.#", "1"),
resource.TestCheckResourceAttr(resourceName, "provisioned_poller_config.0.maximum_pollers", "150"),
resource.TestCheckResourceAttr(resourceName, "provisioned_poller_config.0.minimum_pollers", "15"),
resource.TestCheckResourceAttr(resourceName, "provisioned_poller_config.0.poller_group_name", "group-name-123"),
),
},
{
Expand Down Expand Up @@ -2840,6 +2842,7 @@ resource "aws_lambda_event_source_mapping" "test" {
provisioned_poller_config {
maximum_pollers = 100
minimum_pollers = 1
poller_group_name = "test-group"
}

amazon_managed_kafka_event_source_config {
Expand Down Expand Up @@ -2899,6 +2902,7 @@ resource "aws_lambda_event_source_mapping" "test" {
provisioned_poller_config {
maximum_pollers = 100
minimum_pollers = 1
poller_group_name = "test-group"
}

amazon_managed_kafka_event_source_config {
Expand Down Expand Up @@ -3011,6 +3015,7 @@ resource "aws_lambda_event_source_mapping" "test" {
provisioned_poller_config {
maximum_pollers = 100
minimum_pollers = 1
poller_group_name = "test-group"
}

self_managed_kafka_event_source_config {
Expand Down Expand Up @@ -3067,6 +3072,7 @@ resource "aws_lambda_event_source_mapping" "test" {
provisioned_poller_config {
maximum_pollers = 100
minimum_pollers = 1
poller_group_name = "test-group"
}

self_managed_kafka_event_source_config {
Expand Down Expand Up @@ -3105,7 +3111,7 @@ resource "aws_lambda_event_source_mapping" "test" {
`)
}

func testAccEventSourceMappingConfig_selfManagedKafkaWithProvisionedPollerConfig(rName, batchSize, kafkaBootstrapServers, maxPollers, minPollers string) string {
func testAccEventSourceMappingConfig_selfManagedKafkaWithProvisionedPollerConfig(rName, batchSize, kafkaBootstrapServers, maxPollers, minPollers, pollerGroupName string) string {
if batchSize == "" {
batchSize = "null"
}
Expand All @@ -3115,6 +3121,9 @@ func testAccEventSourceMappingConfig_selfManagedKafkaWithProvisionedPollerConfig
if minPollers == "" {
minPollers = "null"
}
if pollerGroupName == "" {
pollerGroupName = "null"
}

return acctest.ConfigCompose(testAccEventSourceMappingConfig_kafkaBase(rName), fmt.Sprintf(`
resource "aws_lambda_event_source_mapping" "test" {
Expand Down Expand Up @@ -3146,9 +3155,10 @@ resource "aws_lambda_event_source_mapping" "test" {
provisioned_poller_config {
maximum_pollers = %[4]s
minimum_pollers = %[5]s
poller_group_name = %[6]s
}
}
`, rName, batchSize, kafkaBootstrapServers, maxPollers, minPollers))
`, rName, batchSize, kafkaBootstrapServers, maxPollers, minPollers, pollerGroupName))
}

func testAccEventSourceMappingConfig_dynamoDBBatchSize(rName, batchSize string) string {
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/lambda_event_source_mapping.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ resource "aws_lambda_event_source_mapping" "example" {
provisioned_poller_config {
maximum_pollers = 100
minimum_pollers = 10
poller_group_name = "group-123"
}
}
```
Expand Down Expand Up @@ -266,6 +267,7 @@ The following arguments are optional:

* `maximum_pollers` - (Optional) Maximum number of event pollers this event source can scale up to. The range is between 1 and 2000.
* `minimum_pollers` - (Optional) Minimum number of event pollers this event source can scale down to. The range is between 1 and 200.
* `poller_group_name` - (Optional) The name of the provisioned poller group used to group multiple ESMs within the event source's VPC to share Event Poller Unit (EPU) capacity. You can use this option to optimize Provisioned mode costs for your ESMs. You can group up to 100 ESMs per poller group and aggregate maximum pollers across all ESMs in a group cannot exceed 2000.

### scaling_config Configuration Block

Expand Down
Loading