-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CloudFormation: Upload to link parametrized only by version (#1427)
- Loading branch information
Showing
3 changed files
with
15 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,18 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
function usage() { | ||
cat <<EOF | ||
Usage: $0 <local-file> <remote-file> | ||
Replace the CFT_VERSION placeholder in the local-file. | ||
Upload the local-file to S3 with the remote-file name. | ||
function upload_file() { | ||
local local_file=${1:?Missing local file name} | ||
local remote_file=${2:?Missing remote file name} | ||
|
||
EOF | ||
} | ||
|
||
LOCAL_FILE=$1 | ||
REMOTE_FILE=$2 | ||
: "${LOCAL_FILE:?$(echo "Missing local file" && usage && exit 1)}" | ||
: "${REMOTE_FILE:?$(echo "Missing remote file" && usage && exit 1)}" | ||
sed --in-place'' "s/CFT_VERSION/$remote_file/g" "$local_file" | ||
|
||
sed --in-place'' s/CFT_VERSION/$REMOTE_FILE/g $LOCAL_FILE | ||
local s3_file="s3://elastic-cspm-cft/$remote_file" | ||
echo "Uploading $local_file to $s3_file" | ||
aws s3 cp "$local_file" "$s3_file" | ||
} | ||
|
||
S3_FILE="s3://elastic-cspm-cft/$REMOTE_FILE" | ||
echo "Uploading $LOCAL_FILE to $S3_FILE" | ||
aws s3 cp $LOCAL_FILE $S3_FILE | ||
version=$(grep defaultBeatVersion version/version.go | cut -f2 -d "\"") | ||
upload_file deploy/cloudformation/elastic-agent-ec2-cnvm.yml "cloudformation-cnvm-$version.yml" | ||
upload_file deploy/cloudformation/elastic-agent-ec2-cspm.yml "cloudformation-cspm-single-account-$version.yml" | ||
upload_file deploy/cloudformation/elastic-agent-ec2-cspm-organization.yml "cloudformation-cspm-organization-account-$version.yml" |