diff --git a/aws/CouchbaseServer/mappings.json b/aws/CouchbaseServer/mappings.json index 4147054..918766c 100644 --- a/aws/CouchbaseServer/mappings.json +++ b/aws/CouchbaseServer/mappings.json @@ -1,49 +1,49 @@ { "CouchbaseServer": { "ap-northeast-1": { - "AMI": "ami-006d67711fd911e5c" + "AMI": "ami-045a9759e321173f6" }, "ap-northeast-2": { - "AMI": "ami-0bb00e82a3c2cca28" + "AMI": "ami-056144412f917631d" }, "ap-south-1": { - "AMI": "ami-0e06b3b65d62c5d30" + "AMI": "ami-0f01e5c2de0fa17d0" }, "ap-southeast-1": { - "AMI": "ami-0379a65f2fa03d5b7" + "AMI": "ami-02ece6a720722bfca" }, "ap-southeast-2": { - "AMI": "ami-0023cef366e0c4b2d" + "AMI": "ami-0e8f8550d8add8ed9" }, "ca-central-1": { - "AMI": "ami-0c7722777643a9e72" + "AMI": "ami-05b5af5a427fc5d0f" }, "eu-central-1": { - "AMI": "ami-0ae00bfc87b9ea300" + "AMI": "ami-0c89adc51e4f33336" }, "eu-west-1": { - "AMI": "ami-054ef0493de178bdc" + "AMI": "ami-036d8a7f6f0b3960c" }, "eu-west-2": { - "AMI": "ami-0db0d35e2700044e2" + "AMI": "ami-077196b703a687516" }, "eu-west-3": { - "AMI": "ami-0f4cb19f640882dab" + "AMI": "ami-02cd17f569992d278" }, "sa-east-1": { - "AMI": "ami-03960e1e81d72ace3" + "AMI": "ami-0db98f19ea4593153" }, "us-east-1": { - "AMI": "ami-0123a0183c8ae744b" + "AMI": "ami-065b9cb00c0f09196" }, "us-east-2": { - "AMI": "ami-0336f57646fa2ad14" + "AMI": "ami-048fe4e089fe72cae" }, "us-west-1": { - "AMI": "ami-0105833bf06e4ab01" + "AMI": "ami-0c58142ab050b48a3" }, "us-west-2": { - "AMI": "ami-0a458e0f7328f5d1d" + "AMI": "ami-0cad8056d08cb8e97" } } } diff --git a/aws/couchbase-ami-creation/rpm_exploder.sh b/aws/couchbase-ami-creation/rpm_exploder.sh index 11c4b42..2d0eecc 100644 --- a/aws/couchbase-ami-creation/rpm_exploder.sh +++ b/aws/couchbase-ami-creation/rpm_exploder.sh @@ -148,4 +148,3 @@ _EOF chmod 664 /etc/systemd/system/cb-server-startup.service systemctl daemon-reload systemctl enable cb-server-startup.service -systemctl start cb-server-startup.service \ No newline at end of file diff --git a/aws/couchbase-ami-creation/startup.sh b/aws/couchbase-ami-creation/startup.sh index 750b761..6e5ace4 100644 --- a/aws/couchbase-ami-creation/startup.sh +++ b/aws/couchbase-ami-creation/startup.sh @@ -24,13 +24,17 @@ fi TAGS=$(aws ec2 describe-instances --instance-id "$instanceId" --query 'Reservations[*].Instances[*].Tags[*]' --output json --region "$region" | jq -r 'flatten | .[]') - +HASROLE=$(curl -s -o /dev/null -w "%{http_code}" http://169.254.169.254/latest/meta-data/iam) # we may not be able to retrieve tags due to IAM permissions. If not we just want to start the instance and go away -if [[ -z "$TAGS" ]]; then +if [[ -z "$TAGS" ]] && [[ "$HASROLE" == "404" ]]; then echo "Unable to retrieve tags, check IAM permissions, simply starting couchbase server service." bash /setup/postinstall.sh 0 bash /setup/posttransaction.sh exit 0 +else + # Let's wait a sec and try again + sleep 10 + TAGS=$(aws ec2 describe-instances --instance-id "$instanceId" --query 'Reservations[*].Instances[*].Tags[*]' --output json --region "$region" | jq -r 'flatten | .[]') fi VERSION=$(echo "$TAGS" | jq -r 'select(.Key == "couchbase:server:version").Value') @@ -154,10 +158,16 @@ else NAME="couchbase-${SERVICES//,/$'-'}-server" fi -aws ec2 create-tags \ - --region "${region}" \ - --resources "${instanceId}" \ - --tags Key=Name,Value="$NAME" +TAGGED_NAME=$(echo "$TAGS" | jq -r 'select(.Key == "Name").Value') + +# We should only name the instance if they haven't already +# no need to overwrite their name +if [[ -z "$TAGGED_NAME" ]]; then + aws ec2 create-tags \ + --region "${region}" \ + --resources "${instanceId}" \ + --tags Key=Name,Value="$NAME" +fi CLUSTER_HOST=$rallyPublicDNS SUCCESS=1