Skip to content

Commit 219f061

Browse files
committed
docs(auth): IAM credential authentication
1 parent e2ca743 commit 219f061

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

README.rst

+63
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,58 @@ Basic Example
7474
print(result)
7575
>> (['One Hundred Years of Solitude', 'Gabriel García Márquez'], ['A Brief History of Time', 'Stephen Hawking'])
7676
77+
Example using IAM Credentials
78+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
79+
IAM Credentials can be supplied directly to ``connect(...)`` using an AWS profile as shown below:
80+
81+
.. code-block:: python
82+
83+
import redshift_connector
84+
85+
# Connects to Redshift cluster using IAM credentials from default profile defined in ~/.aws/credentials
86+
conn = redshift_connector.connect(
87+
iam=True,
88+
database='dev',
89+
db_user='awsuser',
90+
password='',
91+
user='',
92+
cluster_identifier='examplecluster',
93+
profile='default'
94+
)
95+
96+
.. code-block:: bash
97+
98+
# ~/.aws/credentials
99+
[default]
100+
aws_access_key_id="my_aws_access_key_id"
101+
aws_secret_access_key="my_aws_secret_access_key"
102+
aws_session_token="my_aws_session_token"
103+
104+
# ~/.aws/config
105+
[default]
106+
region=us-west-2
107+
108+
If a region is not provided in `~/.aws/config` or you would like to override its value, `region` may be passed to ``connect(...)``.
109+
110+
Alternatively, IAM credentials can be supplied directly to ``connect(...)`` using AWS credentials as shown below:
111+
112+
.. code-block:: python
113+
114+
import redshift_connector
115+
116+
# Connects to Redshift cluster using IAM credentials from default profile defined in ~/.aws/credentials
117+
conn = redshift_connector.connect(
118+
iam=True,
119+
database='dev',
120+
db_user='awsuser',
121+
password='',
122+
user='',
123+
cluster_identifier='examplecluster',
124+
access_key_id="my_aws_access_key_id",
125+
secret_access_key="my_aws_secret_access_key",
126+
session_token="my_aws_session_token",
127+
region="us-east-2"
128+
)
77129
78130
Integration with pandas
79131
~~~~~~~~~~~~~~~~~~~~~~~
@@ -178,6 +230,17 @@ Connection Parameters
178230
+-------------------------+--------------------------------------------------------------------------------------------+---------------+----------+
179231
| app_name | String. The name of the IdP application used for authentication | None | No |
180232
+-------------------------+--------------------------------------------------------------------------------------------+---------------+----------+
233+
| access_key_id | String. The The access key for the IAM role or IAM user configured for IAM database | None | No |
234+
| | authentication | | |
235+
+-------------------------+--------------------------------------------------------------------------------------------+---------------+----------+
236+
| secret_access_key_id | String. The The secret access key for the IAM role or IAM user configured for IAM database | None | No |
237+
| | authentication | | |
238+
+-------------------------+--------------------------------------------------------------------------------------------+---------------+----------+
239+
| session_token | String. The The access key for the IAM role or IAM user configured for IAM database. | None | No |
240+
| | authentication. Not required unless temporary AWS credentials are being used. | | |
241+
+-------------------------+--------------------------------------------------------------------------------------------+---------------+----------+
242+
| profile | String. The name of a profile in a AWS credentials file that contains AWS credentials. | None | No |
243+
+-------------------------+--------------------------------------------------------------------------------------------+---------------+----------+
181244

182245
Logging
183246
~~~~~~~~~~~~

0 commit comments

Comments
 (0)