-
Notifications
You must be signed in to change notification settings - Fork 87
/
Copy pathtemplate.yaml
69 lines (65 loc) · 1.94 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
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Validation hooks for trivia backend
Parameters:
TriviaBackendDomain:
Type: String
Default: 'api.reinvent-trivia.com'
TriviaBackendTestPort:
Type: Number
Default: 9002
Resources:
PreTrafficHook:
Type: AWS::Serverless::Function
Properties:
FunctionName: !Join
- '-'
- - 'CodeDeployHook_'
- !Ref "AWS::StackName"
- 'pre-traffic-hook'
CodeUri: ./
Timeout: 300
Handler: pre-traffic-hook.handler
Policies:
- Version: "2012-10-17"
Statement:
- Effect: "Allow"
Action:
- "codedeploy:PutLifecycleEventHookExecutionStatus"
- "codedeploy:CreateCloudFormationDeployment"
Resource:
!Sub 'arn:${AWS::Partition}:codedeploy:${AWS::Region}:${AWS::AccountId}:deploymentgroup:*/*'
Runtime: nodejs14.x
DeploymentPreference:
Enabled: false
Role: ""
Environment:
Variables:
TargetUrl: !Join # Example: https://api.reinvent-trivia.com:9002/api/trivia/all
- ''
- - 'https://'
- !Ref TriviaBackendDomain
- ':'
- !Ref TriviaBackendTestPort
- '/api/trivia/all'
CodeDeployHookRole:
Type: AWS::IAM::Role
Properties:
RoleName: !Sub 'CodeDeployHookRole_${AWS::StackName}'
AssumeRolePolicyDocument:
Statement:
- Effect: Allow
Principal:
Service:
- codedeploy.amazonaws.com
Action:
- sts:AssumeRole
Path: /
Policies:
- PolicyName: "Invoke-Hooks"
PolicyDocument:
Statement:
- Effect: Allow
Action:
- "lambda:InvokeFunction"
Resource: !Sub 'arn:${AWS::Partition}:lambda:${AWS::Region}:${AWS::AccountId}:function:CodeDeployHook_*'