Skip to content

Commit

Permalink
Merge pull request rubyonjets#493 from iqre8/patch-1
Browse files Browse the repository at this point in the history
Update activerecord.md
  • Loading branch information
tongueroo authored Dec 4, 2020
2 parents 37f7be6 + 4d84d51 commit 48c2baa
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions docs/_docs/database/activerecord.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,24 @@ On AWS Lambda, there's something called the [Lambda Execution Context](https://d

It's also worth noting that AWS clients provided by the [Jets::AwsServices](https://github.com/tongueroo/jets/blob/master/lib/jets/aws_services.rb) module similarly leverage the Lambda Execution context. IE: The clients get reused between lambda calls.

## RDS Database Support

When creating a database on AWS RDS, you can select between mySQL and PostgreSQL.
When you've created an RDS it will create/use a VPC with at 3 subnets.

To use it with Jets you'll need to do several things.
Create a lambda security group for lambda functions. No Inbound rules.
Create a cloudformation security group for lambda functions. Inbound rules would be HTTPS from the lambda security group.
[Create an endpoint](https://docs.aws.amazon.com/vpc/latest/userguide/vpce-interface.html#create-interface-endpoint) to allow the lambda security group to cloud formation.
Create a security group to allow traffic from the lambda security group to the RDS VPC for the DB Engine. Inbound rules for PGSQL would be from TCP/5432 - Postgresql from the lambda security group.

Add the vpc_config for the lambda functions in config/application.rb:

config.function.vpc_config = {
security_group_ids: %w[ <lambda security group> ],
subnet_ids: %w[ <rds subnet 1> <rds subnet 2> <rds subnet 3> ]
}

## Aurora Database Support

Aurora should work since it is MySQL compatible. Note, with Aurora, your Lambda functions must be configured with a VPC.
Expand Down

0 comments on commit 48c2baa

Please sign in to comment.