Skip to content

Commit 16988e4

Browse files
dave-grahamjlhood
authored andcommitted
docs: Update examples that access DynamoDB to use Policy Templates (#759)
1 parent 36fdb27 commit 16988e4

File tree

2 files changed

+25
-20
lines changed

2 files changed

+25
-20
lines changed

examples/2016-10-31/api_backend/template.yaml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
AWSTemplateFormatVersion: '2010-09-09'
1+
AWSTemplateFormatVersion: "2010-09-09"
22
Transform: AWS::Serverless-2016-10-31
33
Description: Simple CRUD webservice. State is stored in a SimpleTable (DynamoDB) resource.
44
Resources:
@@ -8,7 +8,9 @@ Resources:
88
Handler: index.get
99
Runtime: nodejs6.10
1010
CodeUri: src/
11-
Policies: AmazonDynamoDBReadOnlyAccess
11+
Policies:
12+
- DynamoDBReadPolicy:
13+
TableName: !Ref Table
1214
Environment:
1315
Variables:
1416
TABLE_NAME: !Ref Table
@@ -25,7 +27,9 @@ Resources:
2527
Handler: index.put
2628
Runtime: nodejs6.10
2729
CodeUri: src/
28-
Policies: AmazonDynamoDBFullAccess
30+
Policies:
31+
- DynamoDBCrudPolicy:
32+
TableName: !Ref Table
2933
Environment:
3034
Variables:
3135
TABLE_NAME: !Ref Table
@@ -42,7 +46,9 @@ Resources:
4246
Handler: index.delete
4347
Runtime: nodejs6.10
4448
CodeUri: src/
45-
Policies: AmazonDynamoDBFullAccess
49+
Policies:
50+
- DynamoDBCrudPolicy:
51+
TableName: !Ref Table
4652
Environment:
4753
Variables:
4854
TABLE_NAME: !Ref Table
@@ -57,7 +63,6 @@ Resources:
5763
Type: AWS::Serverless::SimpleTable
5864

5965
Outputs:
60-
ApiURL:
61-
Description: "API endpoint URL for Prod environment"
62-
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/resource/"
63-
66+
ApiURL:
67+
Description: "API endpoint URL for Prod environment"
68+
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/resource/"
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
1-
AWSTemplateFormatVersion: '2010-09-09'
1+
AWSTemplateFormatVersion: "2010-09-09"
22
Transform: AWS::Serverless-2016-10-31
33
Description: IoT -> Lambda -> DynamoDB
44
Resources:
5-
IoTFunction:
5+
IoTFunction:
66
Type: AWS::Serverless::Function
7-
Properties:
7+
Properties:
88
Handler: index.handler
99
Runtime: nodejs6.10
1010
CodeUri: src/
11-
Policies: AmazonDynamoDBFullAccess
12-
Environment:
13-
Variables:
14-
TABLE_NAME:
11+
Policies:
12+
- DynamoDBCrudPolicy:
13+
TableName: !Ref Table
14+
Environment:
15+
Variables:
16+
TABLE_NAME:
1517
Ref: Table
16-
Events:
17-
IoT:
18+
Events:
19+
IoT:
1820
Type: IoTRule
19-
Properties:
21+
Properties:
2022
AwsIotSqlVersion: 2016-03-23
2123
Sql: "SELECT * FROM 'iot2ddb'"
2224
Table:
@@ -25,5 +27,3 @@ Resources:
2527
PrimaryKey:
2628
Name: id
2729
Type: String
28-
29-

0 commit comments

Comments
 (0)