This repository has been archived by the owner on Dec 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2060 from grapl-security/twunderlich/fix-plugin-s…
…3-url Fix s3 uri format so that its explicitly a s3 URI
- Loading branch information
Showing
4 changed files
with
22 additions
and
16 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
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,19 @@ | ||
use grapl_config::env_helpers::ENV_ENDPOINT; | ||
|
||
/// This gets a s3 URI to be used by Nomad's artifact stanza (in particular the grapl-plugin). | ||
/// The underlying library, Hashicorp's [go-getter](https://github.com/hashicorp/go-getter) lib, | ||
/// doesn't work with the `http://` schema prefix, but does work with an explicit s3 prefix `s3://` | ||
/// or without a prefix. We've opted for the s3 prefix to be explicit. | ||
pub fn get_s3_uri(bucket: &str, key: &str) -> String { | ||
let local_endpoint = std::env::var(ENV_ENDPOINT).ok(); | ||
// If the above is specified, we're running locally against Localhost | ||
// Otherwise, it's against prod S3; so we use the s3 URIs. Notably, the underlying go-getter | ||
// lib does not seem to work with s3 object URLs (urls that start with http:// or https://), | ||
// including the recommended virtual host style access. | ||
// https://github.com/hashicorp/go-getter/issues/387 tracks updating the documentation. | ||
// This is the s3 URI format used in the s3 console. | ||
local_endpoint.map_or_else( | ||
|| format!("s3://{bucket}.s3.amazonaws.com/{key}"), | ||
|endpoint| format!("{endpoint}/{bucket}/{key}"), | ||
) | ||
} |
This file was deleted.
Oops, something went wrong.