Created
April 19, 2017 07:12
-
-
Save tralamazza/28465e0fa184dc84b144250d0dde7b2d to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
if [[ "$#" -lt 1 ]]; | |
then | |
echo "Usage: $0 certificate-name [certs subfolder]" | |
exit 1 | |
fi | |
NAME=$1 | |
if [[ -f "domains.txt" ]]; | |
then | |
DOMAIN=`awk 'NR==1 {print $1}' domains.txt` | |
echo "domains.txt found, using it's first entry: ${DOMAIN}" | |
else | |
if [ "$#" -lt 2 ]; | |
then | |
echo "Error: Missing certs subfolder name" | |
exit 2 | |
fi | |
DOMAIN=$2 | |
fi | |
BASE_FOLDER="file://certs/${DOMAIN}" | |
PRIV_KEY="${BASE_FOLDER}/privkey.pem" | |
CHAIN="${BASE_FOLDER}/chain.pem" | |
CERT="${BASE_FOLDER}/cert.pem" | |
if [[ ! -f "${PRIV_KEY}" && ! -f "${CHAIN}" && ! -f "${CERT}"]]; | |
then | |
echo "Error: Missing certificate files" | |
exit 3 | |
fi | |
aws iam upload-server-certificate --server-certificate-name ${NAME} --private-key ${PRIV_KEY} --certificate-body ${CERT} --certificate-chain ${CHAIN} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment