forked from dmt/code-deploy-set-target-group
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.yaml
45 lines (45 loc) · 1.55 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
AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Description: 'SAM template for Serverless framework service: '
Parameters:
CodeDeploySnsTopic:
Type: String
Default: codedeploy
Description: The SNS topic getting code deploy notifications
Resources:
CodeDeploySetTargetGroupDevSetTargetGroup:
Type: 'AWS::Serverless::Function'
Properties:
Handler: lib/lambdas.setTargetGroup
Runtime: nodejs14.x
Description: >-
Update the target group of the asg after a successfull blue/green
codedeploy.
MemorySize: 128
Timeout: 3
Policies:
- Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- 'codedeploy:GetDeployment'
Resource: !Sub 'arn:aws:ec2:${AWS::Region}:${AWS::AccountId}:deploymentgroup:*'
- Effect: Allow
Action:
- 'autoscaling:AttachLoadBalancerTargetGroups'
Resource: !Sub 'arn:aws:ec2:${AWS::Region}:${AWS::AccountId}:autoScalingGroup:*:autoScalingGroupName/*'
- Effect: Allow
Action:
- 'autoscaling:DescribeLoadBalancerTargetGroups'
Resource:
- '*'
- Effect: Allow
Action:
- 'elasticloadbalancing:DescribeTargetGroups'
Resource:
- '*'
Events:
Event1:
Type: SNS
Properties:
Topic: !Sub 'arn:aws:sns:${AWS::Region}:${AWS::AccountId}:${CodeDeploySnsTopic}'