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:
aws-elastic-beanstalk: circleci/aws-elastic-beanstalk@2.0.1
Use aws-elastic-beanstalk
elements in your existing workflows and jobs.
Easily deploy your application to Elastic Beanstalk with the provided deploy job. This example shows how a Node.JS application may be tested and then deployed in a realistic CI environment, using both the Node orb and AWS Elastic Beanstalk orb. This assumes the EB environment already exists and is awaiting deployments.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
version: '2.1'
orbs:
eb: circleci/aws-elastic-beanstalk@1.0.0
node: circleci/node@4.1.0
workflows:
elastic-beanstalk-workflow:
jobs:
- node/test
- eb/deploy:
context: aws-creds
environment-name: my-app
filters:
branches:
only:
- main
label: version-<<pipeline.number>>
requires:
- node/test
Easily install and utilize the AWS Elastic Beanstalk CLI within your CI pipelines.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
version: '2.1'
orbs:
eb: circleci/aws-elastic-beanstalk@1.0.0
jobs:
eb-demo:
docker:
- image: cimg/base:stable
steps:
- checkout
- eb/setup
- run:
command: |
eb create my-environment
eb deploy my-environment
eb status
name: You may now use the EB CLI within this job
workflows:
elastic-beanstalk-workflow:
jobs:
- eb-demo
Deploy an update to an existing AWS Elastic Beanstalk environment.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
app-dir | Path to the directory containing your application source code. My default, the current directory will be used. | No | . | string |
application-name | The name of the application (used during `eb init`). | No | '' | string |
description | The description for the application version, enclosed in double quotation marks. | No | '' | string |
environment-name | The name of the existing environment (created with `eb create`) to update. | No | '' | string |
image | Enter a custom docker image for this job. By default CircleCI's optimized `cimg/base` image will be used. | No | cimg/base:stable | string |
label | Specify a label to use for the version that the EB CLI creates. If the label has already been used, the EB CLI redeploys the previous version with that label. | No | '' | string |
platform-version | The platform version to use. You can specify a platform, a platform and version, a platform branch, a solution stack name, or a solution stack ARN. Use 'eb platform list' to get a list of available configurations. | No | node.js | string |
Install and authenticate with the Elastic Beanstalk CLI. You must have your AWS auth environment variables set for ["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_DEFAULT_REGION"].
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# 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: |
Deploy and scale web applications and services via AWS Elastic Beanstalk with CircleCI.
display:
home_url: https://aws.amazon.com/elasticbeanstalk/
source_url: https://github.com/CircleCI-Public/aws-elastic-beanstalk-orb
commands:
setup:
description: |
Install and authenticate with the Elastic Beanstalk CLI. You must have your AWS auth environment variables set for ["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_DEFAULT_REGION"].
steps:
- run:
command: |
if [[ $EUID == 0 ]]; then export SUDO=""; else # Check if we are root
export SUDO="sudo";
fi
SetupPython() {
# setups python3
$SUDO apt-get -qq -y install python3-dev
SetupPipx
}
SetupPipx() {
if [ "$(which pip | tail -1)" ]; then
echo "pip found"
else
echo "pip not found"
$SUDO apt-get update
$SUDO apt-get install -qq -y python3-setuptools
curl https://bootstrap.pypa.io/pip/3.5/get-pip.py | python3
fi
# install venv with system for pipx
# by using pipx we dont have to worry about activating the virtualenv before using eb
$SUDO apt-get -qq -y install python3-venv
pip install pipx
}
InstallEBCLI() {
if uname -a | grep Darwin > /dev/null 2>&1; then
cd /tmp || { echo "Not able to access /tmp"; return; }
git clone https://github.com/aws/aws-elastic-beanstalk-cli-setup.git
brew install zlib openssl readline
CFLAGS="-I$(brew --prefix openssl)/include -I$(brew --prefix readline)/include -I$(xcrun --show-sdk-path)/usr/include" LDFLAGS="-L$(brew --prefix openssl)/lib -L$(brew --prefix readline)/lib -L$(brew --prefix zlib)/lib" ./aws-elastic-beanstalk-cli-setup/scripts/bundled_installer >/dev/null 2>&1
return $?
elif uname -a | grep Linux > /dev/null 2>&1; then
$SUDO apt-get -qq update > /dev/null
# these are the system level deps for the ebcli
$SUDO apt-get -qq -y install build-essential zlib1g-dev libssl-dev libncurses-dev libffi-dev libsqlite3-dev libreadline-dev libbz2-dev
if [ "$(which python3 | tail -1)" ]; then
echo "Python3 env found"
SetupPipx
else
echo "Python3 env not found, setting up python with apt"
SetupPython
fi
fi
pipx install awsebcli
echo "Complete"
}
CheckAWSEnvVars() {
ERRMSGTEXT="has not been set. This environment variable is required for authentication."
if [ -z "$AWS_ACCESS_KEY_ID" ]; then
echo "AWS_ACCESS_KEY_ID $ERRMSGTEXT"
exit 1
fi
if [ -z "$AWS_SECRET_ACCESS_KEY" ]; then
echo "AWS_SECRET_ACCESS_KEY $ERRMSGTEXT"
exit 1
fi
if [ -z "$AWS_DEFAULT_REGION" ]; then
echo "AWS_DEFAULT_REGION $ERRMSGTEXT"
exit 1
fi
}
# Will not run if sourced for bats.
# View src/tests for more information.
TEST_ENV="bats-core"
if [ "${0#*$TEST_ENV}" == "$0" ]; then
CheckAWSEnvVars
InstallEBCLI
fi
name: Setting Up Elastic Beanstalk CLI
jobs:
deploy:
description: |
Deploy an update to an existing AWS Elastic Beanstalk environment.
docker:
- image: <<parameters.image>>
parameters:
app-dir:
default: .
description: Path to the directory containing your application source code. My default, the current directory will be used.
type: string
application-name:
default: ""
description: The name of the application (used during `eb init`).
type: string
description:
default: ""
description: The description for the application version, enclosed in double quotation marks.
type: string
environment-name:
default: ""
description: The name of the existing environment (created with `eb create`) to update.
type: string
image:
default: cimg/base:stable
description: Enter a custom docker image for this job. By default CircleCI's optimized `cimg/base` image will be used.
type: string
label:
default: ""
description: Specify a label to use for the version that the EB CLI creates. If the label has already been used, the EB CLI redeploys the previous version with that label.
type: string
platform-version:
default: node.js
description: The platform version to use. You can specify a platform, a platform and version, a platform branch, a solution stack name, or a solution stack ARN. Use 'eb platform list' to get a list of available configurations.
type: string
steps:
- checkout
- setup
- run:
command: |
eb init <<parameters.application-name>> -r $AWS_DEFAULT_REGION -p <<parameters.platform-version>>
eb deploy <<parameters.environment-name>> <<#parameters.label>>-l <<parameters.label>><</parameters.label>> <<#parameters.description>>-m <<parameters.description>><</parameters.description>>
name: EB Deploy
working_directory: <<parameters.app-dir>>
examples:
deploy_eb_application_to_env:
description: |
Easily deploy your application to Elastic Beanstalk with the provided deploy job.
This example shows how a Node.JS application may be tested and then deployed in a realistic CI environment, using both the Node orb and AWS Elastic Beanstalk orb.
This assumes the EB environment already exists and is awaiting deployments.
usage:
version: "2.1"
orbs:
eb: circleci/aws-elastic-beanstalk@1.0.0
node: circleci/node@4.1.0
workflows:
elastic-beanstalk-workflow:
jobs:
- node/test
- eb/deploy:
context: aws-creds
environment-name: my-app
filters:
branches:
only:
- main
label: version-<<pipeline.number>>
requires:
- node/test
install_eb_cli:
description: |
Easily install and utilize the AWS Elastic Beanstalk CLI within your CI pipelines.
usage:
version: "2.1"
orbs:
eb: circleci/aws-elastic-beanstalk@1.0.0
jobs:
eb-demo:
docker:
- image: cimg/base:stable
steps:
- checkout
- eb/setup
- run:
command: |
eb create my-environment
eb deploy my-environment
eb status
name: You may now use the EB CLI within this job
workflows:
elastic-beanstalk-workflow:
jobs:
- eb-demo