Skip to content

Commit 268975c

Browse files
davidegiunchiantonbabenkobryantbiggs
authored
feat: Support maximum concurrency of Lambda with SQS as an event source (#402)
Co-authored-by: Anton Babenko <[email protected]> Co-authored-by: Bryant Biggs <[email protected]>
1 parent 0003c43 commit 268975c

File tree

16 files changed

+34
-25
lines changed

16 files changed

+34
-25
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/antonbabenko/pre-commit-terraform
3-
rev: v1.77.0
3+
rev: v1.77.1
44
hooks:
55
- id: terraform_fmt
66
- id: terraform_validate

examples/alias/main.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ provider "aws" {
22
region = "eu-west-1"
33

44
# Make it faster by skipping something
5-
skip_get_ec2_platforms = true
65
skip_metadata_api_check = true
76
skip_region_validation = true
87
skip_credentials_validation = true

examples/async/main.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ provider "aws" {
22
region = "eu-west-1"
33

44
# Make it faster by skipping something
5-
skip_get_ec2_platforms = true
65
skip_metadata_api_check = true
76
skip_region_validation = true
87
skip_credentials_validation = true

examples/build-package/main.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ provider "aws" {
22
region = "eu-west-1"
33

44
# Make it faster by skipping something
5-
skip_get_ec2_platforms = true
65
skip_metadata_api_check = true
76
skip_region_validation = true
87
skip_credentials_validation = true

examples/code-signing/main.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ provider "aws" {
22
region = "eu-west-1"
33

44
# Make it faster by skipping something
5-
skip_get_ec2_platforms = true
65
skip_metadata_api_check = true
76
skip_region_validation = true
87
skip_credentials_validation = true

examples/complete/main.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ provider "aws" {
22
region = "eu-west-1"
33

44
# Make it faster by skipping something
5-
skip_get_ec2_platforms = true
65
skip_metadata_api_check = true
76
skip_region_validation = true
87
skip_credentials_validation = true

examples/container-image/main.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ provider "aws" {
88
region = "eu-west-1"
99

1010
# Make it faster by skipping something
11-
skip_get_ec2_platforms = true
1211
skip_metadata_api_check = true
1312
skip_region_validation = true
1413
skip_credentials_validation = true

examples/deploy/main.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ provider "aws" {
22
region = "eu-west-1"
33

44
# Make it faster by skipping something
5-
skip_get_ec2_platforms = true
65
skip_metadata_api_check = true
76
skip_region_validation = true
87
skip_credentials_validation = true

examples/event-source-mapping/main.tf

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,20 @@ provider "aws" {
22
region = "eu-west-1"
33

44
# Make it faster by skipping something
5-
skip_get_ec2_platforms = true
5+
66
skip_metadata_api_check = true
77
skip_region_validation = true
88
skip_credentials_validation = true
99
skip_requesting_account_id = true
1010
}
1111

12+
data "aws_availability_zones" "available" {}
13+
14+
locals {
15+
vpc_cidr = "10.0.0.0/16"
16+
azs = slice(data.aws_availability_zones.available.names, 0, 3)
17+
}
18+
1219
####################################################
1320
# Lambda Function with event source mapping
1421
####################################################
@@ -20,12 +27,15 @@ module "lambda_function" {
2027
handler = "index.lambda_handler"
2128
runtime = "python3.8"
2229

23-
source_path = "${path.module}/../fixtures/python3.8-app1"
30+
source_path = "${path.module}/../fixtures/python3.8-app1/index.py"
2431

2532
event_source_mapping = {
2633
sqs = {
2734
event_source_arn = aws_sqs_queue.this.arn
2835
function_response_types = ["ReportBatchItemFailures"]
36+
scaling_config = {
37+
maximum_concurrency = 20
38+
}
2939
}
3040
dynamodb = {
3141
event_source_arn = aws_dynamodb_table.this.stream_arn
@@ -216,21 +226,26 @@ resource "aws_kinesis_stream" "this" {
216226
}
217227

218228
# Amazon MQ
219-
data "aws_vpc" "default" {
220-
default = true
221-
}
229+
module "vpc" {
230+
source = "terraform-aws-modules/vpc/aws"
231+
version = "~> 3.0"
232+
233+
name = random_pet.this.id
234+
cidr = local.vpc_cidr
235+
236+
azs = local.azs
237+
public_subnets = [for k, v in local.azs : cidrsubnet(local.vpc_cidr, 8, k)]
222238

223-
data "aws_security_group" "default" {
224-
vpc_id = data.aws_vpc.default.id
225-
name = "default"
239+
enable_nat_gateway = false
226240
}
227241

228242
resource "aws_mq_broker" "this" {
229243
broker_name = random_pet.this.id
230244
engine_type = "RabbitMQ"
231-
engine_version = "3.8.11"
245+
engine_version = "3.10.10"
232246
host_instance_type = "mq.t3.micro"
233-
security_groups = [data.aws_security_group.default.id]
247+
security_groups = [module.vpc.default_security_group_id]
248+
subnet_ids = slice(module.vpc.public_subnets, 0, 1)
234249

235250
user {
236251
username = random_pet.this.id

examples/multiple-regions/main.tf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ provider "aws" {
22
region = "eu-west-1"
33

44
# Make it faster by skipping something
5-
skip_get_ec2_platforms = true
65
skip_metadata_api_check = true
76
skip_region_validation = true
87
skip_credentials_validation = true
@@ -14,7 +13,6 @@ provider "aws" {
1413
alias = "us-east-1"
1514

1615
# Make it faster by skipping something
17-
skip_get_ec2_platforms = true
1816
skip_metadata_api_check = true
1917
skip_region_validation = true
2018
skip_credentials_validation = true

0 commit comments

Comments
 (0)