-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathorb.yml
More file actions
60 lines (60 loc) · 2.13 KB
/
Copy pathorb.yml
File metadata and controls
60 lines (60 loc) · 2.13 KB
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
version: 2.1
description: An orb to get AWS parameters from the parameter store
orbs:
aws-cli: circleci/aws-cli@0.1.22
commands:
aws-get-parameters:
description: "Get parameter list from aws"
parameters:
values:
type: string
output-file:
type: string
aws-access-key-id:
default: AWS_ACCESS_KEY_ID
description: |
AWS access key id for IAM role. Set this to the name of
the environment variable you will use to hold this
value, i.e. AWS_ACCESS_KEY.
type: env_var_name
aws-region:
default: AWS_DEFAULT_REGION
description: |
Env var of AWS region to operate in
(defaults to AWS_DEFAULT_REGION)
type: env_var_name
aws-secret-access-key:
default: AWS_SECRET_ACCESS_KEY
description: |
AWS secret key for IAM role. Set this to the name of
the environment variable you will use to hold this
value, i.e. $AWS_SECRET_ACCESS_KEY.
type: env_var_name
profile-name:
default: default
description: Profile name to be configured.
type: string
steps:
- aws-cli/setup:
aws-access-key-id: << parameters.aws-access-key-id >>
aws-secret-access-key: << parameters.aws-secret-access-key >>
profile-name: << parameters.profile-name >>
aws-region: << parameters.aws-region >>
- run:
name: Create File
command: echo > << parameters.output-file >>
- run:
name: Get AWS parameters and save to file
command: |
for value in << parameters.values >>
do
IFS='=' read -ra tmp \<<< "$value";
AWS_KEY=${tmp[0]}
LOCAL_KEY=${tmp[1]}
PARDATA=$(aws ssm get-parameters --with-decryption --names "${AWS_KEY}" | jq '.Parameters[].Value')
if [ -z "$PARDATA" ]; then
echo no data found in AWS for $AWS_KEY $LOCAL_KEY
exit -1
fi
echo "export ${LOCAL_KEY}=${PARDATA}" >> << parameters.output-file >>
done