-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinit.yml
95 lines (85 loc) · 2.75 KB
/
init.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
AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Description: 'Resources for Code Green Sustainability Hackathon by Marty J. Sullivan'
Parameters:
CornellEasBucket:
Description: 'The S3 bucket containing the Cornell EAS Data Lake'
Type: 'String'
Default: 'cornell-eas'
GitHubRepo:
Type: 'String'
Default: 'https://github.com/marty-sullivan/code-green-reinvent-2019.git'
Outputs:
BuildBucket:
Value: !Sub '${BuildBucket}'
BuildProject:
Value: !Sub '${BuildProject}'
Resources:
BuildBucket:
Type: 'AWS::S3::Bucket'
Properties:
LifecycleConfiguration:
Rules:
- Id: 'daily-cleanup'
Status: 'Enabled'
AbortIncompleteMultipartUpload:
DaysAfterInitiation: 1
ExpirationInDays: 1
NoncurrentVersionExpirationInDays: 1
BuildRole:
Type: 'AWS::IAM::Role'
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: 'Allow'
Action: 'sts:AssumeRole'
Principal:
Service: !Sub 'codebuild.${AWS::URLSuffix}'
# Condition:
# StringEquals:
# 'sts:ExternalId': !Sub '${AWS::AccountId}'
ManagedPolicyArns:
- !Sub 'arn:${AWS::Partition}:iam::aws:policy/AWSCloudFormationReadOnlyAccess'
Policies:
- PolicyName: 'build-permissions'
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: 'Allow'
Action:
- 'cloudformation:*'
Resource:
- !Sub 'arn:${AWS::Partition}:cloudformation:${AWS::Region}:${AWS::AccountId}:stack/${AWS::StackName}/*'
- !Sub 'arn:${AWS::Partition}:cloudformation:${AWS::Region}:aws:transform/Serverless-2016-10-31'
- Effect: 'Allow'
Action:
- 'athena:*'
- 'events:*'
- 'glue:*'
- 'iam:*'
- 'lambda:*'
- 'logs:*'
- 's3:*'
- 'states:*'
Resource:
- '*'
BuildProject:
Type: 'AWS::CodeBuild::Project'
Properties:
Artifacts:
Type: 'NO_ARTIFACTS'
ServiceRole: !Sub '${BuildRole.Arn}'
Source:
Location: !Sub '${GitHubRepo}'
Type: 'GITHUB'
GitCloneDepth: 0
Environment:
ComputeType: 'BUILD_GENERAL1_SMALL'
Image: 'aws/codebuild/standard:3.0'
Type: 'LINUX_CONTAINER'
EnvironmentVariables:
- Name: 'BUILD_BUCKET'
Value: !Sub '${BuildBucket}'
- Name: 'STACK_NAME'
Value: !Sub '${AWS::StackName}'