-
Notifications
You must be signed in to change notification settings - Fork 722
Expand file tree
/
Copy pathssm.sh
More file actions
executable file
·67 lines (51 loc) · 1.79 KB
/
ssm.sh
File metadata and controls
executable file
·67 lines (51 loc) · 1.79 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
61
62
63
64
65
66
67
#!/bin/bash
# NOTE: this script is only for demonstration purposes
# Script to create SSM parameters outside of Terraform
# and set them as environment variables for Terraform
APP_ID=
APP_PRIVATE_KEY_FILE=
APP_WEBHOOK_SECRET=
APP_PRIVATE_KEY=$(base64 -i $APP_PRIVATE_KEY_FILE)
SSM_PATH="/github-runners/example/app"
if [ -z "$APP_ID" ]; then
echo "APP_ID is not set"
exit 1
fi
if [ -z "$APP_WEBHOOK_SECRET" ]; then
echo "APP_WEBHOOK_SECRET is not set"
exit 1
fi
if [ -z "$APP_PRIVATE_KEY_FILE" ]; then
echo "APP_PRIVATE_KEY_FILE is not set"
exit 1
fi
export AWS_PAGER=""
export AWS_REGION=eu-central-1
export TF_VAR_aws_region=$AWS_REGION
# GitHub App ID
aws ssm put-parameter \
--name "${SSM_PATH}/github_app_id" \
--overwrite \
--value "${APP_ID}" \
--type "SecureString"
# GitHub App Private Key
aws ssm put-parameter \
--name "${SSM_PATH}/github_app_key_base64" \
--overwrite \
--value "${APP_PRIVATE_KEY}" \
--type "SecureString"
# GitHub App Installation ID
aws ssm put-parameter \
--name "${SSM_PATH}/github_app_webhook_secret" \
--overwrite \
--value "${APP_WEBHOOK_SECRET}" \
--type "SecureString"
github_app_id_ssm=$(aws ssm get-parameter --name "${SSM_PATH}/github_app_id" --query 'Parameter.{arn:ARN,name:Name}' --output json)
github_app_key_base64_ssm=$(aws ssm get-parameter --name "${SSM_PATH}/github_app_key_base64" --query 'Parameter.{arn:ARN,name:Name}' --output json)
github_app_webhook_secret_ssm=$(aws ssm get-parameter --name "${SSM_PATH}/github_app_webhook_secret" --query 'Parameter.{arn:ARN,name:Name}' --output json)
export TF_VAR_github_app_ssm_parameters="{
\"id\": `echo $github_app_id_ssm`,
\"key_base64\": `echo $github_app_key_base64_ssm`,
\"webhook_secret\": `echo $github_app_webhook_secret_ssm`
}"
export TF_VAR_environment=external-ssm