-
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.
refactor pipeline for share source code sequentially for each stage (#48
) * refactor pipeline for share source code sequentially for each stage * update the bucket role policy and clean source bucket step * add constant for bastion bucket * modify cloud front distribution origin path * remove the dryrun * refactor pipeline for share source code sequentially for each stage * update the bucket role policy and clean source bucket step * add constant for bastion bucket * modify cloud front distribution origin path * remove the dryrun * update deploy logic * remove synth * add role for deploy pipeline * add change for commit * add more specific permission
- Loading branch information
Showing
19 changed files
with
3,010 additions
and
4,945 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
|
||
import os | ||
import boto3 | ||
import json | ||
|
||
def handler(event, context): | ||
ssm = boto3.client('ssm') | ||
s3 = boto3.client('s3') | ||
cloudfront = boto3.client('cloudfront') | ||
|
||
bucket_name = os.environ['BUCKET_NAME'] | ||
cloudfront_distribution_id = os.environ['CLOUDFRONT_DISTRIBUTION_ID'] | ||
# List of SSM parameters to fetch | ||
|
||
|
||
env_params = [ | ||
'VITE_METADATA_URL', | ||
'VITE_WORKFLOW_URL', | ||
'VITE_SEQUENCE_RUN_URL', | ||
'VITE_FILE_URL', | ||
|
||
'VITE_REGION', | ||
'VITE_COG_APP_CLIENT_ID', | ||
'VITE_OAUTH_REDIRECT_IN', | ||
'VITE_OAUTH_REDIRECT_OUT', | ||
'VITE_COG_USER_POOL_ID', | ||
'VITE_COG_IDENTITY_POOL_ID', | ||
'VITE_OAUTH_DOMAIN', | ||
'VITE_UNSPLASH_CLIENT_ID', | ||
] | ||
|
||
env_variables = {} | ||
for param in env_params: | ||
env_variables[param] = os.environ[param] | ||
|
||
env_js_content = f"window.config = {json.dumps(env_variables, indent=2)}" | ||
|
||
|
||
try: | ||
s3.put_object(Bucket=bucket_name, Key='env.js', Body=env_js_content, ContentType='text/javascript') | ||
|
||
# invalidate cloudfront distribution for all files (clear cache) | ||
cloudfront.create_invalidation( | ||
DistributionId=cloudfront_distribution_id, | ||
InvalidationBatch={ | ||
'Paths': { | ||
'Quantity': 1, | ||
'Items': ['/*'] | ||
}, | ||
} | ||
) | ||
|
||
return { | ||
'statusCode': 200, | ||
'body': f" env.js uploaded to {bucket_name}, and CloudFront cache invalidated for {cloudfront_distribution_id}" | ||
} | ||
except Exception as e: | ||
# Log the error and return a failure response | ||
print("Error:") | ||
print(e) | ||
return { | ||
'statusCode': 500, | ||
'body': f"Failed to upload env.js to {bucket_name}. {e}" | ||
} |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.