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

feat(scripts): migrate AWS-SDK from v2 to v3 #15267

Merged
merged 6 commits into from
Jun 5, 2024
Merged

Conversation

jerader
Copy link
Collaborator

@jerader jerader commented May 28, 2024

closes RDEVOPS-96

Overview

this PR migrates from using AWS-SDK v2 to v3 and updates all our web deployment scripts (promote-to-staging, promote-to-production, rollback) and the utils used

NOTE: v3 does support typescript and i tried to update the scripts to using typescript but ran into a bunch of TS compiler issues 🫠. Seemed much easier to just stick with JS. Additionally, v2 is supposed to be deprecated as early as September 8th this year so figured it was better to update to v3 and still use JS than update to v3 and use TS (for now).

Test Plan

Only someone with the proper aws creds can test this. But should be tested for docs, PD, and LL with promote to staging, promote to production, and rollback dry runs.

for promote to staging: node ./scripts/deploy/promote-to-staging project tag (PD tag is [email protected])

for promote to prod: node ./scripts/deploy/promote-to-production project

rollback: node ./scripts/deploy/rollback project environment

Changelog

  • install appropriate dependencies (aws-sdk v3 uses modules now)
  • update all the deploy utils
  • update staging, prod, and rollback scripts

Review requests

see test plan

Risk assessment

medium - we have no more releases that will use these anytime soon. The dry runs all seem to work!

@jerader jerader added the DO NOT MERGE Indicates a PR should not be merged, even if there's a shiny green merge button available label May 28, 2024
@jerader jerader marked this pull request as ready for review May 28, 2024 15:38
@jerader jerader requested review from a team as code owners May 28, 2024 15:38
@jerader jerader requested review from mjhuff, ecormany, sfoster1, b-cooper, shlokamin and y3rsh and removed request for a team May 28, 2024 15:38
Copy link
Member

@sfoster1 sfoster1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple small things to change but thanks for doign this!

const stagingBucket = `staging.${projectDomain}`
const productionBucket = projectDomain
console.log(`Promoting ${projectDomain} from staging to production\n`)
await getDeployMetadata(s3Client, stagingBucket)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems like getDeployMetadata used to be here to get something called current that was then logged, and not really any other purpose. This PR moves the log above getDeployMetadata and removes the use of its return, so maybe we should just get rid of getDeployMetadata


console.log('Promotion to production done\n')

getCreateInvalidation(productionCredentials, cloudfrontArn)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs to be await-ed i think

getCreateInvalidation(productionCredentials, cloudfrontArn)

console.log('Cache invalidation initiated for production\n')
process.exit(0).catch(err => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need this catch, if it's the equivalent of the catch on the old line 100 then that functionality is covered by the function-wide try/catch

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops yes this is not needed there. thanks!

Copy link
Member

@y3rsh y3rsh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let us try and fix the invalidations.


const parseArgs = require('./lib/parseArgs')
const syncBuckets = require('./lib/syncBuckets')
const { getDeployMetadata } = require('./lib/deploy-metadata')
const { getAssumeRole } = require('./assume-role')
const { getCreateInvalidation } = require('./create-invalidation')
const { checkCurrentAWSProfile } = require('./check-current-profile')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cannot comment on the not edited collapsed lines but all the arns for all CloudFront distributions in this file and in the promote-staging.js are incorrect. This is why we have had to do them manually?

Copy link
Collaborator Author

@jerader jerader Jun 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooh, thanks Josh. i thought we haven't had to do them manually since i added the cloud invalidations to these scripts. But did the cloudfront arns change when we added the new administrator role arn last year?

Copy link
Member

@y3rsh y3rsh Jun 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry PD CloudFront ARNs are correct. I think LL, static, docs may be off but are not relevant to this PR.
No they are still in old account we think.


const parseArgs = require('./lib/parseArgs')
const syncBuckets = require('./lib/syncBuckets')
const { getDeployMetadata } = require('./lib/deploy-metadata')
const { getAssumeRole } = require('./assume-role')
const { getCreateInvalidation } = require('./create-invalidation')
const { checkCurrentAWSProfile } = require('./check-current-profile')
Copy link
Member

@y3rsh y3rsh Jun 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry PD CloudFront ARNs are correct. I think LL, static, docs may be off but are not relevant to this PR.
No they are still in old account we think.

@jerader jerader requested a review from sfoster1 June 4, 2024 20:13
@jerader jerader removed the DO NOT MERGE Indicates a PR should not be merged, even if there's a shiny green merge button available label Jun 5, 2024
Copy link
Member

@sfoster1 sfoster1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I think. There is that one weird Promise.resolve() that I don't think needs to be there but good otherwise

@@ -17,7 +23,13 @@ function getCreateInvalidation(productionCredentials, cloudfrontArn) {
},
},
}
return cloudfront.createInvalidation(cloudFrontParams).promise()

if (dryrun) return Promise.resolve()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can just return here since it's async function not function(...): Promise

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooooh ya good point thank you!

@jerader jerader merged commit 36e61d5 into edge Jun 5, 2024
36 checks passed
@jerader jerader deleted the scripts_update-aws-sdk-v3 branch June 5, 2024 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants