generated from dxw/terraform-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #132 from dxw/create-empty-service-env-file
Create empty service env file
- Loading branch information
Showing
4 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/bash | ||
|
||
# exit on failures | ||
set -e | ||
set -o pipefail | ||
|
||
usage() { | ||
echo "Usage: $(basename "$0") [OPTIONS]" 1>&2 | ||
echo " -h - help" | ||
echo " -b - Bucket" | ||
echo " -k - Key" | ||
exit 1 | ||
} | ||
|
||
while getopts "b:k:h" opt; do | ||
case $opt in | ||
b) | ||
BUCKET=$OPTARG | ||
;; | ||
k) | ||
KEY=$OPTARG | ||
;; | ||
h) | ||
usage | ||
;; | ||
*) | ||
usage | ||
;; | ||
esac | ||
done | ||
|
||
if [[ | ||
-z "$BUCKET" || | ||
-z "$KEY" | ||
]] | ||
then | ||
usage | ||
fi | ||
|
||
if ! aws s3api head-object --bucket "$BUCKET" --key "$KEY" 2>/dev/null | ||
then | ||
# If the file does not exist, create an empty file | ||
touch /tmp/empty_file.txt | ||
aws s3api put-object --bucket "$BUCKET" --key "$KEY" --body /tmp/empty_file.txt | ||
rm /tmp/empty_file.txt | ||
echo "==> Empty file created in S3 bucket" | ||
else | ||
echo "==> File already exists in S3 bucket, skipping creation" | ||
fi |