Repository navigation
Expand file tree
/
Copy pathreader.yaml
More file actions
156 lines (151 loc) · 5.95 KB
/
Copy pathreader.yaml
File metadata and controls
156 lines (151 loc) · 5.95 KB
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
AWSTemplateFormatVersion: "2010-09-09"
Description: >-
DebugLogManager reader role. Read-only: lists resources and their current
logging settings, so DebugLogManager can show what is on and never takes over
logging it didn't turn on. Deployed to every account in scope (as a StackSet
from the install stack, or as a plain stack in account-list mode).
Parameters:
ToolsAccountId:
Type: String
AllowedPattern: "^[0-9]{12}$"
Description: The account DebugLogManager runs in.
AppPrincipalArn:
Type: String
Description: >-
The IAM role DebugLogManager runs as in the tools account (its VM role),
matched with ArnLike, so a wildcard is allowed.
ExternalId:
Type: String
MinLength: 8
NoEcho: true
Description: The install's ExternalId. DebugLogManager sends it on every assume.
IdentityCenterReader:
Type: String
AllowedValues: ["false", "true"]
Default: "false"
Description: >-
true only in the account that hosts IAM Identity Center (its delegated
administrator): adds the four read actions that list a user's account
assignments at sign-in.
Conditions:
ReadIdentityCenter: !Equals [!Ref IdentityCenterReader, "true"]
Resources:
ReaderRole:
Type: AWS::IAM::Role
Properties:
RoleName: DebugLogManager-reader
Description: Read-only role for DebugLogManager (lists resources and their logging settings).
MaxSessionDuration: 3600
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
# Two statements: AWS checks sts:ExternalId only on AssumeRole, so
# SetSourceIdentity can't share a statement that requires it.
- Sid: DebugLogManagerOnly
Effect: Allow
Principal:
AWS: !Sub "arn:${AWS::Partition}:iam::${ToolsAccountId}:root"
Action: sts:AssumeRole
Condition:
StringEquals:
sts:ExternalId: !Ref ExternalId
ArnLike:
aws:PrincipalArn: !Ref AppPrincipalArn
"Null":
sts:SourceIdentity: "false"
- Sid: DebugLogManagerNamesWhoAsked
Effect: Allow
Principal:
AWS: !Sub "arn:${AWS::Partition}:iam::${ToolsAccountId}:root"
Action: sts:SetSourceIdentity
Condition:
ArnLike:
aws:PrincipalArn: !Ref AppPrincipalArn
StringLike:
sts:SourceIdentity: "?*"
Policies:
- PolicyName: read-logging-settings
PolicyDocument:
Version: "2012-10-17"
Statement:
- Sid: AccountName
Effect: Allow
Action: account:GetAccountInformation
Resource: "*"
- Sid: WorkerStackParameters
Effect: Allow
Action: cloudformation:DescribeStacks
Resource: !Sub "arn:${AWS::Partition}:cloudformation:*:${AWS::AccountId}:stack/DebugLogManager-worker/*"
- Sid: ResourcesAndTheirLogging
Effect: Allow
Action:
- ec2:DescribeVpcs
- ec2:DescribeFlowLogs
- ec2:DescribeRegions
- elasticloadbalancing:DescribeLoadBalancers
- elasticloadbalancing:DescribeLoadBalancerAttributes
- elasticloadbalancing:DescribeTags
- s3:ListAllMyBuckets
- s3:GetBucketLocation
- s3:GetBucketLogging
- lambda:ListFunctions
- lambda:GetFunctionConfiguration
- cloudtrail:DescribeTrails
- cloudtrail:GetTrailStatus
- cloudtrail:GetEventSelectors
- cloudtrail:LookupEvents
- dynamodb:ListTables
- logs:DescribeLogGroups
- logs:DescribeSubscriptionFilters
- logs:DescribeMetricFilters
- logs:DescribeDeliverySources
- cloudwatch:GetMetricStatistics
- ec2:DescribeTransitGateways
- elasticloadbalancing:DescribeListeners
- network-firewall:ListFirewalls
- network-firewall:DescribeLoggingConfiguration
- logs:ListLogDeliveries
- route53resolver:ListResolverQueryLogConfigs
- route53resolver:ListResolverQueryLogConfigAssociations
- route53:ListHostedZones
- route53:ListQueryLoggingConfigs
- cloudfront:ListDistributions
- cloudfront:GetDistributionConfig
- wafv2:ListWebACLs
- wafv2:GetLoggingConfiguration
- apigateway:GET
- states:ListStateMachines
- states:DescribeStateMachine
- rds:DescribeDBInstances
- eks:ListClusters
- eks:DescribeCluster
- elasticache:DescribeReplicationGroups
- es:ListDomainNames
- es:DescribeDomain
- es:DescribeDomains
Resource: "*"
IdentityCenterPolicy:
Type: AWS::IAM::RolePolicy
Condition: ReadIdentityCenter
Properties:
RoleName: !Ref ReaderRole
PolicyName: read-identity-center-assignments
PolicyDocument:
Version: "2012-10-17"
Statement:
- Sid: IdentityCenterRead
Effect: Allow
Action:
- sso:ListInstances
- sso:ListPermissionSets
- sso:DescribePermissionSet
- sso:ListAccountAssignments
- identitystore:GetUserId
- identitystore:ListGroupMembershipsForMember
- identitystore:ListGroups
- identitystore:DescribeGroup
- identitystore:DescribeUser
Resource: "*"
Outputs:
ReaderRoleArn:
Value: !GetAtt ReaderRole.Arn