Skip to content
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

Revert bad changes #144

Merged
merged 2 commits into from
Sep 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions src/pds/registrysweepers/utils/db/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,34 +78,9 @@ def get_aws_credentials_from_ec2_metadata_service(iam_role_name: str) -> Credent
return credentials


def get_assumed_identity() -> str:
sts_client = boto3.client("sts")

response = sts_client.get_caller_identity()

arn = response["Arn"]
logging.info(f"Caller ARN: {arn}")

if "assumed-role" in arn:
role_name = arn.split("/")[-2]
logging.info(f"Role Name: {role_name}")
else:
role_name = None
logging.info("The credentials are not associated with an assumed role.")

return role_name


def get_aws_aoss_client_from_ssm(endpoint_url: str, iam_role_name: str) -> OpenSearch:
# https://opensearch.org/blog/aws-sigv4-support-for-clients/
logging.info(f'Expect role name "{iam_role_name}"')
get_assumed_identity()

credentials = boto3.Session().get_credentials()

# TODO: DELETE ME DO NOT MERGE
logging.info(credentials.token)
# END TODO
auth = RequestsAWSV4SignerAuth(credentials, "us-west-2", "aoss")
return get_aws_opensearch_client(endpoint_url, auth)

Expand Down
Loading