Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix artifacts references to properly support regions other than us-east-2 #93

Merged
merged 1 commit into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ jobs:
needs.changes.outputs.ci == 'true'
)
env:
S3_BUCKET: elastio-prod-artifacts-us-east-2
S3_BUCKET_PREFIX: elastio-prod-artifacts
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down
6 changes: 3 additions & 3 deletions elastio-nat-provision-lambda/cloudformation-lambda.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,11 @@ Resources:
Environment:
Variables:
NAT_CFN_PREFIX: !Ref NatGatewayStackPrefix
NAT_CFN_TEMPLATE_URL: https://{{S3_BUCKET}}.s3.{{AWS_REGION}}.amazonaws.com/{{S3_PREFIX}}/{{VERSION}}/cloudformation-nat.yaml
NAT_CFN_TEMPLATE_URL: !Sub https://{{S3_BUCKET_PREFIX}}-${AWS::Region}.s3.${AWS::Region}.amazonaws.com/{{S3_KEY_PREFIX}}/{{VERSION}}/cloudformation-nat.yaml
STATE_MACHINE_ARN: !Sub 'arn:aws:states:${AWS::Region}:${AWS::AccountId}:stateMachine:elastio-nat-gateway-provision-state-machine'
Code:
S3Bucket: {{S3_BUCKET}}
S3Key: {{S3_PREFIX}}/{{VERSION}}/lambda.zip
S3Bucket: !Sub '{{S3_BUCKET_PREFIX}}-${AWS::Region}'
S3Key: {{S3_KEY_PREFIX}}/{{VERSION}}/lambda.zip

pendingInstancesSubscription:
Type: AWS::Events::Rule
Expand Down
15 changes: 7 additions & 8 deletions elastio-nat-provision-lambda/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_DeleteQuiescentPeriodSeconds=5' ./elastio-nat-provision-lambda/upload.sh
# S3_BUCKET_PREFIX=bucket LINK_PARAMS='&param_DeleteQuiescentPeriodSeconds=5' ./elastio-nat-provision-lambda/upload.sh
# ```

set -euxo pipefail

s3_prefix=contrib/elastio-nat-provision-lambda
s3_key_prefix=contrib/elastio-nat-provision-lambda

trap cleanup SIGINT SIGTERM ERR EXIT

Expand Down Expand Up @@ -40,12 +40,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 @@ -55,8 +54,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-lambda.yaml"
"https://$S3_BUCKET_PREFIX-$AWS_REGION.s3.$AWS_REGION.amazonaws.com/"
"$s3_key_prefix/$version/cloudformation-lambda.yaml"
"&stackName=elastio-nat-provision-lambda"
"${LINK_PARAMS:-}"
)
Expand Down