-
Notifications
You must be signed in to change notification settings - Fork 85
/
CloudWatchAutoAlarms-CrossAccountRole.yaml
75 lines (71 loc) · 2.55 KB
/
CloudWatchAutoAlarms-CrossAccountRole.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
AWSTemplateFormatVersion: '2010-09-09'
Description: Cross-Account role for CloudWatchAutoAlarms AWS Lambda Function
Metadata:
AWS::CloudFormation::Interface:
ParameterGroups:
- Label:
default: "CloudWatchAutoAlarms Configuration"
Parameters:
- AlarmIdentifierPrefix
- CloudWatchAutoAlarmsAccount
ParameterLabels:
AlarmIdentifierPrefix:
default: "Alarm Identifier Prefix"
CloudWatchAutoAlarmsAccount:
default: "CloudWatch Auto Alarms Account ID"
Parameters:
AlarmIdentifierPrefix:
Type: String
Description: "Prefix for CloudWatch Alarm Identifiers"
Default: "AutoAlarm"
CloudWatchAutoAlarmsAccount:
Type: String
Description: "The account where the CloudWatch Auto Alarms function is deployed"
Resources:
CloudWatchAutoAlarmCrossAccountRole:
Type: AWS::IAM::Role
Properties:
RoleName: "CloudWatchAutoAlarmCrossAccountRole"
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
AWS:
- !Sub "arn:${AWS::Partition}:iam::${CloudWatchAutoAlarmsAccount}:role/CloudWatchAutoAlarmsRole"
- !Sub "arn:${AWS::Partition}:sts::${CloudWatchAutoAlarmsAccount}:assumed-role/CloudWatchAutoAlarmsRole/CloudWatchAutoAlarms"
Action:
- sts:AssumeRole
Path: "/"
Policies:
- PolicyName: "CloudWatchAutoAlarmsPermissions"
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- cloudwatch:ListMetrics
Resource: "*"
- Effect: Allow
Action:
- rds:ListTagsForResource
Resource: "*"
- Effect: Allow
Action:
- ec2:DescribeInstances
- ec2:DescribeImages
Resource: "*"
- Effect: Allow
Action:
- ec2:CreateTags
Resource: !Sub "arn:${AWS::Partition}:ec2:*:${AWS::AccountId}:instance/*"
- Effect: Allow
Action:
- cloudwatch:DescribeAlarms
- cloudwatch:DeleteAlarms
- cloudwatch:PutMetricAlarm
Resource: !Sub "arn:${AWS::Partition}:cloudwatch:*:${AWS::AccountId}:alarm:${AlarmIdentifierPrefix}-*"
- Effect: Allow
Action:
- cloudwatch:DescribeAlarms
Resource: "*"