How to include S3 byte name and region / endpoint in one url?

If I have a bucket named mybucket in region=us-east-1 , I can access it using

 aws s3 ls s3://mybucket --region=us-east-1 

However, this requires the transfer of two pieces of information:

  • URL s3://mybucket
  • us-east-1 (or endpoint, whichever is the most)

Ideally, a URL is a single resource locator. It's great that it has a protocol ( s3 ) and a bucket name, but is there one AWS S3-only URL that encodes both the scope and the column name, what can I do:

 aws s3 ls s3://mybucket_url_including_region_or_endpoint 

EDIT:

To clarify, I'm not looking for a list of endpoints. I'm looking for how the s3 URL can really be a single resource locator, by encapsulating all the necessary information inside it to get the resource (of course, without credentials).

+6
source share
3 answers

In the s3:// scheme, there is no provision for encoding the area.

Also note that the β€œU” in the URL means uniform, not universal.

+4
source

As @ michael-sqlbot comments, URLs and URIs are not the same thing.

The S3 URL you are linking to is actually S3Uri, as indicated here.

AWS CLI Documentation - S3

S3Uri: represents the location of an S3 object, prefix, or bucket. This should be written in the form s3: // mybucket / mykey, where mybucket is the specified S3 bucket, mykey is the specified S3 key.

Uniform Resource Identifier (URI)

In information technology, a Unified Resource Identifier (URI) is a string of characters used to identify a resource. Such identification allows you to interact with resource representations over the network, as a rule, in the World Wide Web, using certain protocols. Schemas defining specific syntax and related protocols define each URI.

Uniform Resource Locator (URL)

A single resource locator (URL), commonly informally referred to as a web address (a term that is not defined identically), is a link to a web resource that indicates its location on a computer network and its retrieval mechanism. A URL is a certain type of uniform resource identifier (URI) , although many people use these terms interchangeably.

So what does this mean? URL! = URI?

According to the definition of what a URI is, it is determined by the scheme designed for it. And, the scheme defined for him in this case does not include a link for the region.

Thus, the format for the URI will be correct, even if others are considered incomplete.

The URL is designed to help you find an object somewhere where, as a URI, is intended to refer to an object and does not have to be found.

+2
source

The correct way to include an S3 area for a bucket is to include it correctly in the URL.

Note. "s3.amazonaws.com" is often misused when referring to buckets in regions outside of us - east-1. It can be and is often used for this. But doing this, knowing which region you are actually working in, is less obvious, and this can be problematic in some scenarios.

If you want to specifically reference a bucket called "mybucket" in us-east-2, then the best way to do this is to do one of the following:

 Host-Style Naming: http://mybucket.s3-us-west-2.amazonaws.com Path-Style Naming: http://s3-us-west-2.amazonaws.com/mybucket 

In any of these examples, you will always be connected to us-west-2 with a link to "mybucket".

+1
source

Source: https://habr.com/ru/post/1013117/


All Articles