-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathtemplate.yml
101 lines (93 loc) · 2.95 KB
/
template.yml
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
AWSTemplateFormatVersion: 2010-09-09
Transform: AWS::Serverless-2016-10-31
Metadata:
AWS::ServerlessRepo::Application:
Name: propagate-cfn-tags
Description: Propagates CloudFormation's stack tags to resources that are currently not propagated automatically - e.g. CloudWatch Logs.
Author: Lumigo
SpdxLicenseId: Apache-2.0
LicenseUrl: LICENSE
ReadmeUrl: README.md
Labels: ['lambda', 'cloudformation', 'tags', 'devops']
HomePageUrl: https://github.com/lumigo-io/SAR-Propagate-CFN-Tags.git
SemanticVersion: 1.11.0
SourceCodeUrl: https://github.com/lumigo-io/SAR-Propagate-CFN-Tags.git
Globals:
Function:
Runtime: nodejs14.x
MemorySize: 128
Environment:
Variables:
LOG_LEVEL: INFO
Resources:
Propagate:
Type: AWS::Serverless::Function
Properties:
Handler: src/functions/propagate.handler
Timeout: 60
Policies:
- Statement:
Effect: Allow
Action:
- cloudformation:DescribeStacks
- cloudformation:DescribeStackResources
- logs:TagLogGroup
- states:TagResource
- sqs:TagQueue
Resource: "*"
Events:
CloudFormationEvent:
Type: CloudWatchEvent
Properties:
Pattern:
source:
- aws.cloudformation
detail-type:
- AWS API Call via CloudTrail
detail:
eventSource:
- cloudformation.amazonaws.com
eventName:
- CreateStack
- UpdateStack
- ExecuteChangeSet
PropagateLogGroup:
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: !Sub /aws/lambda/${Propagate}
PropagateAll:
Type: AWS::Serverless::Function
Properties:
Handler: src/functions/propagate-all.handler
Timeout: 840
Policies:
- Statement:
Effect: Allow
Action:
- cloudformation:ListStacks
- cloudformation:DescribeStacks
- cloudformation:DescribeStackResources
- logs:TagLogGroup
- states:TagResource
- sqs:TagQueue
Resource: "*"
PropagateAllLogGroup:
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: !Sub /aws/lambda/${PropagateAll}
LambdaInvocationCustomResource:
Type: AWS::Serverless::Application
Properties:
Location:
ApplicationId: arn:aws:serverlessrepo:us-east-1:374852340823:applications/lambda-invocation-cfn-custom-resource
SemanticVersion: 1.5.0
# custom resource to invoke the PropagateAll function during deployment
InvokePropagateAll:
Type: Custom::LambdaInvocation
DependsOn:
- PropagateAll
- LambdaInvocationCustomResource
Properties:
ServiceToken: !GetAtt LambdaInvocationCustomResource.Outputs.FunctionArn
FunctionName: !Ref PropagateAll
Payload: {}