-
Notifications
You must be signed in to change notification settings - Fork 38
/
aws-local-env.sh
78 lines (72 loc) · 3.22 KB
/
aws-local-env.sh
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
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
# aws-local-env.sh
#
# Disclaimer: Building AWS Packer images locally has not been tested. The Azure process has.
#
# Variables you'll need to trigger Packer image builds locally
# If you have an ~/.aws/credentials file, you'll need to override that with
# the credentials given to you via this repo: https://github.com/hashicorp/licensing-binaries
# and this job: https://tfe.hashicorp.engineering/terraform/licensing/environments/binaries/changes/runs
#
# The procedure for getting your binary credentials is documented in the [SE Handbook](https://docs.google.com/document/d/1lRYgJMIGejYbaxTpZmc3hnbj7aWRg7dFXCN3_x87mYQ/edit#heading=h.6blw4fxx8vz1)
#
# Below is one example of how to use it
#
#
## Example usage:
#
# $ cd /root/of/this/repository
# $ source aws-local-env.sh
# $ cd hashistack # or cd into any dir containing an AWS Packer build file
# $ packer build hashistack.json
#
# TODO: See if we need a separate set of variables for the binary downloads
# so we're not conflicting with the credentials being used to build the image.
# Source versions from this repository
source versions.sh
if [ -z ${S3BUCKET} ]; then
read -p $'\033[1;32mPlease enter an S3 bucket name for enterprise binary download: \033[0m' S3BUCKET
export S3BUCKET="${S3BUCKET}"
else
export S3BUCKET="${S3BUCKET}"
fi
if [ -z ${AWS_ACCESS_KEY_ID} ]; then
read -p $'\033[1;32mPlease enter an AWS access key ID for enterprise binary download: \033[0m' AWS_ACCESS_KEY_ID
export AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID}"
else
export AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID}"
fi
if [ -z ${AWS_SECRET_ACCESS_KEY} ]; then
read -p $'\033[1;32mPlease enter an AWS secret access key for enterprise binary download: \033[0m' AWS_SECRET_ACCESS_KEY
export AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY}"
else
export AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY}"
fi
export VCS_NAME="local"
export RELEASE_VERSION="${RELEASE_VERSION}"
export CONSUL_VERSION="${CONSUL_VERSION}"
export VAULT_VERSION="${VAULT_VERSION}"
export NOMAD_VERSION="${NOMAD_VERSION}"
# Re-source this file for every Packer run to re-generate URLs
# They are set to expire after 10 minutes
export CONSUL_ENT_URL=$(AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY}" \
AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID}" \
aws s3 presign \
--region="us-east-1" \
s3://${S3BUCKET}/consul-enterprise/${CONSUL_VERSION}/consul-enterprise_${CONSUL_VERSION}+ent_linux_amd64.zip \
--expires-in 600)
export VAULT_ENT_URL=$(AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY}" \
AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID}" \
aws s3 presign \
--region="us-east-1" \
s3://${S3BUCKET}/vault/prem/${VAULT_VERSION}/vault-enterprise_${VAULT_VERSION}+prem_linux_amd64.zip \
--expires-in 600)
export NOMAD_ENT_URL=$(AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY}" \
AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID}" \
aws s3 presign \
--region="us-east-1" \
s3://${S3BUCKET}/nomad-enterprise/${NOMAD_VERSION}/nomad-enterprise_${NOMAD_VERSION}+ent_linux_amd64.zip \
--expires-in 600)
# Feel free to comment out the below reminder if you're familiar with this process
echo -e "\n\033[0;32mBinary downloads generated by this script expire in 10 minutes."
echo -e "Make sure to re-source this file to regenerate URLs for every Packer build."