Skip to content

Commit e1ed462

Browse files
authored
Merge pull request #8 from tinymarsracing/patch-6
fixed jwt env vars & moved sensitive vpc settings into env vars
2 parents 89694b7 + 0a083cd commit e1ed462

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

.env.template

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ export JWT_PG_TYPE_IDENTIFIER="forum_example.jwt_token"
99
export AWS_SERVICE_NAME="my-postgraphile-lambda"
1010
export AWS_REGION="us-east-1"
1111
export AWS_STAGE="dev"
12+
export AWS_VPC_SECURITY_GROUP_IDS="sg-1234asdf"
13+
export AWS_VPC_SUBNET_IDS="subnet-2345sdfg,subnet-3456dfgh,subnet-4567fghj"

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,21 @@ Achieving this can be a bit confusing if you're new to VPCs. When you create you
7070

7171
If you want to learn more, here's some more info on [VPCs in the context of RDS](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_VPC.WorkingWithRDSInstanceinaVPC.html) and on [security groups](https://docs.aws.amazon.com/vpc/latest/userguide/VPC_SecurityGroups.html).
7272

73-
Now, we just have to make sure that our Lambda is created within our VPC as well. For that just add the following to the specifications of your `graphql` function in your `serverless.yml` file:
73+
Now, we just have to make sure that our Lambda is created within our VPC as well. For that just use the AWS_VPC environment variables from the `.env.template` and add the following to the specifications of your `graphql` function in your `serverless.yml` file:
7474

7575
```
7676
vpc:
7777
securityGroupIds:
78-
- sg-123456
78+
"Fn::Split":
79+
- ","
80+
- ${env:AWS_VPC_SECURITY_GROUP_IDS}
7981
subnetIds:
80-
- subnet-123
81-
- subnet-456
82-
- subnet-789
82+
"Fn::Split":
83+
- ","
84+
- ${env:AWS_VPC_SUBNET_IDS}
8385
```
8486

85-
You can find all these values in the RDS console under "Connectivity & Security". (As the securityGroupId it's enough to use the `default` one: this basically makes the Lambda function part of the VPC.)
87+
You can find all these values in the RDS console under "Connectivity & Security". (As the securityGroupId it's enough to use the `default` one: this basically makes the Lambda function part of the VPC. There should be 3 subnetIds.)
8688

8789
(You will also need to add `"iam:AttachRolePolicy"` to the permissions of the Serverless IAM role policy you will later create.)
8890

serverless.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@ functions:
3030
environment:
3131
DATABASE_URL: ${env:DATABASE_URL}
3232
DATABASE_SCHEMAS: ${env:DATABASE_SCHEMAS}
33+
JWT_SECRET: ${env:JWT_SECRET}
34+
JWT_PG_TYPE_IDENTIFIER: ${env:JWT_PG_TYPE_IDENTIFIER}

0 commit comments

Comments
 (0)