so currently I have a codebuild that is triggered by codepipeline when I push to my repository.
The files have a .sh file, a buildspec.yaml file, and a folder which contains 1 to n number of folders, each of which will have their own .sh file that will then deploy cloudformation resources inside the folder.
deploy.sh
buildspec.yaml
Folder
|
|-- Directory1
| -- deploy.sh
| -- template.yaml
|
|-- Directory2
| -- deploy.sh
| -- template.yaml
|
|-- Directory3
| -- deploy.sh
| -- template.yaml
Currently, the first .sh file is just a for loop that will cd into each directory and run the .sh script sequentially.
I am trying to make this process to be parallel rather than sequential. Since there can be an unknown number of child folders it can potentially be a lengthy process and I don't want it waiting on previous resources.
Does anyone have and advice/experience in this area? I have done some searching but haven't found anything conclusive in my testing.
EDIT: Main build.sh file that runs the for loop
#!/bin/bash
set -e
PROFILE='new-profile'
aws configure --profile $PROFILE set credential_source EcsContainer
REGION=$AWS_REGION
for directory in *; do
if [ -d ${directory} ]; then
# Will not run if no directories are available
chmod +x $directory/deploy.sh
$directory/deploy.sh -p new-profile &
# cd $directory
# echo $directory
# echo "---------------------------------------------------------------------------------"
# echo "Start deploying $directory resources..."
# echo "---------------------------------------------------------------------------------"
# chmod +x ./deploy.sh
# ./deploy.sh -p new-profile &
# cd ../
# echo "---------------------------------------------------------------------------------"
# echo "End deploying $directory resources..."
# echo "---------------------------------------------------------------------------------"
fi
done
wait
echo "finished deployment"