-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update ansible to load put secrets in environment not .env file
- Loading branch information
1 parent
44da939
commit 135fd9b
Showing
3 changed files
with
48 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/bash | ||
|
||
# Check if the CERT_DIR environment variable is set | ||
if [ -z "$CERT_DIR" ]; then | ||
echo "Error: CERT_DIR environment variable is not set." | ||
exit 1 | ||
fi | ||
|
||
# Directory where the cert files will be written | ||
CERT_DIR="$1" | ||
# Ensure the directory exists | ||
mkdir -p "$CERT_DIR" | ||
|
||
# load cert.pem file | ||
aws secretsmanager get-secret-value \ | ||
--secret-id cert.pem \ | ||
--region {{ aws_region }} \ | ||
--query SecretString \ | ||
--output text \ | ||
> "${CERT_DIR}"/cert.pem | ||
|
||
# load key.pem file | ||
aws secretsmanager get-secret-value \ | ||
--secret-id key.pem \ | ||
--region {{ aws_region }} \ | ||
--query SecretString \ | ||
--output text \ | ||
> ${CERT_DIR}/key.pem | ||
|
||
# set environmental variables | ||
aws secretsmanager get-secret-value \ | ||
--secret-id {{ env_secret_id }} \ | ||
--region {{ aws_region }} \ | ||
--query SecretString \ | ||
| jq -r 'fromjson | to_entries | .[] | "export \(.key)=\(.value|tostring)"' \ | ||
| while read -r line; do eval "$line"; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters