-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstack.yml
121 lines (111 loc) · 2.92 KB
/
stack.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
AWSTemplateFormatVersion: 2010-09-09
Description: Build Pipeline for Bill Of Materials
####################
Parameters:
AWSAccessKeyId:
Description: The AWS access key id
Type: String
AWSSecretAccessKey:
Description: The AWS secret access key
Type: String
GitHubToken:
Description: The GitHub OAuth token
Type: String
Repository:
Default: bill-of-materials
Description: The repository name
Type: String
RepositoryOwner:
Default: varunmc
Description: The repository owner
Type: String
####################
Resources:
CodeBuild:
Type: AWS::CodeBuild::Project
Properties:
Artifacts:
Type: NO_ARTIFACTS
Environment:
ComputeType: BUILD_GENERAL1_SMALL
EnvironmentVariables:
- Name: AWS_ACCESS_KEY_ID
Value: !Ref AWSAccessKeyId
- Name: AWS_SECRET_ACCESS_KEY
Value: !Ref AWSSecretAccessKey
Image: aws/codebuild/java:openjdk-8
Type: LINUX_CONTAINER
Name: !Ref AWS::StackName
ServiceRole: !GetAtt [CodeBuildRole, Arn]
Source:
Auth:
Resource: !Ref GitHubToken
Type: OAUTH
Location: !Sub https://github.com/${RepositoryOwner}/${Repository}.git
Type: GITHUB
CodeBuildRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Action:
- sts:AssumeRole
Effect: Allow
Principal:
Service:
- codebuild.amazonaws.com
ManagedPolicyArns:
- arn:aws:iam::aws:policy/PowerUserAccess
CodePipeline:
Type: AWS::CodePipeline::Pipeline
Properties:
ArtifactStore:
Location: !Ref Store
Type: S3
Name: !Ref AWS::StackName
RoleArn: !GetAtt [CodePipelineRole, Arn]
Stages:
- Name: Source
Actions:
- Name: Checkout
ActionTypeId:
Category: Source
Owner: ThirdParty
Provider: GitHub
Version: 1
Configuration:
Branch: master
OAuthToken: !Ref GitHubToken
Owner: !Ref RepositoryOwner
Repo: !Ref Repository
OutputArtifacts:
- Name: Sources
- Name: Build
Actions:
- Name: Build
ActionTypeId:
Category: Build
Owner: AWS
Provider: CodeBuild
Version: 1
Configuration:
ProjectName: !Ref CodeBuild
InputArtifacts:
- Name: Sources
CodePipelineRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Action:
- sts:AssumeRole
Effect: Allow
Principal:
Service:
- codepipeline.amazonaws.com
ManagedPolicyArns:
- arn:aws:iam::aws:policy/AdministratorAccess
Store:
Type: AWS::S3::Bucket