From 6790d03a05cd458e40cd9d602cf8b8f498a2576e Mon Sep 17 00:00:00 2001 From: Andrew McDermott Date: Fri, 24 Aug 2018 15:13:23 +0100 Subject: [PATCH] Add convenience script to update AWS secrets Convenience script to update AWS secrets in examples/addons.yaml. Usage: $ cd $GOPATH/sigs.k8s.io/cluster-api-provider-aws $ ./examples/update-aws-secrets.sh Only works if both: - AWS_SECRET_ACCESS_KEY - AWS_ACCESS_KEY_ID are set in the environment. --- README.md | 14 ++++++++++++-- examples/render-aws-secrets.sh | 25 +++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) create mode 100755 examples/render-aws-secrets.sh diff --git a/README.md b/README.md index 5a09778ad4..911569b628 100644 --- a/README.md +++ b/README.md @@ -71,17 +71,27 @@ Note: this info is RH only, it needs to be backported every time the `README.md` 4. **Deploying the cluster-api stack manifests** - Add your aws credentials to the `addons.yaml` file in base64 format: + Add your AWS credentials to the `addons.yaml` file (in base64 + format). You can either do this manually or use the + `examples/render-aws-secrets.sh`. + + The easy deployment is: + + ```sh + ./examples/render-aws-secrets.sh examples/addons.yaml | kubectl apply -f - + ``` + + The manual deployment is: ``` sh $ echo -n 'your_id' | base64 $ echo -n 'your_key' | base64 + $ kubectl apply -f examples/addons.yaml ``` Deploy the components: ```sh - $ kubectl apply -f examples/addons.yaml $ kubectl apply -f examples/cluster-api-server.yaml $ kubectl apply -f examples/provider-components.yml ``` diff --git a/examples/render-aws-secrets.sh b/examples/render-aws-secrets.sh new file mode 100755 index 0000000000..d84cb1ce0d --- /dev/null +++ b/examples/render-aws-secrets.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +set -e + +if [ $# -lt 1 ]; then + echo "usage: $0 " + exit 1 +fi + +if [ -z "$AWS_ACCESS_KEY_ID" ]; then + echo "error: AWS_ACCESS_KEY_ID is not set in the environment" 2>&1 + exit 1 +fi + +if [ -z "$AWS_SECRET_ACCESS_KEY" ]; then + echo "error: AWS_SECRET_ACCESS_KEY is not set in the environment" 2>&1 + exit 1 +fi + +x=$(echo -n "$AWS_ACCESS_KEY_ID" | base64) +y=$(echo -n "$AWS_SECRET_ACCESS_KEY" | base64) + +sed -e "s/awsAccessKeyId:.*/awsAccessKeyId: $x/" \ + -e "s/awsSecretAccessKey:.*/awsSecretAccessKey: $y/" \ + "$1"