Skip to content

Commit 2454dcd

Browse files
committed
updated readme, added required roles to serverless.yml file
1 parent 2a50d37 commit 2454dcd

File tree

4 files changed

+32
-19
lines changed

4 files changed

+32
-19
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules
22
.webpack
3+
.serverless

README.md

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[![serverless](http://public.serverless.com/badges/v3.svg)](http://www.serverless.com)
22

3-
# aws-node-elasticache-redis
3+
# aws-node-elasticache-vpc
44
> A set of serverless functions using elasticache (redis) within VPC
55
66
---
@@ -9,27 +9,29 @@
99

1010
In order to install and run this example you need an AWS accounts credentials configured with your system. To get started with AWS account configuration, please follow this [link](https://serverless.com/framework/docs/providers/aws/guide/credentials/)
1111

12-
1. Clone aws-node-elasticache-redis and install npm packages
12+
1. Clone aws-node-elasticache-vpc and install npm packages
1313
```
14-
git clone [email protected]:ankkho/aws-node-elasticache-redis.git
15-
cd aws-node-elasticache-redis
14+
git clone [email protected]:ankkho/aws-node-elasticache-vpc.git
15+
cd aws-node-elasticache-vpc
1616
npm install
1717
export REGION='your-desired-aws-region' eg: 'ap-south-1'
1818
```
1919

20-
> Comment from line number 17 to 24. Else you'll get an error, since serverless tires to fetch those resources which are not been present yet.
20+
*NOTE*
21+
> Before you run `sls deploy`. Comment line number 17 and from 28-34. Else you'll get an error, since serverless try to fetch (elasticache and vpc) resources which are not currently present.
2122
22-
> Once you run `sls deploy`, then uncomment those lines and run `sls deploy` once again.
23+
> Once deployment is done uncomment those lines and run `sls deploy` once again.
2324
2425
*Deploy using sls deploy*
2526
```
26-
sls deploy --stage <any stage> --region <your region>
27+
sls deploy
2728
```
2829

2930
### Folder Structure
3031

31-
functions -- contains all business logic required for a function
32+
> functions -- contains all business logic required for a function
3233
33-
handler.js -- lambda handler
34+
> handler.js -- lambda handler
3435
35-
lib -- acts as middleware. You can perform following operations: schema validations, checking user roles (if any) etc..
36+
> lib -- acts as middleware. You can perform following types of operations:
37+
schema validation, check users role (if any) etc..

aws/redis.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ bluebird.promisifyAll(redis.RedisClient.prototype)
99
bluebird.promisifyAll(redis.Multi.prototype)
1010

1111
const createRedisClient = () => {
12-
const clientObj = redis.createClient(6379, process.env.cacheURL, { no_ready_check: true })
12+
const clientObj = redis.createClient(6379, process.env.cacheUrl, { no_ready_check: true })
1313

1414
clientObj.on('error', (err) => {
1515
console.log(`Error while creating redis client: ${err}`)

serverless.yml

+18-8
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,24 @@ provider:
1414
environment: dev
1515
serviceName: serverless-sample
1616
environment:
17-
# cacheUrl: ${cf:serverless-sample-dev.cacheUrl}
18-
# vpc:
19-
# securityGroupIds:
20-
# - ${cf:serverless-sample-dev.VPCSecurityGroup}
21-
# - ${cf:serverless-sample-dev.RedisSecurityGroup}
22-
# subnetIds:
23-
# - ${cf:serverless-sample-dev.PrivateSubnetA}
24-
# - ${cf:serverless-sample-dev.PublicSubnetB}
17+
cacheUrl: ${cf:serverless-sample-dev.cacheUrl}
18+
iamRoleStatements:
19+
- Effect: 'Allow'
20+
Action:
21+
- "logs:CreateLogGroup"
22+
- "logs:CreateLogStream"
23+
- "logs:PutLogEvents"
24+
- "ec2:CreateNetworkInterface"
25+
- "ec2:DeleteNetworkInterface"
26+
- "ec2:DescribeNetworkInterfaces"
27+
Resource: '*'
28+
vpc:
29+
securityGroupIds:
30+
- ${cf:serverless-sample-dev.VPCSecurityGroup}
31+
- ${cf:serverless-sample-dev.RedisSecurityGroup}
32+
subnetIds:
33+
- ${cf:serverless-sample-dev.PrivateSubnetA}
34+
- ${cf:serverless-sample-dev.PublicSubnetB}
2535
package:
2636
exclude:
2737
- ./node_modules/**

0 commit comments

Comments
 (0)