This repository has been archived by the owner on May 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
/
template.yaml
63 lines (59 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
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
aws-dx-monitor
The purpose of aws-dx-monitor is to monitor AWS Direct Connect runtime configuration items with Amazon CloudWatch. The system is driven by Amazon CloudWatch Events and AWS Lambda.
Globals:
Function:
Timeout: 3
Resources:
MonitorFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: monitor/
Handler: app.lambda_handler
Runtime: python3.8
Timeout: 40
Events:
Timer:
Type: Schedule
Properties:
Schedule: "rate(1 minute)"
Enabled: True
Role: !GetAtt MonitorFunctionRole.Arn
MonitorFunctionRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Statement:
- Action: ['sts:AssumeRole']
Effect: Allow
Principal:
Service: [lambda.amazonaws.com]
Version: '2012-10-17'
Path: /
Policies:
- PolicyName: DxMonitorFunctionPolicy
PolicyDocument:
Version: '2012-10-17'
Statement:
- Action:
- 'cloudwatch:PutMetricData'
- 'directconnect:DescribeConnections'
- 'directconnect:DescribeConnectionsOnInterconnect'
- 'directconnect:DescribeDirectConnectGateways'
- 'directconnect:DescribeInterconnects'
- 'directconnect:DescribeVirtualGateways'
- 'directconnect:DescribeVirtualInterfaces'
- 'logs:CreateLogGroup'
- 'logs:CreateLogStream'
- 'logs:PutLogEvents'
Effect: Allow
Resource: '*'
Outputs:
MonitorFunction:
Description: "AWS DX Monitor Function ARN"
Value: !GetAtt MonitorFunction.Arn
MonitorFunctionIamRole:
Description: "Implicit IAM Role created for the Monitor function"
Value: !GetAtt MonitorFunctionRole.Arn