/
chapter_9_CFN.yaml
113 lines (109 loc) · 3.34 KB
/
chapter_9_CFN.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
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
AWSTemplateFormatVersion: 2010-09-09
Description: Stack for Amazon Redshift cookbook Chapter9
Parameters:
CookbookIAMUserName:
Type: String
Description: cookbook iam user name
Default: ''
CookbookBucketName:
Type: String
Description: >-
Session name must satisfy regular expression pattern
^[a-zA-Z0-9](-*[a-zA-Z0-9])*
Default: ''
RedshiftClusterRole:
Type: String
Description: redshift cluster role name
Default: ''
Resources:
Chapter9GlueServiceRole:
Type: 'AWS::IAM::Role'
Properties:
Description: IAM Role for Redshift scheduler
RoleName: Chapter9GlueServiceRole
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
-
Effect: "Allow"
Principal:
Service:
- "glue.amazonaws.com"
Action:
- "sts:AssumeRole"
ManagedPolicyArns:
- arn:aws:iam::aws:policy/AmazonS3FullAccess
- arn:aws:iam::aws:policy/service-role/AWSGlueServiceRole
- arn:aws:iam::aws:policy/service-role/AWSGlueServiceNotebookRole
- arn:aws:iam::aws:policy/CloudWatchLogsFullAccess
- arn:aws:iam::aws:policy/AmazonRDSFullAccess
Chapter9IAMPolicy:
Type: 'AWS::IAM::ManagedPolicy'
Properties:
ManagedPolicyName: Chapter9IAMPolicy
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Action:
- 'redshift:*'
- 'redshift-data:*'
- 'secretsmanager:*'
- 'logs:*'
- 'sns:*'
- 'cloudwatch:*'
- 'cloudformation:*'
- 'kms:*'
- 'glue:*'
- 'ec2:*'
- 'iam:*'
- s3:ListAllMyBuckets
- s3:GetBucketLocation
- 'rds:*'
- cloudtrail:DescribeTrails
- 'lakeformation:*'
- 'cfn:*'
Resource:
- '*'
- Effect: Allow
Action:
- s3:*
Resource:
- !Sub "arn:aws:s3:::${CookbookBucketName}"
- !Sub "arn:aws:s3:::${CookbookBucketName}/*"
Users:
- !Ref CookbookIAMUserName
Chapter9RedshiftPolicy:
Type: 'AWS::IAM::ManagedPolicy'
Properties:
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Action:
- 's3:*'
Resource:
- !Sub 'arn:aws:s3:::${CookbookBucketName}'
- !Sub 'arn:aws:s3:::${CookbookBucketName}/*'
- Effect: Allow
Action:
- glue:*
Resource:
- '*'
- Effect: Allow
Action:
- secretsmanager:*
Resource:
- '*'
Roles:
- !Ref RedshiftClusterRole
Outputs:
Chapter9IAMPolicy:
Description: IAM policy access for chapter 9
Value: !Ref Chapter9IAMPolicy
Chapter9RedshiftPolicy:
Description: Chapter9 redshift policy
Value: !Ref Chapter9RedshiftPolicy
Chapter9GlueServiceRole:
Description: Chapter9 glue service role
Value: !Ref Chapter9RedshiftPolicy