Skip to content

Commit 9d5a7dd

Browse files
committed
Document configuration for S3 ResourcePath
1 parent c62a4ab commit 9d5a7dd

File tree

2 files changed

+94
-0
lines changed

2 files changed

+94
-0
lines changed

doc/lsst.resources/index.rst

+6
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ Design and Development
2424

2525
It is available from PyPI as ``lsst-resources``: https://pypi.org/project/lsst-resources/
2626

27+
Configuration
28+
=============
29+
30+
.. toctree::
31+
s3.rst
32+
2733
.. _lsst.resources-pyapi:
2834

2935
Python API reference

doc/lsst.resources/s3.rst

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
S3 ResourcePath
2+
=================
3+
4+
The basic syntax for using an S3 `~lsst.resources.ResourcePath` is:
5+
6+
.. code-block::
7+
8+
ResourcePath("s3://bucketname/key")
9+
10+
Configuration
11+
-------------
12+
To access files hosted in S3 using `~lsst.resources.ResourcePath`, the environment must be
13+
configured to choose an S3 service and provide credentials for authentication.
14+
15+
Choosing an S3 service
16+
^^^^^^^^^^^^^^^^^^^^^^
17+
By default, the library will attempt to use AWS S3. To connect to another S3
18+
service, set the environment variable ``S3_ENDPOINT_URL`` to the HTTP URL where
19+
the service is hosted. For example, for Google Cloud Storage:
20+
21+
.. code-block::
22+
23+
S3_ENDPOINT_URL=https://storage.googleapis.com
24+
25+
Authentication credentials
26+
^^^^^^^^^^^^^^^^^^^^^^^^^^
27+
28+
Authentication for S3 services can be configured in `a variety of ways
29+
<https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html>`_.
30+
The simplest and most common is to provide an access key ID and secret. This
31+
can be accomplished using `environment variables
32+
<https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html#shared-credentials-file>`_:
33+
34+
.. code-block::
35+
36+
AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE
37+
AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
38+
39+
or a `credentials file <https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html#shared-credentials-file>`_.
40+
By default, the credentials file is located at ``~/.aws/credentials``. This
41+
path can be changed by setting the environment variable
42+
``AWS_SHARED_CREDENTIALS_FILE``. A basic credentials file looks like this:
43+
44+
.. code-block::
45+
46+
[default]
47+
aws_access_key_id=AKIAIOSFODNN7EXAMPLE
48+
aws_secret_access_key=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
49+
50+
Using multiple S3 services or sets of credentials
51+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
52+
53+
If you need to connect to more than one S3 service, you can configure
54+
additional S3 "profiles". The profile name is added to the S3 URI as a
55+
``profile_name@`` prefix to the bucket name. For example, a
56+
`~lsst.resources.ResourcePath` URI for an S3 profile called ``myprofile`` looks
57+
like:
58+
59+
.. code-block::
60+
61+
ResourcePath("s3://myprofile@bucket/key")
62+
63+
Each profile must set an environment variable to identify the S3 service it
64+
should connect to. The variable name is in the form
65+
``LSST_RESOURCES_S3_PROFILE_<profile_name>``, for example:
66+
67+
.. code-block::
68+
69+
LSST_RESOURCES_S3_PROFILE_myprofile=https://private-s3-service.example
70+
71+
The credentials for each profile should be configured by adding additional
72+
profile blocks to the `credentials file
73+
<https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html#shared-credentials-file>`_.
74+
For example:
75+
76+
.. code-block::
77+
78+
# Will be used for S3 URIs without an explicit profile name, e.g.
79+
# s3://bucket/key
80+
[default]
81+
aws_access_key_id=AKIAIOSFODNN7EXAMPLE
82+
aws_secret_access_key=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
83+
84+
# Will be used for S3 URIs with a profile name of "myprofile", e.g.
85+
# s3://myprofile@bucket/key
86+
[myprofile]
87+
aws_access_key_id=AKIAIOSFSDAD7EXAMPLE2
88+
aws_secret_access_key=wJakjASDWREMI/FAMDENG/bPxRfiCYEXAMPLEKEY2

0 commit comments

Comments
 (0)