-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtemplate.yaml
84 lines (74 loc) · 2.53 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
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Description: >
serverless-account-signup-service
Parameters:
Email:
Type: String
Description: A valid email that will be subscribed to the SNS topic for approval or deny notifications
AllowedPattern: "^(.+)@(\\S+)$"
Resources:
NewAccountApplicationStateMachine:
Type: AWS::Serverless::StateMachine
Properties:
DefinitionUri: statemachine/application_service.asl.json
DefinitionSubstitutions:
CheckIdentityFunctionArn: !GetAtt CheckIdentityFunction.Arn
CheckAddressFunctionArn: !GetAtt CheckAddressFunction.Arn
AccountsTable: !Ref AccountsTable
SendCustomerNotificationSNSTopicArn: !Ref SendCustomerNotificationSNSTopic
HomeInsuranceInterestQueueArn: !Ref HomeInsuranceInterestQueue
Policies:
- LambdaInvokePolicy:
FunctionName: !Ref CheckIdentityFunction
- LambdaInvokePolicy:
FunctionName: !Ref CheckAddressFunction
- DynamoDBWritePolicy:
TableName: !Ref AccountsTable
- SNSPublishMessagePolicy:
TopicName: !GetAtt SendCustomerNotificationSNSTopic.TopicName
- SQSSendMessagePolicy:
QueueName: !GetAtt HomeInsuranceInterestQueue.QueueName
CheckIdentityFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: functions/check-identity/
Handler: app.lambdaHandler
Runtime: nodejs14.x
CheckIdentityFunctionLogGroup:
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: !Sub "/aws/lambda/${CheckIdentityFunction}"
RetentionInDays: 7
CheckAddressFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: functions/check-address/
Handler: app.lambdaHandler
Runtime: nodejs14.x
CheckAddressFunctionLogGroup:
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: !Sub "/aws/lambda/${CheckAddressFunction}"
RetentionInDays: 7
AccountsTable:
Type: AWS::Serverless::SimpleTable
Properties:
PrimaryKey:
Name: email
Type: String
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
SendCustomerNotificationSNSTopic:
Type: AWS::SNS::Topic
Properties:
Subscription:
- Endpoint: !Ref Email
Protocol: email
HomeInsuranceInterestQueue:
Type: AWS::SQS::Queue
Outputs:
NewAccountApplicationStateMachine:
Description: "New Account Application State Machine ARN"
Value: !Ref NewAccountApplicationStateMachine