-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.template.yaml
143 lines (143 loc) · 4.84 KB
/
deploy.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
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
AWSTemplateFormatVersion: "2010-09-09"
Description: "deploy the AWSQS::EKS::Cluster resource into CloudFormation registry"
Parameters:
CreateClusterAccessRole:
Type: String
Default: 'Enabled'
AllowedValues:
- 'Enabled'
- 'Disabled'
PermissionsBoundary:
Type: String
Default: ''
HandlerPackage:
Type: String
Description: S3 path for handler package
Default: s3://aws-quickstart/quickstart-amazon-eks-cluster-resource-provider/awsqs-eks-cluster.zip
Conditions:
CreateRole: !Equals [!Ref CreateClusterAccessRole, 'Enabled']
PermissionsBoundary: !Not [!Equals [!Ref PermissionsBoundary, '']]
Resources:
ResourceVersion:
Type: AWS::CloudFormation::ResourceVersion
Metadata:
DependsOn:
- !If [CreateRole, !Ref ExecutionRole, !Ref 'AWS::NoValue']
- !If [CreateRole, !Ref LogDeliveryRole, !Ref 'AWS::NoValue']
Properties:
TypeName: AWSQS::EKS::Cluster
LoggingConfig:
LogGroupName: awsqs-eks-cluster-logs
LogRoleArn: !Sub 'arn:${AWS::Partition}:iam::${AWS::AccountId}:role/eks-cluster-log-delivery'
SchemaHandlerPackage: !Ref HandlerPackage
ExecutionRoleArn: !Sub 'arn:${AWS::Partition}:iam::${AWS::AccountId}:role/eks-cluster-execution'
ResourceDefaultVersion:
Type: AWS::CloudFormation::ResourceDefaultVersion
Properties:
TypeVersionArn: !Ref ResourceVersion
ExecutionRole:
Type: AWS::IAM::Role
Condition: CreateRole
Properties:
RoleName: eks-cluster-execution
PermissionsBoundary:
Fn::If:
- PermissionsBoundary
- Ref: PermissionsBoundary
- Ref: AWS::NoValue
MaxSessionDuration: 8400
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service: [resources.cloudformation.amazonaws.com, cloudformation.amazonaws.com]
Action: sts:AssumeRole
Path: "/"
Policies:
- PolicyName: ResourceTypePolicy
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- "sts:GetCallerIdentity"
- "eks:CreateCluster"
- "eks:DeleteCluster"
- "eks:DescribeCluster"
- "eks:ListTagsForResource"
- "eks:UpdateClusterVersion"
- "eks:UpdateClusterConfig"
- "eks:TagResource"
- "eks:UntagResource"
- "iam:PassRole"
- "sts:AssumeRole"
- "lambda:UpdateFunctionConfiguration"
- "lambda:DeleteFunction"
- "lambda:GetFunction"
- "lambda:Invoke"
- "lambda:CreateFunction"
- "lambda:UpdateFunctionCode"
- "ec2:DescribeVpcs"
- "ec2:DescribeSubnets"
- "ec2:DescribeSecurityGroups"
- "kms:CreateGrant"
- "kms:DescribeKey"
Resource: "*"
LogDeliveryRole:
Type: AWS::IAM::Role
Condition: CreateRole
Properties:
RoleName: eks-cluster-log-delivery
PermissionsBoundary:
Fn::If:
- PermissionsBoundary
- Ref: PermissionsBoundary
- Ref: AWS::NoValue
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service:
- cloudformation.amazonaws.com
- resources.cloudformation.amazonaws.com
Action: sts:AssumeRole
Path: "/"
Policies:
- PolicyName: ResourceTypePolicy
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- "logs:CreateLogGroup"
- "logs:CreateLogStream"
- "logs:DescribeLogGroups"
- "logs:DescribeLogStreams"
- "logs:PutLogEvents"
- "cloudwatch:ListMetrics"
- "cloudwatch:PutMetricData"
Resource: "*"
VpcProxyRole:
Type: AWS::IAM::Role
Condition: CreateRole
Properties:
RoleName: CloudFormation-Kubernetes-VPC
PermissionsBoundary:
Fn::If:
- PermissionsBoundary
- Ref: PermissionsBoundary
- Ref: AWS::NoValue
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Action: sts:AssumeRole
Path: "/"
ManagedPolicyArns:
- !Sub 'arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaENIManagementAccess'
- !Sub 'arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole'