-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.yaml
100 lines (93 loc) · 2.48 KB
/
template.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Parameters:
TestTableName:
Type: String
Default: 'SamTestTable'
MinLength: 3
MaxLength: 50
AllowedPattern: ^[A-Za-z_]+$
Resources:
TestSchedule:
Type: AWS::Serverless::Function
Properties:
Runtime: nodejs8.10
Handler: index.handler
Description: Test Schedule to trigger TestSNS with TestTopic
# Using the compiled code in dist directory
CodeUri: ./dist/testSchedule
FunctionName: testSchedule
Timeout: 15
Environment:
Variables:
TEST_SNS: !Ref TestTopic
Events:
# Schedule type is created as a CloudWatch Event Rule
TestSchedule:
Type: Schedule
Properties:
Schedule: rate(30 minutes)
# To trigger the SNS Topic - include the policy to publish to that topic
Policies:
- SNSPublishMessagePolicy:
TopicName: !GetAtt TestTopic.TopicName
TestSNS:
Type: AWS::Serverless::Function
Properties:
Runtime: nodejs8.10
Handler: index.handler
Description: Single SNS event handler test
CodeUri: ./dist/testSns
FunctionName: testSns
Timeout: 15
Environment:
Variables:
BUCKET: !Ref TestS3Bucket
Events:
TestEvent:
Type: SNS
Properties:
Topic: !Ref TestTopic
Policies:
- S3CrudPolicy:
BucketName: !Ref TestS3Bucket
TestS3:
Type: AWS::Serverless::Function
Properties:
Runtime: nodejs8.10
Handler: index.handler
Description: Single S3 event handler test
CodeUri: ./dist/testS3
FunctionName: testS3
Timeout: 30
Environment:
Variables:
DYNAMO_TABLE: !Ref TestTableName
Events:
NewObject:
Type: S3
Properties:
Bucket: !Ref TestS3Bucket
Events: s3:ObjectCreated:*
Policies:
- DynamoDBCrudPolicy:
TableName: !Ref TestTable
TestTopic:
Type: AWS::SNS::Topic
TestS3Bucket:
Type: AWS::S3::Bucket
Properties:
BucketName: sam-test-bucket-cs
TestTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: !Ref TestTableName
AttributeDefinitions:
- AttributeName: id
AttributeType: S
KeySchema:
- AttributeName: id
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5