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

Switch AWS clients over to a generic cloud client library so it can run on other locations. #8

Merged
merged 3 commits into from
Nov 30, 2020

Conversation

dlorenc
Copy link
Contributor

@dlorenc dlorenc commented Nov 25, 2020

No description provided.

@dlorenc
Copy link
Contributor Author

dlorenc commented Nov 25, 2020

I haven't actually tried this out yet, and probably won't be able to on AWS since I don't have an AWS account. I'll get it running on GCP today though.

@dlorenc
Copy link
Contributor Author

dlorenc commented Nov 25, 2020

OK, this is working now for GCP. The instructions to setup need to change a bit, the main difference is the environment variables used to access the queue/storage. They basically follow the patterns from here: https://github.com/google/go-cloud

For GCP, you can use something like:

OSSMALWARE_UPLOAD_BUCKET_URL=gs://<gcs bucket name>
OSSMALWARE_QUEUE_URL=gcppubsub://projects/<gcp project id>/subscriptions/<gcp pubsub subscription>

For AWS, it would look like:

OSSMALWARE_UPLOAD_BUCKET_URL=s3://<s3 bucket name>
OSSMALWARE_QUEUE_URL=awssqs://sqs.us-east-2.amazonaws.com/123456789012/myqueue

Copy link
Owner

@jordan-wright jordan-wright left a comment

Choose a reason for hiding this comment

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

Hey @dlorenc! This is looking great.

I'll give this a shot on AWS, but to be honest I think it's fine moving forward with GCP specifically, since we'll eventually have a series of cloud functions that fetch packages from different package managers, and at that point it'll be trickier to be multi-cloud.

pkg/consumer/consumer.go Outdated Show resolved Hide resolved
pkg/uploader/uploader.go Outdated Show resolved Hide resolved
}
return consumer, nil
return &PubSubConsumer{
url: queueURL,
Copy link
Owner

Choose a reason for hiding this comment

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

Out of curiosity - do we still need the url field? It seems that Next() now just needs the subs attribute.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope, it's only required for the logging line. I can't find a way to get the URL back out of the subs object, so I saved the URL. Let me know if you'd prefer to drop that logging line or switch it to something else.

pkg/consumer/consumer.go Outdated Show resolved Hide resolved
@jordan-wright
Copy link
Owner

Also, one more thing: we'll need to update the log line here since it previously pointed to the bucket URL and now points to the bucket object:

2020/11/26 03:35:10 uploading /home/ec2-user/pypi-0-._.-._.-._.-._.-._.-._.-0-0.1.scap to &{%!s(*s3blob.bucket=&{oss-malware-results 0xc00000e168 false}) %!s(*oc.Tracer=&{gocloud.dev/blob gocloud.dev/blob/s3blob 0xc00000e040}) {{%!s(int32=0) %!s(uint32=0)} %!s(uint32=0) %!s(uint32=0) %!s(int32=0) %!s(int32=0)} %!s(bool=false)}/pypi/pypi-0-._.-._.-._.-._.-._.-._.-0-0.1/pypi-0-._.-._.-._.-._.-._.-._.-0-0.1.scap

Otherwise, this seems to work fine on AWS, too, which is great!

@dlorenc
Copy link
Contributor Author

dlorenc commented Nov 28, 2020

Ready for another look!

@dlorenc dlorenc changed the title WIP: switch AWS clients over to a generic cloud client library so it can run on other locations. Switch AWS clients over to a generic cloud client library so it can run on other locations. Nov 28, 2020
Copy link
Owner

@jordan-wright jordan-wright left a comment

Choose a reason for hiding this comment

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

Hey @dlorenc! This looks great. There was a super minor typo that slipped in, but when that's resolved we'll be in great shape to merge.

Thanks for all the great work!

main.go Outdated Show resolved Hide resolved
@dlorenc
Copy link
Contributor Author

dlorenc commented Nov 29, 2020

All set!

@jordan-wright jordan-wright merged commit 0b6db94 into jordan-wright:main Nov 30, 2020
@jordan-wright jordan-wright added the enhancement New feature or request label Nov 30, 2020
@jordan-wright jordan-wright linked an issue Nov 30, 2020 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move to Google Cloud
2 participants