Skip to content

Commit f08bd8c

Browse files
committed
Add AWS Pipeline files
1 parent d49dd63 commit f08bd8c

5 files changed

Lines changed: 139 additions & 1 deletion

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
/.gradle/
77
/build/
88
.idea/**/libraries
9+
output-template.yml
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
{
2+
"Statement": [
3+
{
4+
"Action": [
5+
"s3:GetObject",
6+
"s3:GetObjectVersion",
7+
"s3:GetBucketVersioning"
8+
],
9+
"Resource": "*",
10+
"Effect": "Allow"
11+
},
12+
{
13+
"Action": [
14+
"s3:PutObject"
15+
],
16+
"Resource": [
17+
"arn:aws:s3:::codepipeline*"
18+
],
19+
"Effect": "Allow"
20+
},
21+
{
22+
"Action": [
23+
"lambda:*"
24+
],
25+
"Resource": [
26+
"arn:aws:lambda:us-east-1:061121813127:function:*"
27+
],
28+
"Effect": "Allow"
29+
},
30+
{
31+
"Action": [
32+
"apigateway:*"
33+
],
34+
"Resource": [
35+
"arn:aws:apigateway:us-east-1::*"
36+
],
37+
"Effect": "Allow"
38+
},
39+
{
40+
"Action": [
41+
"iam:GetRole",
42+
"iam:CreateRole",
43+
"iam:DeleteRole"
44+
],
45+
"Resource": [
46+
"arn:aws:iam::061121813127:role/*"
47+
],
48+
"Effect": "Allow"
49+
},
50+
{
51+
"Action": [
52+
"iam:AttachRolePolicy",
53+
"iam:DetachRolePolicy"
54+
],
55+
"Resource": [
56+
"arn:aws:iam::061121813127:role/*"
57+
],
58+
"Effect": "Allow"
59+
},
60+
{
61+
"Action": [
62+
"iam:PassRole"
63+
],
64+
"Resource": [
65+
"*"
66+
],
67+
"Effect": "Allow"
68+
},
69+
{
70+
"Action": [
71+
"cloudformation:CreateChangeSet"
72+
],
73+
"Resource": [
74+
"arn:aws:cloudformation:us-east-1:aws:transform/Serverless-2016-10-31"
75+
],
76+
"Effect": "Allow"
77+
}
78+
],
79+
"Version": "2012-10-17"
80+
}

buildspec.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
version: 0.1
2+
3+
phases:
4+
build:
5+
commands:
6+
- chmod +x gradlew
7+
- ./gradlew build
8+
install:
9+
commands:
10+
- aws cloudformation package --template-file cloudformation-input-template.yml --s3-bucket java4lambda-bucket --output-template-file output-template.yml
11+
12+
artifacts:
13+
files:
14+
- build/distributions/java4lambda.zip
15+
- output-template.yml
16+
discard-paths: yes

cloudformation-input-template.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
AWSTemplateFormatVersion: '2010-09-09'
2+
Transform: AWS::Serverless-2016-10-31
3+
Description: AWS example in Java to say hello
4+
Resources:
5+
HelloFunction:
6+
Type: AWS::Serverless::Function
7+
Properties:
8+
Handler: index.handler
9+
Runtime: java8
10+
CodeUri: .
11+
Events:
12+
MyTimeApi:
13+
Type: Api
14+
Properties:
15+
Path: /OhHai
16+
Method: GET

readme.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,29 @@ Empty repo to Java AWS Lambda
1313
* get gradle wrapper
1414
* setup build.gradle
1515
* add java code
16-
* reopen into intellij to make gradle project
16+
* reopen into intellij to make gradle project
17+
6. Setup AWS files that live in git
18+
* Create bucket in s3
19+
* Add CloudFormation input template
20+
* Add buildspec.yml
21+
* add aws cloudformation install command that produces output template
22+
* include output template in artifact
23+
7. Create new role in AWS IAM
24+
* Role Type: AWS CloudFormation
25+
* Attach Policy: AWS Lambda Execute
26+
* Inline Custom Role Policy
27+
* copy from aws/cloudformation-role-policy.json
28+
* from http://docs.aws.amazon.com/lambda/latest/dg/automating-deployment.html
29+
* replace account-id and region, from upper right in aws console header
30+
* account-id=061121813127
31+
* region=us-east-1
32+
8. Create pipeline in AWS CodePipeline
33+
* Link to AWS CodeCommit repo
34+
* Create AWS CodeBuild project
35+
* Use AWS CodeBuild image: aws/codebuild/java:openjdk-8
36+
* Deployment provider AWS CloudFormation
37+
* Create or replace change set
38+
* template file = output template in #6
39+
* CAPABILITY_IAM
40+
* Use role in #7 for pipeline role
41+
* Create new IAM role for AWS Service Role

0 commit comments

Comments
 (0)