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-parameter-store: circleci/aws-parameter-store@1.0.0
Use aws-parameter-store
elements in your existing workflows and jobs.
Load environment variables into a job. The load command will automatically fetch all environment variables permitted via the IAM credentials of the user under the "Describe Parameters" command. https://docs.aws.amazon.com/cli/latest/reference/ssm/describe-parameters.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
jobs:
my-job:
docker:
- image: circleci/<language>:<version TAG>
steps:
- aws-parameter-store/load
- checkout
orbs:
aws-parameter-store: circleci/aws-parameter-store@x.y.z
version: 2.1
workflows:
build_and_test:
jobs:
- my-job
version: 2
Use the "with-secrets" job to quickly and easily run commands in an environment with your secrets pre-loaded.
1
2
3
4
5
6
7
8
9
10
orbs:
aws-parameter-store: circleci/aws-parameter-store@x.y.z
version: 2.1
workflows:
my-workflow:
jobs:
- aws-parameter-store/with-secrets:
image: circleci/<language>:<version TAG>
post-steps:
- run: null
Environment pre-loaded with environment variables. Supply steps and add to your Workflow.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
filter | One or more filters. Use a filter to return a more specific list of results. Ex: "Key=string,Values=string,..."
| No | '' | string |
Fetch and load in your parameter store values as environment variables.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
filter | One or more filters. Use a filter to return a more specific list of results. Ex: "Key=string,Values=string,..."
| No | '' | string |
Default environment for "load" command. To load environment variables into your own job, define a job an invoke the "load" command
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
image | Select a custom Docker image. https://hub.docker.com/r/circleci/
| No | circleci/python:2.7 | 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
# This code is licensed from CircleCI to the user under the MIT license.
# See here for details: https://circleci.com/developer/ja/orbs/licensing
commands:
load:
description: |
Fetch and load in your parameter store values as environment variables.
parameters:
filter:
default: ""
description: |
One or more filters. Use a filter to return a more specific list of results. Ex: "Key=string,Values=string,..."
type: string
steps:
- aws-cli/install
- aws-cli/configure
- run:
command: |
mkdir -p /tmp/parameterstore/
for row in $(aws ssm describe-parameters --no-paginate --filters << parameters.filter >> | jq -c '.Parameters[]'); do
_jq() {
PARNAME=$(jq -r '.Name' \<<< "${row}")
PARDATA=$(aws ssm get-parameters --with-decryption --names "${PARNAME}" | jq '.Parameters[].Value')
if [ -z "$PARDATA" ]
then
echo "${PARNAME} appears to be empty. Please double check the value of this parameter."
exit 1
fi
if [ -f /tmp/parameterstore/"${PARNAME}" ]
then
echo "This value has already been stored. Is this value stored twice?"
exit 1
fi
echo "${PARDATA}" >> /tmp/parameterstore/"${PARNAME}"
echo "export ${PARNAME}=$(cat /tmp/parameterstore/"${PARNAME}")" >> /tmp/parameterstore/PARAMETERSTORESOURCEFILE
}
_jq
done
source /tmp/parameterstore/PARAMETERSTORESOURCEFILE
name: Load AWS Parameters into environment
description: |
Load AWS Parameter Store keys as environment variables. Alpha
examples:
custom-job:
description: |
Load environment variables into a job. The load command will automatically fetch all environment variables permitted via the IAM credentials of the user under the "Describe Parameters" command. https://docs.aws.amazon.com/cli/latest/reference/ssm/describe-parameters.html
usage:
jobs:
my-job:
docker:
- image: circleci/<language>:<version TAG>
steps:
- aws-parameter-store/load
- checkout
orbs:
aws-parameter-store: circleci/aws-parameter-store@x.y.z
version: 2.1
workflows:
build_and_test:
jobs:
- my-job
version: 2
with-secrets:
description: |
Use the "with-secrets" job to quickly and easily run commands in an environment with your secrets pre-loaded.
usage:
orbs:
aws-parameter-store: circleci/aws-parameter-store@x.y.z
version: 2.1
workflows:
my-workflow:
jobs:
- aws-parameter-store/with-secrets:
image: circleci/<language>:<version TAG>
post-steps:
- run: null
executors:
default:
description: |
Default environment for "load" command. To load environment variables into your own job, define a job an invoke the "load" command
docker:
- image: <<parameters.image>>
parameters:
image:
default: circleci/python:2.7
description: |
Select a custom Docker image. https://hub.docker.com/r/circleci/
type: string
jobs:
with-secrets:
description: |
Environment pre-loaded with environment variables. Supply steps and add to your Workflow.
executor: default
parameters:
filter:
default: ""
description: |
One or more filters. Use a filter to return a more specific list of results. Ex: "Key=string,Values=string,..."
type: string
steps:
- load:
filter: << parameters.filter >>
orbs:
aws-cli: circleci/aws-cli@0.1.13
version: 2.1