@@ -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
228242resource "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
0 commit comments