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 | |
set -euo pipefail | |
# assuming MILESTONE_NAME is passed in via release pipeline | |
source config/test_workload.env | |
source helpers/lib.sh | |
main() { | |
local milestoneName=$1 | |
local workloadId=$(get_workload_id "${WORKLOAD_NAME}") | |
check_milestone "${workloadId}" "${milestoneName}" |
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 | |
AWS_REGIONS='"eu-west-1" "eu-west-2"' | |
ACCOUNT_IDS=''' | |
123456789012 | |
123456789011 | |
''' | |
APPLICATIONS=''' | |
arn:aws:servicecatalog:us-east-1: XXXXXXXXXX:/application/0bwdgnibevsc5clgtm7hehuljh | |
''' | |
ARCHITECTURAL_DESIGN='https://www.confluence.com' |
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 | |
get_workload_id() { | |
local workloadNamePrefix=${1:-null} | |
workloadId=$(aws wellarchitected list-workloads --workload-name-prefix "${workloadNamePrefix}" --query "WorkloadSummaries[0].WorkloadId" --output text) | |
if [[ "${workloadId}" == "None" ]] || [[ "${workloadId}" == "null" ]]; then | |
echo "No workload with prefix ${workloadNamePrefix} exists." | |
exit 1 | |
else | |
echo "${workloadId}" | |
fi |
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 | |
set -euo pipefail | |
source config/test_workload.env | |
source helpers/lib.sh | |
main() { | |
aws wellarchitected create-workload \ | |
--account-ids "${ACCOUNT_IDS}" \ | |
--architectural-design "${ARCHITECTURAL_DESIGN}" \ | |
--aws-regions "eu-west-1" "eu-west-2" \ |
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
function main() { | |
local keyKind=$1 | |
local cosmosDBAccountName=$2 | |
echo "Beginning key rotation on ${cosmosDBAccountName}" | |
echo "Key: ${keyKind}" | |
# Rotate key | |
newConnString=$(rotate_keys "${keyKind}" "${cosmosDBAccountName}" | tail -n 1) | |
# Test Connectivity with new key |
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
function update_keyvault_secret() { | |
local keyKind=$1 # The kind of CosmosDB account key, which must be either primary or secondary. | |
local secretValue=$2 | |
local cosmosDBAccountName=$3 | |
local vaultNames=("${cosmosDBAccountName%-mongo}" "${cosmosDBAccountName%-mongo}-ukw") | |
local secretName | |
if [[ "${keyKind}" == "primary" ]]; then | |
secretName='cosmosDBPrimaryConnectionString' | |
else |
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
Beginning key rotation on <account name> | |
Key: primary | |
INFO: Command ran in 213.162 seconds (init: 0.154, invoke: 213.007) | |
Testing connectivity with new primary key... | |
Connecting to: mongodb://<credentials>@ | |
MongoServerError: Invalid key | |
Connection attempt 3 unsuccessful, retrying in 40 seconds... | |
Current Mongosh Log ID: 618b9f15c57e6ca91fc75a8e | |
Connecting to: mongodb://<credentials>@ | |
MongoServerError: Invalid key |
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
# Test CosmosDB Connectivity with a given string | |
function test_connectivity() { | |
local connString=$1 | |
local counter=0 | |
local successCount=0 # count of successful attempts | |
local maxWait=120 # max time allowed between loops | |
local minWait=5 # start of process | |
local timeOut=$((120 * 60)) # max time allowed until the loop is cancelled | |
local waitTime=minWait # time to wait between loops | |
local requiredSuccessConnections=5 # Number of successful connections required |
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
function rotate_keys() { | |
local keyKind=$1 | |
local cosmosDBAccountName=$2 | |
local rgName="${2%-mongo}" | |
currentConnString=$(az cosmosdb keys list -n "${cosmosDBAccountName}" -g "${rgName}" --type connection-strings -o tsv --query "connectionStrings[? contains(description, '${keyKind:1} MongoDB')].connectionString") | |
# Start key rotation | |
if az cosmosdb keys regenerate -n "${cosmosDBAccountName}" -g "${rgName}" --key-kind "${keyKind}" --verbose; then | |
echo "Key rotation for ${cosmosDBAccountName} succeeded, retrieving ${keyKind} key" | |
newConnString=$(az cosmosdb keys list -n "${cosmosDBAccountName}" -g "${rgName}" --type connection-strings -o tsv --query "connectionStrings[? contains(description, '${keyKind:1} MongoDB')].connectionString") |
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 | |
function install_mongo_shell() { | |
# Installation instructions: https://docs.mongodb.com/mongodb-shell/install/ | |
# Check the Ubuntu version used and modify installation accordingly | |
osRelease=$(cat /etc/os-release | grep 'VERSION=') | |
wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add - | |
case $osRelease in | |
*"Xenial"*) | |
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list | |
;; |
NewerOlder