github.com/NVIDIA/aistore@v1.3.23-0.20240517131212-7df6609be51d/api/env/aws.go (about)

     1  // Package env contains environment variables
     2  /*
     3   * Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved.
     4   */
     5  package env
     6  
     7  import "os"
     8  
     9  func AwsDefaultRegion() (region string) {
    10  	if region = os.Getenv(AWS.Region); region == "" {
    11  		// from https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketLocation.html:
    12  		// "Buckets in region `us-east-1` have a LocationConstraint of null."
    13  		region = "us-east-1"
    14  	}
    15  	return region
    16  }
    17  
    18  // use S3_ENDPOINT to globally override the default 'https://s3.amazonaws.com' endpoint
    19  // NOTE: the same can be done on a per-bucket basis, via bucket prop `Extra.AWS.Endpoint`
    20  // (bucket override will always take precedence)
    21  
    22  // ditto non-default profile via "AWS_PROFILE" (the default one is called [default])
    23  
    24  var (
    25  	AWS = struct {
    26  		Endpoint  string
    27  		Region    string
    28  		Profile   string
    29  		Inventory string
    30  	}{
    31  		Endpoint: "S3_ENDPOINT",
    32  		Region:   "AWS_REGION",
    33  		Profile:  "AWS_PROFILE",
    34  	}
    35  )