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

Fix access_key, token missing issue #2089

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dlscjf151
Copy link

SUMMARY

fix #2088

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

ansible_collections.community.aws.plugins.connection.aws_ssm.Connection._get_boto_client

ADDITIONAL INFORMATION

If you set the access_key first and then set the profile, the acces_key and token will be overwritten by the profile value instead of being applied. Therefore, only set the acces_key and token if you are not using the profile.

aws_access_key_id = self.get_option("access_key_id")
        aws_secret_access_key = self.get_option("secret_access_key")
        aws_session_token = self.get_option("session_token")

        session_args = dict(
            aws_access_key_id=aws_access_key_id,
            aws_secret_access_key=aws_secret_access_key,
            aws_session_token=aws_session_token,
            region_name=region_name,
        )
        if profile_name:
            session_args["profile_name"] = profile_name
        session = boto3.session.Session(**session_args)
============================================
aws_access_key_id = self.get_option("access_key_id")
        aws_secret_access_key = self.get_option("secret_access_key")
        aws_session_token = self.get_option("session_token")

        session_args = dict(
            region_name=region_name,
        )
        if profile_name:
            session_args["profile_name"] = profile_name
        else:
            session_args["aws_access_key_id"]=aws_access_key_id,
            session_args["aws_secret_access_key"]=aws_secret_access_key,
            session_args["aws_session_token"]=aws_session_token,

Copy link
Contributor

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/a825498a5b8c441a88f9b27c572b1d2e

✔️ ansible-galaxy-importer SUCCESS in 4m 42s (non-voting)
✔️ build-ansible-collection SUCCESS in 16m 59s
✔️ ansible-test-splitter SUCCESS in 8m 39s
integration-community.aws-1 FAILURE in 12m 44s
integration-community.aws-2 FAILURE in 13m 01s
integration-community.aws-3 FAILURE in 16m 54s
integration-community.aws-4 FAILURE in 13m 17s
integration-community.aws-5 FAILURE in 12m 18s
integration-community.aws-6 FAILURE in 11m 55s
✔️ integration-community.aws-7 SUCCESS in 9m 55s
integration-community.aws-8 FAILURE in 11m 50s
integration-community.aws-9 FAILURE in 12m 32s
integration-community.aws-10 FAILURE in 7m 01s
✔️ integration-community.aws-11 SUCCESS in 6m 46s
Skipped 11 jobs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aws_ssm.Connection._get_boto_client lose access_key, token when using aws profile
1 participant