Skip to content

Commit

Permalink
Merge pull request #183 from malscent/MB-54388-UpdatesForSyncGateway304
Browse files Browse the repository at this point in the history
Moved template to s3 bucket due to length
  • Loading branch information
malscent authored Nov 7, 2022
2 parents 6562297 + 521bd6b commit a6797db
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions aws/CouchbaseServerAndSyncGateway/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

set -eu

function __generate_random_string() {
NEW_UUID=$(LC_ALL=C tr -dc a-z0-9 </dev/urandom | head -c 10 ; echo '')
echo "${NEW_UUID}"
}

SCRIPT_SOURCE=${BASH_SOURCE[0]/%deploy.sh/}
bash "${SCRIPT_SOURCE}makeArchives.sh"
STACK_NAME=$1
PRICING_TYPE=$2 #byol or hourlypricing
TEMPLATE_BODY="file://${SCRIPT_SOURCE}../../build/aws/CouchbaseServerAndSyncGateway/aws-cbs-$PRICING_TYPE.template"
echo "$TEMPLATE_BODY"
#TEMPLATE_BODY="file://couchbase-$2.template"
REGION=$(aws configure get region)
echo "$REGION"
if [ -z "$REGION" ]; then
Expand All @@ -28,11 +30,18 @@ VpcName=$(aws ec2 describe-vpcs --filter "Name=isDefault,Values=true" | jq -r '.
SubnetId=$(aws ec2 describe-subnets --filter "Name=vpc-id,Values=${VpcName}" --max-items 1 --region "$REGION" | jq -r '.Subnets[].SubnetId')
#SubnetId=subnet-08476a90d895839b4

TEMPLATE_BODY_FILE="${SCRIPT_SOURCE}/../../build/aws/CouchbaseServerAndSyncGateway/aws-cbs-$PRICING_TYPE.template"
echo "$TEMPLATE_BODY_FILE"

BUCKET="mp-test-templates$(__generate_random_string)"
aws s3api create-bucket --acl public-read --bucket "$BUCKET" --region "$REGION"
KEY="aws-cb-server$(__generate_random_string).template"
aws s3api put-object --bucket "$BUCKET" --key "$KEY" --body "$TEMPLATE_BODY_FILE"

aws cloudformation create-stack \
--disable-rollback \
--capabilities CAPABILITY_IAM \
--template-body "${TEMPLATE_BODY}" \
--template-url "https://${BUCKET}.s3.amazonaws.com/${KEY}" \
--stack-name "${STACK_NAME}" \
--region "${REGION}" \
--parameters \
Expand Down

0 comments on commit a6797db

Please sign in to comment.