Created
June 16, 2025 15:27
-
-
Save thomashartm/e59201a951c76ddca8c6a980fdb81a00 to your computer and use it in GitHub Desktop.
Clones a terragrunt and or a terraform stack to support the case where we need to clone stacks for different environments in terragrunt. Removes the state directories.
This file contains hidden or 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 | |
# Check if the correct number of arguments is provided | |
if [ "$#" -ne 2 ]; then | |
echo "Usage: $0 <source_directory> <target_directory>" | |
exit 1 | |
fi | |
SOURCE_DIR=$1 | |
TARGET_DIR=$2 | |
echo "Cloning content of $SOURCE_DIR to $TARGET_DIR..." | |
# Create the target directory if it doesn't exist | |
mkdir -p "$TARGET_DIR" | |
# Use rsync to copy only directories and terragrunt.hcl files, excluding .terragrunt-cache directory | |
rsync -av --exclude '*/*terragrunt-*' --exclude '*/*lock*' --include '*/terragrunt*' "$SOURCE_DIR/" "$TARGET_DIR/" | |
echo "Copying completed." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment