Use CircleCI version 2.1 at the top of your .circleci/config.yml file.
1
version: 2.1
Add the orbs
stanza below your version, invoking the orb:
1
2
orbs:
serverless-framework: circleci/serverless-framework@2.0.2
Use serverless-framework
elements in your existing workflows and jobs.
Use the Serverless orb's "setup" command to install the Serverless Framework CLI and authenticate with your account if an API key is provided. This example shows how to construct a custom "deploy" job using the Serverless and AWS CLI orbs to deploy an app to AWS.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
version: '2.1'
orbs:
aws-cli: circleci/aws-cli@3.1
serverless-framework: circleci/serverless-framework@2.0
jobs:
deploy:
executor: serverless-framework/default
steps:
- checkout
- aws-cli/setup
- serverless-framework/setup
- run:
command: serverless deploy -v
name: deploy
workflows:
deploy:
jobs:
- deploy
Make use of the Node, AWS CLI, and Serverless Framework orbs to test and deploy your serverless Node.js applications.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
version: '2.1'
orbs:
aws-cli: circleci/aws-cli@3.1
node: circleci/node@5.0.2
serverless-framework: circleci/serverless-framework@2.0
jobs:
deploy:
executor: serverless-framework/default
steps:
- checkout
- aws-cli/setup
- serverless-framework/setup
- run:
command: serverless deploy -v
name: deploy
workflows:
deploy:
jobs:
- node/test:
version: 16.14.2
- deploy:
requires:
- node/test
Install and authenticate with the Serverless CLI.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
mirror | Select the geo-location for the download mirror. By default the value will be `us`, do not change if on CircleCI Cloud. Switch to `cn` for the China hosted mirror. | No | us | enum |
version | Specify the version of the Serverless Framework CLI to install. By default, the latest version will be used. | No | '' | string |
Highly cached minimal Ubuntu docker designed for CircleCI with Python and Node.js installed.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
python-version | Select your python version or any of the available tags here: https://hub.docker.com/r/cimg/python.
| No | 3.10-node | string |
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
# This code is licensed from CircleCI to the user under the MIT license.
# See here for details: https://circleci.com/developer/orbs/licensing
version: 2.1
description: |
Add the Serverless Framework CLI to your serverless deployment pipeline with ease. Easily and automatically test and deploy serverless applications to your favorite cloud provider.
display:
home_url: https://serverless.com/
source_url: https://github.com/CircleCI-Public/serverless-framework-orb
commands:
setup:
description: |
Install and authenticate with the Serverless CLI.
parameters:
mirror:
default: us
description: Select the geo-location for the download mirror. By default the value will be `us`, do not change if on CircleCI Cloud. Switch to `cn` for the China hosted mirror.
enum:
- us
- cn
type: enum
version:
default: ""
description: Specify the version of the Serverless Framework CLI to install. By default, the latest version will be used.
type: string
steps:
- run:
command: |
#!/bin/bash
[ "$ORB_PARAM_MIRROR" = "cn" ] && locale=cn
[ "$ORB_PARAM_MIRROR" = "us" ] && locale=us
# Temporarily pin to github per Serverless recommendation.
# Note that locale-specific mirror features will be mostly unavailable.
# See https://forum.serverless.com/t/serverless-deploy-failing-when-run-from-circleci/20184/14
install_url="https://raw.githubusercontent.com/serverless/serverless/v3/scripts/pkg/install.sh"
# Let Serverless handle mirror selection.
curl -o- -L "${install_url}" | VERSION="$ORB_PARAM_SERVERLESS_VERSION" SLS_GEO_LOCATION="$locale" bash
# shellcheck disable=SC2016
echo 'export PATH=$HOME/.serverless/bin:$PATH' >> "$BASH_ENV"
# shellcheck disable=SC1090
source "$BASH_ENV"
# Check for Serverless key
if [ -z "$SERVERLESS_ACCESS_KEY" ]; then
echo "Error: The environment variable SERVERLESS_ACCESS_KEY is empty.
Please create your serverless dashboard access key and add it to this project as a project environment vairable
or via contexts.
https://serverless.com/framework/docs/dashboard/cicd/running-in-your-own-cicd#configure-environment-variables"
fi
environment:
ORB_PARAM_MIRROR: <<parameters.mirror>>
ORB_PARAM_SERVERLESS_VERSION: <<parameters.version>>
name: Install Serverless CLI
executors:
default:
description: |
Highly cached minimal Ubuntu docker designed for CircleCI with Python and Node.js installed.
docker:
- image: cimg/python:<<parameters.python-version>>
parameters:
python-version:
default: 3.10-node
description: |
Select your python version or any of the available tags here: https://hub.docker.com/r/cimg/python.
type: string
examples:
simple_deploy_aws:
description: |
Use the Serverless orb's "setup" command to install the Serverless Framework CLI and authenticate with your account if an API key is provided. This example shows how to construct a custom "deploy" job using the Serverless and AWS CLI orbs to deploy an app to AWS.
usage:
version: "2.1"
orbs:
aws-cli: circleci/aws-cli@3.1
serverless-framework: circleci/serverless-framework@2.0
jobs:
deploy:
executor: serverless-framework/default
steps:
- checkout
- aws-cli/setup
- serverless-framework/setup
- run:
command: serverless deploy -v
name: deploy
workflows:
deploy:
jobs:
- deploy
test_and_deploy_node_aws:
description: |
Make use of the Node, AWS CLI, and Serverless Framework orbs to test and deploy your serverless Node.js applications.
usage:
version: "2.1"
orbs:
aws-cli: circleci/aws-cli@3.1
node: circleci/node@5.0.2
serverless-framework: circleci/serverless-framework@2.0
jobs:
deploy:
executor: serverless-framework/default
steps:
- checkout
- aws-cli/setup
- serverless-framework/setup
- run:
command: serverless deploy -v
name: deploy
workflows:
deploy:
jobs:
- node/test:
version: 16.14.2
- deploy:
requires:
- node/test