[ 
https://issues.apache.org/jira/browse/AIRFLOW-2151?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16378658#comment-16378658
 ] 

Pieter Mulder commented on AIRFLOW-2151:
----------------------------------------

Yes of course: Currently I have something like this (on Airflow 1.9):

 
{code:java}
aws_hook = AwsHook(aws_conn_id=aws_conn_id)
# Get the credentials from the AWS hook.
(aws_access_key_id, aws_secret_access_key, _, _) = 
aws_hook._get_credentials(None)
aws_session = boto3.Session(
    aws_access_key_id=aws_access_key_id,
    aws_secret_access_key=aws_secret_access_key)
credentials = aws_session.get_credentials().get_frozen_credentials()
COPY_SQL = "COPY schema.table FROM 's3://somewhere/afile.csv' CREDENTIALS 
'aws_access_key_id={c.access_key};aws_secret_access_key={c.secret_key}'".format(c=credentials)
PostgresHook(postgres_conn_id).run(COPY_SQL)
{code}
Master would already simplify this as `AwsHook._get_credentials()` already 
returns a `session`, but this still leaves me with using a private function.

My point above could be solved by adding a public `AwsHook.get_credentials()`, 
but I wondered why not allow using the underlying session.

 

> Allow getting AWS Session from AwsHook
> --------------------------------------
>
>                 Key: AIRFLOW-2151
>                 URL: https://issues.apache.org/jira/browse/AIRFLOW-2151
>             Project: Apache Airflow
>          Issue Type: New Feature
>          Components: aws, contrib
>            Reporter: Pieter Mulder
>            Assignee: Pieter Mulder
>            Priority: Major
>
> I would like to be able to get the `session` object that `AwsHook` creates.
> In my case I want to use it's credentials (I now use `_get_credentials()` in 
> my code, but don't like using the private function) to do a `COPY` with 
> Redshift.
> I think the AWS Session could also be useful for people that want to use a 
> client or resource with other arguments then the default.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to