Comments (3)
Hey, thanks for the feature request !
It is doable, and have already done it in the past for other projects, although will not have time to do it this week, I will certainly implement it now that I can also take advantage of some of the new HCL syntax from 0.12.
As a guide for you, to configure the lambda in a VPC subnet you need to specify in the
aws_lambda_function
this property as well
vpc_config {
security_group_ids = ["${data.aws_security_group.vpc_security_group.id}"]
subnet_ids = ["${data.aws_subnet.vpc_subnet_a.id}", "${data.aws_subnet.vpc_subnet_b.id}"]
}
Given this is the module that also creates DynamoDB, I imagine you also need DynamoDB access. In the current format of the module it has direct access to DDB due to the lambda being exposed to WAN internet. Having it in VPC will require you to add a DynamoDB VPC Endpoint for the Lambda to access DDB.
resource "aws_vpc_endpoint" "vpc_dynamodb_endpoint" {
vpc_id = "${module.vpc.vpc_id}"
service_name = "com.amazonaws.${var.region}.dynamodb"
vpc_endpoint_type = "Gateway"
}
as it is a specific route location, you will also need to add the endpoint in the route table
resource "aws_vpc_endpoint_route_table_association" "vpc_dynamodb_endpoint_route" {
route_table_id = "${module.subnets_public.route_table_id}"
vpc_endpoint_id = "${aws_vpc_endpoint.vpc_dynamodb_endpoint.id}"
}
Also don't forget to add the aws_vpc_endpoint.vpc_dynamodb_endpoint.prefix_list_id
to a Security Group egress.
resource "aws_security_group_rule" "lambda_reminders_sec_egress_ipv4_dynamodb" {
type = "egress"
from_port = 0
to_port = 65535
protocol = -1
security_group_id = "$}"
prefix_list_ids = ["${aws_vpc_endpoint.vpc_dynamodb_endpoint.prefix_list_id}"]
}
from terraform-aws-api-gateway-lambda-dynamodb.
@crisboarna - thank you very much for super verbose answer, I will first get it working and eventually will extend the module. Its really nice work.
from terraform-aws-api-gateway-lambda-dynamodb.
v1.16.0 adds Lambda VPC/Layers support.
from terraform-aws-api-gateway-lambda-dynamodb.
Related Issues (7)
- Seems like there is a bug HOT 4
- Question: Do I need to zip Java lambda in form of JAR file? HOT 1
- Error: Unsupported block type on ..\..\modules\global\iam\main.tf line 4, in data "template_file" "lambda_dynamodb_policy": 4: vars { HOT 3
- Seems like general reference complex variable doesn't work HOT 4
- IAM module uses wrong naming conventions. HOT 1
- "lambda_code_s3_bucket" argument invalid in README.MD example
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from terraform-aws-api-gateway-lambda-dynamodb.