Skip to content

BCDA-9484: Migrate aws sdk to v2#1235

Merged
carlpartridge merged 18 commits intomainfrom
carl-9484-migrate-aws-to-v2
Nov 3, 2025
Merged

BCDA-9484: Migrate aws sdk to v2#1235
carlpartridge merged 18 commits intomainfrom
carl-9484-migrate-aws-to-v2

Conversation

@carlpartridge
Copy link
Collaborator

@carlpartridge carlpartridge commented Oct 28, 2025

🎫 Ticket

https://jira.cms.gov/browse/BCDA-9484

🛠 Changes

Migrate all AWS packages to v2. Various refactoring and cleanup.

ℹ️ Context

AWS v1 are out of service as of end of July 2025.

🧪 Validation

Local linting and testing.

@@ -0,0 +1,49 @@
package bcdaaws
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Moved this from its own package to under our aws helpers package.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

AWS session is no longer a thing in v2. Instead each service creates a client for itself using AWS config.

assert.Contains(buf.String(), "Files failed: 1")
assert.Contains(buf.String(), "Files skipped: 0")
}
// func (s *CLITestSuite) TestImportCCLFDirectory() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Tests related to the commented out cli actions.

type CclfFileProcessor interface {
// Load a list of valid CCLF files to be imported
LoadCclfFiles(path string) (cclfList map[string][]*cclfZipMetadata, skipped int, failed int, err error)
LoadCclfFiles(ctx context.Context, path string) (cclfList map[string][]*cclfZipMetadata, skipped int, failed int, err error)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

A good amount of changes are just adding ctx to functions. Ctx is now needed for basically kind of AWS interaction.

return nil, err
}
}
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This whole section seemed to say if DATABASE_URL is not set, then go grab it from param store. This is just as easily made sure to be set elsewhere in our pipelines so I think its ok to clean this up a bit.

Copy link
Collaborator Author

@carlpartridge carlpartridge Oct 28, 2025

Choose a reason for hiding this comment

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

I am 90% sure insights data is now handled via the js lambda in bcda-ops: https://github.com/CMSgov/bcda-ops/tree/main/terraform/modules/insights_data_sampler_lambda

Copy link
Contributor

Choose a reason for hiding this comment

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

last update was 4 years ago, so LGTM to remove!

} else {
lambda.Start(attributionImportHandler)
}
lambda.Start(attributionImportHandler)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Dont need these localstack checks anymore. It now just works (assuming you set your test AWS clients up properly).

Copy link
Contributor

Choose a reason for hiding this comment

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

I see the previous comment:

// should only be set in local development to avoid making external calls to a real AWS account. - is there a risk of calling our AWS account inadvertently?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As long as AWS_ENDPOINT_URL is set when anything is run, then anything that runs any kind of aws service will get redirected to that url (generally http://localstack:4566). Localstack does a lot of magic to mimic AWS services APIs.

logger.Infof("Reading %s event for file %s", e.EventName, filepath)
if cclf.CheckIfAttributionCSVFile(e.S3.Object.Key) {
return handleCSVImport(db, s3AssumeRoleArn, filepath)
return handleCSVImport(ctx, pool, s3Client, ssmClient, filepath)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed some of the logic above in order to dep inject them into functions. This allows us more flexibility in testing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Moved to bcda/aws package

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This whole file is mostly helpers for AWS but also specifically for only running tests. It seems kind of useful but also feels a bit wrong... Wondering if anyone else has feelings about it. Also if it should maybe get moved under bcda/aws?

}
}

// TODO: once we remove que library and upgrade to pgx5 we can move the below functions into manager
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Followed this TODO and moved it under manager.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I wend ahead and removed this (and related files). This was originally part of https://jira.cms.gov/browse/BCDA-9491. It was quick and easy and I was in here already so just went ahead and did it.

@carlpartridge carlpartridge marked this pull request as ready for review October 28, 2025 17:28
@carlpartridge carlpartridge requested a review from a team as a code owner October 28, 2025 17:28
Copy link
Contributor

@laurenkrugen-navapbc laurenkrugen-navapbc left a comment

Choose a reason for hiding this comment

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

Only other comment is a few other places could initialize ctx in the func call, but other than that, LGTM! Thanks for getting this updated and cleaned up! 🎉

Copy link
Contributor

@michaeljvaldes michaeljvaldes left a comment

Choose a reason for hiding this comment

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

Great job! That's a lot of additional work removing/refactoring outdated packages. I also think this design around interacting with AWS/localstack aligns much more with the intent of localstack.

@carlpartridge carlpartridge merged commit 9acc861 into main Nov 3, 2025
15 of 16 checks passed
@carlpartridge carlpartridge deleted the carl-9484-migrate-aws-to-v2 branch November 3, 2025 22:06
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