-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpimcoreDevBox.yml
210 lines (200 loc) · 6.99 KB
/
pimcoreDevBox.yml
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
AWSTemplateFormatVersion: 2010-09-09
Description: Create a Pimcore Admin tool box (optional), before the actual pimcore stack is created.
Please not that this template is not optimized for the security concerns of your company.
Parameters:
Prefix:
Type: String
Description: A common prefix for users and resources
Default: 'Pimcore'
S3BucketName:
Type: String
Default: 'pimcore-utility-bucket'
EcrRepositoryName:
Type: String
Default: 'pimcore-company-ecr'
Description: 'Set to false if a ECR docker image repository should not be created.'
WildcardCertificateDomainName:
Type: String
Default: false
Description: Name of your (root) test domain, such as "pimcore.xyz", when *.pimcore.xyz should be hosted.
For multiple projects, extend the template, or create additional certificats manually.
Conditions:
CreateEcr: !Not [ !Equals [ !Ref EcrRepositoryName, "false" ]]
CreateWildcardCertificate: !Not [ !Equals [ !Ref WildcardCertificateDomainName, "false" ]]
Resources:
#
# Setup User is used to install the cloudformation environment from your local (docker) environment.
# @see https://policysim.aws.amazon.com/ for simulating policies.
#
SetupUser:
Type: 'AWS::IAM::User'
SetupUserGroup:
Type: 'AWS::IAM::Group'
Properties:
GroupName: !Sub '${Prefix}-SetupUserGroup'
ManagedPolicyArns:
- arn:aws:iam::aws:policy/AmazonSSMFullAccess
- arn:aws:iam::aws:policy/AWSCloudFormationFullAccess
- arn:aws:iam::aws:policy/IAMFullAccess
- arn:aws:iam::aws:policy/AWSCloudMapFullAccess
- arn:aws:iam::aws:policy/AmazonEC2FullAccess
- arn:aws:iam::aws:policy/AmazonECS_FullAccess
- arn:aws:iam::aws:policy/AWSLambdaFullAccess
- arn:aws:iam::aws:policy/AmazonElastiCacheFullAccess
- arn:aws:iam::aws:policy/AmazonRDSFullAccess
- arn:aws:iam::aws:policy/CloudFrontFullAccess
# attention: max 10 managed policies
AddSetupUserToGroup:
Type: 'AWS::IAM::UserToGroupAddition'
DependsOn: SetupUserGroup
Properties:
GroupName: !Sub '${Prefix}-setupUserGroup'
Users:
- !Ref SetupUser
SetupUserAccessKeys:
Type: 'AWS::IAM::AccessKey'
DependsOn: SetupUser
Properties:
UserName:
Ref: SetupUser
SetupUserPolicy:
Type: 'AWS::IAM::Policy'
DependsOn:
- SetupUserGroup
- SetupUser
Properties:
PolicyName: !Sub '${Prefix}-SetupUserPolicy'
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- sts:AssumeRole
- secretsmanager:* # test
- acm:RequestCertificate # for ACM certificate creation
- acm:DescribeCertificate
- acm:DeleteCertificate # important for cleanup of certificates
- route53:*
- ecr:*
Resource: '*'
Groups:
- !Sub '${Prefix}-setupUserGroup'
#
# S3 Bucket as a preparation for CFN deployments with nested stacks
#
S3Bucket:
Type: AWS::S3::Bucket
Description: S3 Bucket as a preparation for CFN deployments with nested stacks.
#DeletionPolicy: Retain
Properties:
AccessControl: Private
BucketName: !Sub '${S3BucketName}'
PublicAccessBlockConfiguration:
BlockPublicAcls: true
BlockPublicPolicy: true
S3BucketPolicy:
Type: AWS::S3::BucketPolicy
#DeletionPolicy: Retain
Properties:
PolicyDocument:
Version: 2012-10-17
Statement:
- Sid: ForceHTTPS
Effect: Deny
Principal: '*'
Action: 's3:*'
Resource:
- !Sub ${S3Bucket.Arn}/*
- !Sub ${S3Bucket.Arn}
Condition:
Bool:
"aws:SecureTransport": false
- Sid: UploadUserAccess
Effect: Allow
Principal:
AWS: !GetAtt SetupUser.Arn
Action: 's3:*'
Resource:
- !Sub ${S3Bucket.Arn}/*
- !Sub ${S3Bucket.Arn}
- Sid: SetupUserAccess
Effect: Allow
Principal:
AWS: !GetAtt SetupUser.Arn
Action: 's3:*'
Resource:
- !Sub ${S3Bucket.Arn}/*
- !Sub ${S3Bucket.Arn}
Bucket: !Ref S3Bucket
S3BucketAccessPolicy:
Type: AWS::IAM::ManagedPolicy
Properties:
Description: !Sub 'Grants CRUD access to the S3 bucket ${S3Bucket}'
PolicyDocument:
Version: 2012-10-17
Statement:
- Sid: S3ObjectActions
Effect: Allow
Action:
- s3:GetObject
- s3:PutObject
- s3:PutObjectACL
- s3:PutObjectTagging
- s3:DeleteObject
- s3:RestoreObject
Resource:
- !Sub ${S3Bucket.Arn}/*
- !Sub ${S3Bucket.Arn}
- Sid: S3ListAction
Effect: Allow
Action: s3:ListBucket
Resource:
- !Sub ${S3Bucket.Arn}/*
- !Sub ${S3Bucket.Arn}
#
# ECR | Docker Image Repository for continuous ECS deployments.
#
EcrRepository:
Type: AWS::ECR::Repository
Condition: CreateEcr
Properties:
RepositoryName: !Ref EcrRepositoryName
#
# Domain wildcard certificate creation. The certificate can be used as an input for other Pimcore stacks.
#
DomainWildcardCertificate:
Condition: CreateWildcardCertificate
Type: AWS::CertificateManager::Certificate
Description: Create a wildcard certificate. Do not forget to visit the Certificate Manager (https://eu-central-1.console.aws.amazon.com/acm/home to manually)
and manually trigger the validatio confirmation.
Properties:
DomainName: !Sub '*.${WildcardCertificateDomainName}'
DomainValidationOptions:
- DomainName: !Sub '*.${WildcardCertificateDomainName}'
ValidationDomain: !Sub '*.${WildcardCertificateDomainName}'
ValidationMethod: DNS
Outputs:
SetupUserAccessKey:
Description: "Setup User Access Key"
Value: !Ref SetupUserAccessKeys
SetupUserAccessToken:
Description: "Setup User Access token"
Value: 'Please create an access token using the AWS console (IAM).'
SetupUserArn:
Description: "Setup User ARN"
Value: !GetAtt SetupUser.Arn
AwsRegion:
Description : AWS Region
Value: !Ref AWS::Region
S3BucketName:
Description: S3 Bucket Name for Cloudformation Deployments etc.
Value: !Ref S3BucketName
EcrRepository:
Description: ECR Repository
Value: !Ref EcrRepository
DomainWildcardCertificate:
Description: "Wildcard Certificate that can be used across various applications within one domain range.
Particularly useful as AWS has a default limit of 20 contingents a year per account. If you are using
a wildcard certificate, switch to Resources, copy the ARN of the certificate, and use it as an input
for the creation of your Pimcore stack."
Value: !Ref WildcardCertificateDomainName