Skip to content

Commit

Permalink
fix: Don't call EC2 Metadata and allow anonymouse if no cred (#1800)
Browse files Browse the repository at this point in the history
* fix: Don't call EC2 Metadata and allow anonymouse if no cred

Signed-off-by: Xuanwo <github@xuanwo.io>

* Add comments

Signed-off-by: Xuanwo <github@xuanwo.io>

* Fix typo

Signed-off-by: Xuanwo <github@xuanwo.io>

---------

Signed-off-by: Xuanwo <github@xuanwo.io>
  • Loading branch information
Xuanwo committed Jun 12, 2023
1 parent af6e381 commit ef7daa4
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/cache/s3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ impl S3Cache {

if no_credentials {
builder.disable_config_load();
// Disable EC2 metadata to avoid OpenDAL trying to load
// credentials from EC2 metadata.
//
// A.k.a, don't try to visit `http://169.254.169.254`
builder.disable_ec2_metadata();
// Allow anonymous access to S3 so that OpenDAL will not
// throw error when no credentials are provided.
builder.allow_anonymous();
}

if let Some(endpoint) = endpoint {
Expand Down

0 comments on commit ef7daa4

Please sign in to comment.