-
Notifications
You must be signed in to change notification settings - Fork 16.5k
Expose AWS IAM missing param in Hashicorp secret #38536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
31990d9
7e242ce
6378557
0e82e20
4d5b0e8
552dc6e
ea0f2a9
536d0fe
67c384b
ad1c59d
cb82eed
d7fb3bf
cf70280
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -74,6 +74,7 @@ class _VaultClient(LoggingMixin): | |
| :param key_id: Key ID for Authentication (for ``aws_iam`` and ''azure`` auth_type). | ||
| :param secret_id: Secret ID for Authentication (for ``approle``, ``aws_iam`` and ``azure`` auth_types). | ||
| :param role_id: Role ID for Authentication (for ``approle``, ``aws_iam`` auth_types). | ||
| :param role_arn: AWS arn role (for ``aws_iam`` auth_type) | ||
| :param kubernetes_role: Role for Authentication (for ``kubernetes`` auth_type). | ||
| :param kubernetes_jwt_path: Path for kubernetes jwt token (for ``kubernetes`` auth_type, default: | ||
| ``/var/run/secrets/kubernetes.io/serviceaccount/token``). | ||
|
|
@@ -103,6 +104,7 @@ def __init__( | |
| password: str | None = None, | ||
| key_id: str | None = None, | ||
| secret_id: str | None = None, | ||
| role_arn: str | None = None, | ||
| role_id: str | None = None, | ||
| kubernetes_role: str | None = None, | ||
| kubernetes_jwt_path: str | None = "/var/run/secrets/kubernetes.io/serviceaccount/token", | ||
|
|
@@ -161,6 +163,7 @@ def __init__( | |
| self.key_id = key_id | ||
| self.secret_id = secret_id | ||
| self.role_id = role_id | ||
| self.role_arn = role_arn | ||
| self.kubernetes_role = kubernetes_role | ||
| self.kubernetes_jwt_path = kubernetes_jwt_path | ||
| self.gcp_key_path = gcp_key_path | ||
|
|
@@ -318,15 +321,36 @@ def _auth_azure(self, _client: hvac.Client) -> None: | |
| ) | ||
|
|
||
| def _auth_aws_iam(self, _client: hvac.Client) -> None: | ||
| if self.auth_mount_point: | ||
| _client.auth.aws.iam_login( | ||
| access_key=self.key_id, | ||
| secret_key=self.secret_id, | ||
| role=self.role_id, | ||
| mount_point=self.auth_mount_point, | ||
| ) | ||
| if self.key_id and self.secret_id: | ||
| auth_args = { | ||
| "access_key": self.key_id, | ||
| "secret_key": self.secret_id, | ||
| "role": self.role_id, | ||
| } | ||
| else: | ||
| _client.auth.aws.iam_login(access_key=self.key_id, secret_key=self.secret_id, role=self.role_id) | ||
| import boto3 | ||
|
|
||
| if self.role_arn: | ||
| sts_client = boto3.client("sts") | ||
| credentials = sts_client.assume_role(RoleArn=self.role_arn, RoleSessionName="airflow") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @pankajastro - we should consider exposing assume_role_kwargs as a This is currently available as an AWS Connection Extra parameter.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you please share an example of AIRFLOW__SECRETS__BACKEND_KWARGS?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please see the Request Syntax section for example kwargs. I imagine it would be a dictionary that you would pass to
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wdyt #39279
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes that looks good (assuming that it works). You wouldn't need a
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's included in the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. I am saying you no longer need a dedicated |
||
| auth_args = { | ||
| "access_key": credentials["Credentials"]["AccessKeyId"], | ||
| "secret_key": credentials["Credentials"]["SecretAccessKey"], | ||
| "session_token": credentials["Credentials"]["SessionToken"], | ||
| } | ||
| else: | ||
| session = boto3.Session() | ||
| credentials = session.get_credentials() | ||
| auth_args = { | ||
| "access_key": credentials.access_key, | ||
| "secret_key": credentials.secret_key, | ||
| "session_token": credentials.token, | ||
| } | ||
|
|
||
| if self.auth_mount_point: | ||
| auth_args["mount_point"] = self.auth_mount_point | ||
|
|
||
| _client.auth.aws.iam_login(**auth_args) | ||
|
|
||
| def _auth_approle(self, _client: hvac.Client) -> None: | ||
| if self.auth_mount_point: | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.