forked from chaosbunker/munkimagic-in-aws
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap_stack.yaml
80 lines (79 loc) · 2.3 KB
/
bootstrap_stack.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
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Parameters:
MunkiGitRepoName:
Type: "String"
Description: "Munki git repository name"
Default: master
CodeBuildScriptsBucketName:
Type: "String"
Description: "CodeBuild scripts bucket name"
MunkiRepoBucketName:
Type: "String"
Description: "Munki repository name"
MunkiLoggingBucketName:
Type: "String"
Description: "Munki logging bucket name"
MunkiStackName:
Type: "String"
Description: "Munki stack name"
Resources:
MunkiScriptsBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: !Sub ${CodeBuildScriptsBucketName}
VersioningConfiguration:
Status: Enabled
MunkiBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: !Sub ${MunkiRepoBucketName}
LoggingConfiguration:
DestinationBucketName: !Ref 'LoggingBucket'
LogFilePrefix: munki-logs
LoggingBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: !Sub ${MunkiLoggingBucketName}
AccessControl: LogDeliveryWrite
MunkiGitRepo:
Type: AWS::CodeCommit::Repository
Properties:
RepositoryName: !Sub ${MunkiGitRepoName}
RepositoryDescription: Munki git repository
LoggingBucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket:
Ref: LoggingBucket
PolicyDocument:
Statement:
-
Sid: AWSCloudTrailAclCheck
Effect: Allow
Principal:
Service: cloudtrail.amazonaws.com
Action: s3:GetBucketAcl
Resource:
!Sub |-
arn:aws:s3:::${MunkiLoggingBucketName}
-
Sid: AWSCloudTrailWrite
Effect: Allow
Principal:
Service: cloudtrail.amazonaws.com
Action: s3:PutObject
Resource:
!Sub |-
arn:aws:s3:::${MunkiLoggingBucketName}/AWSLogs/${AWS::AccountId}/*
Condition:
StringEquals:
s3:x-amz-acl: bucket-owner-full-control
MunkiTrail:
DependsOn:
- LoggingBucketPolicy
Type: AWS::CloudTrail::Trail
Properties:
TrailName: !Join ['-', [ !Ref 'MunkiStackName', 'CloudTrail']]
S3BucketName: !Ref MunkiLoggingBucketName
IsLogging: true