From 653377f9757245f2b6743007d8a1cb7d26322ed6 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Tue, 4 Feb 2025 16:40:12 +0000 Subject: [PATCH] schema script --- src/schema/update.ps1 | 0 src/schema/update.sh | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) mode change 100644 => 100755 src/schema/update.ps1 create mode 100755 src/schema/update.sh diff --git a/src/schema/update.ps1 b/src/schema/update.ps1 old mode 100644 new mode 100755 diff --git a/src/schema/update.sh b/src/schema/update.sh new file mode 100755 index 00000000..585921bf --- /dev/null +++ b/src/schema/update.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +# Set working directory +ROOT_DIR="$(pwd)" +SCHEMA_URL="https://schema.cloudformation.us-east-1.amazonaws.com/CloudformationSchema.zip" +FILEPATH="${ROOT_DIR}/CloudformationSchema.zip" + +# Function to cleanup on exit +cleanup() { + rm -f "${FILEPATH}" +} + +# Error handling +set -e +trap cleanup EXIT + +# Remove existing JSON files +rm -f ./*.json + +# Download schema +echo "Downloading schema..." +curl -L -o "${FILEPATH}" "${SCHEMA_URL}" || { + echo "Failed to download schema" + exit 1 +} + +# Extract zip file +echo "Extracting schema..." +unzip -o "${FILEPATH}" || { + echo "Failed to extract schema" + exit 1 +}