-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfix-role.cf.template
108 lines (104 loc) · 3.44 KB
/
fix-role.cf.template
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
AWSTemplateFormatVersion: 2010-09-09
Description: This CloudFormation template creates a role in your AWS account that Fix can assume to perform security audits. It also sends a SNS callback notification to Fix with the account ID and name of the role that was created.
Parameters:
ExternalId:
Description: Your Fix-assigned External ID (DO NOT EDIT)
Type: String
WorkspaceId:
Description: Your Fix-assigned Workspace ID (DO NOT EDIT)
Type: String
Outputs:
FixAccessRoleName:
Description: Name of the Fix Access Role
Value: !GetAtt FixAccountCallback.RoleName
Resources:
FixCrossAccountAccessRole:
Type: 'AWS::IAM::Role'
Properties:
Path: /
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal:
AWS: arn:aws:iam::{{fix_account_id}}:root
Action:
- 'sts:AssumeRole'
- 'sts:TagSession'
Condition:
StringEquals:
'sts:ExternalId': !Ref ExternalId
MaxSessionDuration: 10800
ManagedPolicyArns:
- 'arn:aws:iam::aws:policy/ReadOnlyAccess'
Policies:
- PolicyName: FixOrgList
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Resource: '*'
Action:
- organizations:List*
- organizations:Describe*
- ec2:DescribeRegions
- iam:ListAccountAliases
- PolicyName: FixPricingList
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Resource: '*'
Action:
- pricing:DescribeServices
- pricing:GetAttributeValues
- pricing:GetProducts
- PolicyName: FixRevokeUnnecessaryPermissions
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Deny
Resource: '*'
Action:
- athena:GetQueryResults
- cloudformation:GetTemplate
- codecommit:GetBlob
- codecommit:GetCommit
- codecommit:GetFile
- codecommit:GetFolder
- config:SelectAggregateResourceConfig
- config:SelectResourceConfig
- directconnect:DescribeConnectionLoa
- dynamodb:BatchGetItem
- dynamodb:GetItem
- dynamodb:Query
- dynamodb:Scan
- ec2:GetConsoleOutput
- ec2:GetConsoleScreenshot
- ec2:GetPasswordData
- ecr:BatchGetImage
- ecr:GetDownloadUrlForLayer
- glacier:GetJobOutput
- kinesis:GetRecords
- lambda:GetFunction
- lambda:GetLayerVersion
- rds:DownloadCompleteDBLogFile
- rds:DownloadDbLogFilePortion
- s3:GetObject
- s3:GetObjectVersion
- sdb:Select*
- secretsmanager:GetSecretValue
- sqs:ReceiveMessage
- ssm:GetParameter
- ssm:GetParameters
- ssm:GetParametersByPath
FixAccountCallback:
Type: Custom::Function
Properties:
StackId: !Ref AWS::StackId
RoleName: !Ref FixCrossAccountAccessRole
WorkspaceId: !Ref WorkspaceId
ExternalId: !Ref ExternalId
FixEnvironment: "{{environment}}"
FixStackVersion: "{{unixtime}}"
ServiceToken: !Sub "arn:aws:sns:${AWS::Region}:{{fix_account_id}}:FixAccountCallbacks"