Skip to content

Commit

Permalink
Make upload scripts for s3-changelog and nat-gateway lambda consistent
Browse files Browse the repository at this point in the history
Recently I fixed the CNF template in NAT gateway lambda stack to use the region of the CFN deployment when referencing the lambda artifact.
  • Loading branch information
Veetaha committed Jul 19, 2024
1 parent 99ac216 commit 239918a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Resources:
EnableQrts: !Ref EnableQrts
QrtsBatchSize: !Ref QrtsBatchSize
QrtsMaxDelay: !Ref QrtsMaxDelay
TemplateURL: https://{{S3_BUCKET}}.s3.{{AWS_REGION}}.amazonaws.com/{{S3_PREFIX}}/{{VERSION}}/cloudformation-single-bucket.yaml
TemplateURL: !Sub https://{{S3_BUCKET_PREFIX}}-${AWS::Region}.s3.${AWS::Region}.amazonaws.com/{{S3_KEY_PREFIX}}/{{VERSION}}/cloudformation-single-bucket.yaml
Outputs:
templateVersion:
Value: "{{VERSION}}"
2 changes: 1 addition & 1 deletion elastio-s3-changelog/cloudformation-multiple-buckets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Resources:
EnableQrts: !Ref EnableQrts
QrtsBatchSize: !Ref QrtsBatchSize
QrtsMaxDelay: !Ref QrtsMaxDelay
TemplateURL: https://{{S3_BUCKET}}.s3.{{AWS_REGION}}.amazonaws.com/{{S3_PREFIX}}/{{VERSION}}/cloudformation-multiple-buckets-with-macros.yaml
TemplateURL: !Sub https://{{S3_BUCKET_PREFIX}}-${AWS::Region}.s3.${AWS::Region}.amazonaws.com/{{S3_KEY_PREFIX}}/{{VERSION}}/cloudformation-multiple-buckets-with-macros.yaml

Outputs:
templateVersion:
Expand Down
15 changes: 7 additions & 8 deletions elastio-s3-changelog/upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
# Upload the templates into your S3 bucket for testing
# Use this script like this:
# ```bash
# S3_BUCKET=bucket LINK_PARAMS='&param_BucketNames=foo,bar' ./elastio-s3-changelog/upload.sh
# S3_BUCKET_PREFIX=bucket LINK_PARAMS='&param_BucketNames=foo,bar' ./elastio-s3-changelog/upload.sh
# ```

set -euxo pipefail

s3_prefix=contrib/elastio-s3-changelog
s3_key_prefix=contrib/elastio-s3-changelog

trap cleanup SIGINT SIGTERM ERR EXIT

Expand Down Expand Up @@ -38,12 +38,11 @@ cd "$temp_dir"
# Using `|` separator instead of `/` for prefix, because prefix
# by itself contains a `/`
sed -i ./*.yaml \
-e "s/{{AWS_REGION}}/$AWS_REGION/g" \
-e "s/{{S3_BUCKET}}/$S3_BUCKET/g" \
-e "s|{{S3_PREFIX}}|$s3_prefix|g" \
-e "s/{{S3_BUCKET_PREFIX}}/$S3_BUCKET_PREFIX/g" \
-e "s|{{S3_KEY_PREFIX}}|$s3_key_prefix|g" \
-e "s/{{VERSION}}/$version/g"

aws s3 cp --recursive ./ "s3://${S3_BUCKET}/${s3_prefix}/${version}/"
aws s3 cp --recursive ./ "s3://$S3_BUCKET_PREFIX-$AWS_REGION/${s3_key_prefix}/${version}/"

# Skip opening the link if we're on CI
if [[ -v CI ]]; then
Expand All @@ -53,8 +52,8 @@ fi
cfn_deep_link_parts=(
"https://$AWS_REGION.console.aws.amazon.com/cloudformation/home"
"?region=$AWS_REGION#/stacks/create/review?templateURL="
"https://$S3_BUCKET.s3.$AWS_REGION.amazonaws.com/"
"$s3_prefix/$version/cloudformation-multiple-buckets.yaml"
"https://$S3_BUCKET_PREFIX-$AWS_REGION.s3.$AWS_REGION.amazonaws.com/"
"$s3_key_prefix/$version/cloudformation-multiple-buckets.yaml"
"&stackName=elastio-s3-changelog"
"${LINK_PARAMS:-}"
)
Expand Down

0 comments on commit 239918a

Please sign in to comment.