Skip to content

Commit 21cbca4

Browse files
authored
Merge pull request #10 from getcft/release-2.0
Upgrading to Node 18 and Serverless 3.38.0
2 parents aaae314 + 16526ea commit 21cbca4

File tree

8 files changed

+45
-113
lines changed

8 files changed

+45
-113
lines changed

README.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ As with most AWS services you will incur costs for usage. For this CloudFormatio
5656
* The serverless framework file that defines AWS Lambda Functions and the events that trigger them along with any resources they require.
5757
* buildspec-dev.yml ~ buildspec-stg.yml ~ buildspec-prod.yml
5858
* File or files CodeBuild reads to understand build commands and related settings. There are three representing typical DEV STAGE and PROD environments.
59-
* deploy.sh
60-
* Instructions for AWS CodePipeline to deploy the chosen environment
6159

6260
## Deploy the CloudFormation Template
6361

@@ -87,10 +85,8 @@ In the *AWS Management Console* you should be able to *verify* the following hav
8785

8886
## Workflow
8987

90-
The workflow is as follows, the Github repo/branch you designated with your Serverless code will be sourced initially and upon commits, which then will trigger a AWS CodeBuild project that will package the code (you can add linting here), and send the result to another AWS CodeBuild project that will deploy the code using a deploy script.
88+
The workflow is as follows, the Github repo/branch you designated with your Serverless code will be sourced initially and upon commits, which then will trigger a AWS CodeBuild project that will package the code (you can add linting here), and send the result to another AWS CodeBuild project that will deploy the code using serverless framework.
9189

9290
If you used this repository as a test you can go to CloudFormation and see two templates one has "aws-serverless-express-application" in the name if you select it and look at the "Outputs" tab you will see "ServiceEndpoint" with a URL click on it and you will get a "Hello World!" message.
9391

9492
Anytime you commit code to the repo/branch you specified it will trigger a new build and deploy it. This will be more relevant when you use it for your own repo/branch and not the test one since you don't have access to commit to this repository.
95-
96-

buildspec-dev.yml

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,25 @@ version: 0.2
33
phases:
44
install:
55
commands:
6-
#- rm package-lock.json
7-
- npm install --silent --progress=false -g npm
6+
- n 18.19.0
87

98
## Dependencies
109
- npm install --silent --progress-false
11-
- npm --version
12-
- npm install --silent --progress=false -g serverless
10+
- npm install --silent --progress=false -g [email protected]
1311
- npm install --silent --save–dev serverless-stack-output
1412

1513
build:
1614
commands:
17-
## Integration test environment
18-
#- serverless deploy --stage test -v
19-
- mkdir artifacts
20-
- mkdir artifacts/stg
21-
- serverless package --package artifacts/dev --stage dev -v
15+
## Tests
2216

2317
post_build:
2418
commands:
25-
## Remove integration testing environment
26-
#- serverless remove --stage test -v
19+
## Post build commands
2720

2821
artifacts:
2922
files:
30-
- artifacts/**/*
3123
- serverless.yml
3224
- deploy.sh
25+
- index.js
3326
- package.json
3427
- package-lock.json

buildspec-prod.yml

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,25 @@ version: 0.2
33
phases:
44
install:
55
commands:
6-
#- rm package-lock.json
7-
- npm install --silent --progress=false -g npm
6+
- n 18.19.0
87

98
## Dependencies
109
- npm install --silent --progress-false
11-
- npm --version
12-
- npm install --silent --progress=false -g serverless
10+
- npm install --silent --progress=false -g [email protected]
1311
- npm install --silent --save–dev serverless-stack-output
1412

1513
build:
1614
commands:
17-
## Integration test environment
18-
#- serverless deploy --stage test -v
19-
- mkdir artifacts
20-
- mkdir artifacts/prod
21-
- serverless package --package artifacts/prod --stage prod -v
15+
## Tests
2216

2317
post_build:
2418
commands:
25-
## Remove integration testing environment
26-
#- serverless remove --stage test -v
19+
## Post build commands
2720

2821
artifacts:
2922
files:
30-
- artifacts/**/*
3123
- serverless.yml
3224
- deploy.sh
25+
- index.js
3326
- package.json
3427
- package-lock.json

buildspec-stg.yml

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,25 @@ version: 0.2
33
phases:
44
install:
55
commands:
6-
#- rm package-lock.json
7-
- npm install --silent --progress=false -g npm
6+
- n 18.19.0
87

98
## Dependencies
109
- npm install --silent --progress-false
11-
- npm --version
12-
- npm install --silent --progress=false -g serverless
10+
- npm install --silent --progress=false -g [email protected]
1311
- npm install --silent --save–dev serverless-stack-output
1412

1513
build:
1614
commands:
17-
## Integration test environment
18-
#- serverless deploy --stage test -v
19-
- mkdir artifacts
20-
- mkdir artifacts/stg
21-
- serverless package --package artifacts/stg --stage stg -v
15+
## Tests
2216

2317
post_build:
2418
commands:
25-
## Remove integration testing environment
26-
#- serverless remove --stage test -v
19+
## Post build commands
2720

2821
artifacts:
2922
files:
30-
- artifacts/**/*
3123
- serverless.yml
3224
- deploy.sh
25+
- index.js
3326
- package.json
3427
- package-lock.json

deploy.sh

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

package-lock.json

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

serverless-code-pipeline-cf-template.yml

Lines changed: 18 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright [2018] [Phil Chen]
1+
# Copyright [2024] [Phil Chen]
22

33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -38,8 +38,8 @@ Parameters:
3838

3939
GitHubOAuthToken:
4040
Type: String
41-
Default: GitHub OAuthToken Here
42-
Description: CodePipeline requires an OAuthToken
41+
NoEcho: true
42+
Description: CodePipeline requires an GitHub OAuthToken
4343

4444
Resources:
4545

@@ -80,58 +80,22 @@ Resources:
8080
Statement:
8181
Effect: Allow
8282
Action:
83-
- logs:CreateLogGroup
84-
- logs:CreateLogStream
85-
- logs:PutLogEvents
86-
- logs:DescribeLogGroups
87-
- logs:FilterLogEvents
88-
- logs:DescribeLogStreams
89-
- logs:DeleteLogGroup
90-
- s3:putObject
91-
- s3:getObject
92-
- codebuild:*
93-
- 'cloudformation:List*'
94-
- 'cloudformation:Get*'
95-
- 'cloudformation:PreviewStackUpdate'
96-
- 'cloudformation:ValidateTemplate'
97-
- 'cloudformation:CreateStack'
98-
- 'cloudformation:CreateUploadBucket'
99-
- 'cloudformation:DeleteStack'
100-
- 'cloudformation:Describe*'
101-
- 'cloudformation:UpdateStack'
102-
- 'lambda:Get*'
103-
- 'lambda:List*'
104-
- 'lambda:CreateFunction'
105-
- 'lambda:AddPermission'
106-
- 'lambda:CreateAlias'
107-
- 'lambda:DeleteFunction'
108-
- 'lambda:InvokeFunction'
109-
- 'lambda:PublishVersion'
110-
- 'lambda:RemovePermission'
111-
- 'lambda:Update*'
112-
- 'apigateway:GET'
113-
- 'apigateway:POST'
114-
- 'apigateway:PUT'
115-
- 'apigateway:DELETE'
116-
- 's3:CreateBucket'
117-
- 's3:DeleteBucket'
118-
- 's3:ListBucket'
119-
- 's3:ListBucketVersions'
120-
- 's3:PutObject'
121-
- 's3:GetObject'
122-
- 's3:DeleteObject'
83+
- 'logs:*'
84+
- 'codebuild:*'
85+
- 'cloudformation:*'
86+
- 'lambda:*'
87+
- 'apigateway:*'
88+
- 's3:*'
12389
- 'iam:PassRole'
124-
- 'kinesis:*'
12590
- 'iam:GetRole'
12691
- 'iam:CreateRole'
12792
- 'iam:PutRolePolicy'
12893
- 'iam:DeleteRolePolicy'
12994
- 'iam:DeleteRole'
130-
- 'cloudwatch:GetMetricStatistics'
95+
- 'iam:TagRole'
13196
- 'events:Put*'
13297
- 'events:Remove*'
13398
- 'events:Delete*'
134-
- 'dynamodb:*'
13599
Resource: "*"
136100
Roles:
137101
- !Ref CodeBuildRole
@@ -175,7 +139,7 @@ Resources:
175139
Environment:
176140
Type: "LINUX_CONTAINER"
177141
ComputeType: BUILD_GENERAL1_SMALL
178-
Image: aws/codebuild/nodejs:10.1.0
142+
Image: aws/codebuild/standard:7.0
179143
Artifacts:
180144
Type: CODEPIPELINE
181145

@@ -193,15 +157,19 @@ Resources:
193157
phases:
194158
build:
195159
commands:
196-
- bash deploy.sh
160+
- n 18.19.0
161+
- npm install --silent --progress-false
162+
- npm install --silent --progress=false -g [email protected]
163+
- npm install --silent --save–dev serverless-stack-output
164+
- serverless deploy
197165
Environment:
198166
Type: "LINUX_CONTAINER"
199167
ComputeType: BUILD_GENERAL1_SMALL
200168
EnvironmentVariables:
201169
- Name: env
202170
Type: PLAINTEXT
203171
Value: !Ref Environment
204-
Image: aws/codebuild/nodejs:10.1.0
172+
Image: aws/codebuild/standard:7.0
205173
Artifacts:
206174
Type: CODEPIPELINE
207175

@@ -236,7 +204,7 @@ Resources:
236204
OutputArtifacts:
237205
- Name: TheSourceCode
238206

239-
# Stage 2: Build using Serverless Framework
207+
# Stage 2: Run Your Tests
240208
- Name: TestBuild
241209
Actions:
242210
- Name: Test-Build

serverless.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ functions:
1313
handler: index.handler
1414
events:
1515
- http: ANY /
16-
- http: 'ANY {proxy+}'
16+
- http: 'ANY /{proxy+}'

0 commit comments

Comments
 (0)