-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.yaml
111 lines (109 loc) · 4.75 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
101
102
103
104
105
106
107
108
109
110
111
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Description: >
Project Daylily: SAM Template To Create a Step Function using SNS (Simple Notification Service) and Wait state.
Parameters:
###################################### Project Name and Environment ##############################
ProjectName:
Default: daylily
Type: String
Description: "The Project Name."
Environment:
Default: devl
Type: String
Description: "The Environment Name."
CodeRepoS3Bucket:
Default: subhamay-projects-repository-us-east-1
Type: String
Description: The S3 bucket storing the code repo (nested CloudFormation templates)
###################################### KMS Key ###################################################
KmsMasterKeyAlias:
Default: "SB-KMS"
Type: String
Description: "The KMS Master Key Alias To Be Used For Server Side Encryption."
KmsMasterKeyId:
Default: "e4c733c5-9fbe-4a90-bda1-6f0362bc9b89"
Type: String
Description: "The KMS Key Id Used For Encryption."
###################################### SNS Topic With Email Subscription #########################
SNSTopicBaseName:
Default: "daylily-sns-topic"
Type: String
Description: "The Base Name Of The Sns Topic. The Region And Environment Will Be Added As Suffix By The Template."
SNSTopicDisplayName:
Default: "Daylily SNS Topic used in the step function using SNS and Wait state."
Type: String
Description: "The SNS Topic Display Name."
SNSSubscriptionEmail:
Default: "subhamay.aws@mailinator.com"
Type: String
Description: "The Subscription Email For The Sns Topic."
#################################### State Machine ###########################################
StepFunctionBaseName:
Default: daylily-state-machine
Type: String
Description: "The Base Name The Lambda Function. The Region And Environment Will Be Added As Suffix By The Template."
StepFunctionExecutionRoleName:
Default: daylily-step-function-role
Type: String
Description: "The Execution Role Of The State Machine."
StepFunctionExecutionPolicyName:
Default: daylily-step-function-policy
Type: String
Description: "The Execution Policy Of The State Machine."
Resources:
###################################### SNS Topic With Email Subscription #########################
DaylilySNSTopic:
DeletionPolicy: Delete
UpdateReplacePolicy: Retain
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: !Sub "https://${CodeRepoS3Bucket}.s3.amazonaws.com/0086-daylily/cft/nested-stacks/sns-stack.yaml"
Parameters:
ProjectName: !Ref ProjectName
Environment: !Ref Environment
TopicBaseName: !Ref SNSTopicBaseName
TopicDisplayName: !Ref SNSTopicDisplayName
SubscriptionEmail: !Ref SNSSubscriptionEmail
KmsMasterKeyAlias: !Ref KmsMasterKeyAlias
TimeoutInMinutes: 15
###################################### State Machine Execution Role ##############################
DaylilyIAMExecutionRole:
DeletionPolicy: Delete
UpdateReplacePolicy: Retain
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: !Sub "https://${CodeRepoS3Bucket}.s3.amazonaws.com/0086-daylily/cft/nested-stacks/iam-role-stack.yaml"
Parameters:
ProjectName: !Ref ProjectName
Environment: !Ref Environment
StepFunctionExecutionRoleName: !Ref StepFunctionExecutionRoleName
StepFunctionExecutionPolicyName: !Ref StepFunctionExecutionPolicyName
SNSTopicBaseName: !Ref SNSTopicBaseName
KmsMasterKeyId: !Ref KmsMasterKeyId
TimeoutInMinutes: 15
###################################### State Machine #############################################
DaylilyStateMachine:
Type: AWS::Serverless::StateMachine
Properties:
Name: !Sub '${StepFunctionBaseName}-${Environment}-${AWS::Region}'
DefinitionUri: statemachine/state-machine.asl.json
Role: !GetAtt DaylilyIAMExecutionRole.Outputs.StepFunctionExecutionRoleArn
DefinitionSubstitutions:
SNSTopicArn: !GetAtt DaylilySNSTopic.Outputs.SNSTopicArn
Tags:
ProjectName: !Ref ProjectName
Environment: !Ref Environment
Outputs:
DaylilySNSTopicArn:
Description: "Daylily SNS Topic Arn"
Value: !GetAtt DaylilySNSTopic.Outputs.SNSTopicArn
DaylilySNSSubscriptionArn:
Description: "Daylily SNS Subscription Arn"
Value: !GetAtt DaylilySNSTopic.Outputs.SNSSubscriptionArn
DaylilyStateMachineArn:
Description: "Daylily State machine ARN"
Value: !GetAtt DaylilyStateMachine.Arn
DaylilyStateMachineRoleArn:
Description: "IAM Role created for Stock Trading State machine based on the specified SAM Policy Templates"
Value: !GetAtt DaylilyIAMExecutionRole.Outputs.StepFunctionExecutionRoleArn