Skip to content

Commit 842fbea

Browse files
Merge pull request #289 from code-dot-org/create-codepipeline
Create codepipeline for pr builds and Test env.
2 parents 324dcf3 + 94e6d12 commit 842fbea

19 files changed

+472
-82
lines changed

.ruby-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.7.2
1+
2.7.6

cicd/1-setup/setup.template.yml renamed to cicd/1-setup/cicd-dependencies.template.yml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,37 @@ Resources:
1313
# This role will be used by CodeBuild to execute the CI build. Here we have
1414
# the common policy rules required. Since we may want to create multiple
1515
# codebuild projects for different branches, we can append policies when those
16-
# stack resources are created (in "2-cicd")
16+
# stack resources are created (in "2-cicd/cicd.template.yml")
1717
JavabuilderCodeBuildRole:
1818
Type: AWS::IAM::Role
1919
Properties:
2020
AssumeRolePolicyDocument:
2121
Statement:
2222
- Action: ['sts:AssumeRole']
2323
Effect: Allow
24-
Principal: {Service: [codebuild.amazonaws.com]}
24+
Principal:
25+
Service:
26+
- codebuild.amazonaws.com
27+
- codepipeline.amazonaws.com
2528
Version: '2012-10-17'
2629
Path: /service-role/
2730
PermissionsBoundary: !ImportValue IAM-DevPermissions
2831
Policies:
32+
- PolicyName: JavabuilderPassRole
33+
PolicyDocument:
34+
Statement:
35+
- Effect: Allow
36+
Action: iam:PassRole
37+
Resource: !Sub arn:aws:iam::${AWS::AccountId}:role/admin/CloudFormationService
38+
- PolicyName: JavabuilderCodePipelinePolicy
39+
PolicyDocument:
40+
Statement:
41+
- Effect: Allow
42+
Action:
43+
- "cloudformation:DescribeStacks"
44+
- "cloudformation:CreateStack"
45+
- "cloudformation:UpdateStack"
46+
Resource: "*"
2947
- PolicyName: CodeBuildResourcesAccess
3048
PolicyDocument:
3149
Statement:
@@ -45,10 +63,15 @@ Resources:
4563
- Effect: Allow
4664
Action:
4765
- s3:PutObject
66+
- s3:PutObjectAcl
4867
- s3:GetObject
4968
- s3:GetObjectVersion
5069
Resource:
5170
- !Sub arn:aws:s3:::${ArtifactStore}/*
71+
- Effect: Allow
72+
Action: codestar-connections:UseConnection
73+
Resource:
74+
- !Sub arn:aws:codestar-connections:us-east-1:${AWS::AccountId}:connection/*
5275

5376
Outputs:
5477
JavabuilderCodeBuildArtifactBucket:
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
3+
echo Deploying Javabuilder CICD Dependencies
4+
5+
# Create/Update the Javabuilder setup/dependencies stack. This is manually created and maintained, and does not require elevated permissions
6+
7+
TEMPLATE_FILE=cicd/1-setup/cicd-dependencies.template.yml
8+
9+
echo Validating cloudformation template...
10+
aws cloudformation validate-template \
11+
--template-body file://${TEMPLATE_FILE} \
12+
| cat
13+
14+
ACCOUNT=$(aws sts get-caller-identity --query "Account" --output text)
15+
16+
read -r -p "Would you like to deploy this template to AWS account $ACCOUNT? [y/N] " response
17+
if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]
18+
then
19+
echo Updating cloudformation stack...
20+
aws cloudformation deploy \
21+
--stack-name javabuilder-cicd-deps \
22+
--template-file ${TEMPLATE_FILE} \
23+
--capabilities CAPABILITY_IAM \
24+
"$@"
25+
26+
echo Complete!
27+
else
28+
echo Exiting...
29+
fi
30+
31+

cicd/1-setup/deploy-setup.sh

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)