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/support envvars for lookup aws ssm #623

Conversation

Cicatrice
Copy link

@Cicatrice Cicatrice commented Jan 18, 2022

Depends-On: ansible/ansible-zuul-jobs#1424

SUMMARY

Working on support in lookup plugin amazon.aws.aws_ssm for endpoint parameters, as well of tradional environment variable for client configuration (AWS_PROFILE, AWS_ACCESS_KEY_ID, ...).

This should fixes #519

Depends-On: #728

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

aws_ssm

ADDITIONAL INFORMATION

It seems LookupModule cannot benefit from AnsibleAWSModule (it expect several methods/params, I am not familiar enough with Python and Ansible to sort it out) ; so this PR uses boto3_conn and get_aws_connection_info defined in utils.ec2.

This is a simple snippet how it can be used:

- name: Load env
  collections:
  - amazon.aws
  gather_facts: no
  hosts: localhost
  connection: local
  vars:
    my_env: "{{ lookup('amazon.aws.aws_ssm', 'status', endpoint='http://localhost:4566') }}"
  tasks:
    - name: show the env
      debug:
        msg: "{{ my_env }}"

Command line test:

ANSIBLE_COLLECTIONS_PATHS=${ANSIBLE_HOME}/collections ansible-playbook test.yml

Output:

PLAY [Load env] *************************************************************************************************************************************************************************************************************************************************************

TASK [show the env] *********************************************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
    "msg": "INIT"
}

PLAY RECAP ******************************************************************************************************************************************************************************************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

Another test with envars:

AWS_ACCESS_KEY_ID='foo' AWS_ACCESS_SECRET_KEY='bar' AWS_URL='http://localhost:4566' ANSIBLE_COLLECTIONS_PATHS=${ANSIBLE_HOME}/collections ansible-playbook test.yml

where we remove the endpoint from lookup:

- name: Load env
  collections:
  - amazon.aws
  gather_facts: no
  hosts: localhost
  connection: local
  vars:
    my_env: "{{ lookup('amazon.aws.aws_ssm', 'status') }}"
  tasks:
    - name: show the env
      debug:
        msg: "{{ my_env }}"

(provides same output)

@softwarefactory-project-zuul
Copy link
Contributor

@softwarefactory-project-zuul
Copy link
Contributor

@softwarefactory-project-zuul
Copy link
Contributor

@ansibullbot ansibullbot added community_review feature This issue/PR relates to a feature request lookup lookup plugin needs_triage new_contributor Help guide this first time contributor plugins plugin (any type) tests tests labels Jan 27, 2022
@Cicatrice
Copy link
Author

recheck

@softwarefactory-project-zuul
Copy link
Contributor

@jillr jillr removed the needs_triage label Feb 8, 2022
@alinabuzachis
Copy link
Collaborator

recheck

@softwarefactory-project-zuul
Copy link
Contributor

@markuman
Copy link
Member

recheck

@markuman
Copy link
Member

@Cicatrice can you also add a channgelog fragment please?

@softwarefactory-project-zuul
Copy link
Contributor

Build failed.

@alinabuzachis alinabuzachis added the backport-3 PR should be backported to the stable-3 branch label Mar 22, 2022
@alinabuzachis
Copy link
Collaborator

recheck

@softwarefactory-project-zuul
Copy link
Contributor

Build failed.

@alinabuzachis
Copy link
Collaborator

recheck

@softwarefactory-project-zuul
Copy link
Contributor

Build failed.

@alinabuzachis
Copy link
Collaborator

recheck

@softwarefactory-project-zuul
Copy link
Contributor

Build failed.

@Cicatrice Cicatrice force-pushed the fix/support_envvars_for_lookup_aws_ssm branch from 193f0b4 to c06cbba Compare May 19, 2022 15:51
@ansibullbot ansibullbot added community_review and removed needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR labels May 19, 2022
@softwarefactory-project-zuul
Copy link
Contributor

Build failed.

✔️ ansible-galaxy-importer SUCCESS in 4m 24s
✔️ build-ansible-collection SUCCESS in 5m 35s
ansible-test-sanity-aws-ansible-python38 FAILURE in 12m 15s
ansible-test-sanity-aws-ansible-2.9-python38 FAILURE in 11m 39s
ansible-test-sanity-aws-ansible-2.11-python38 FAILURE in 9m 57s
✔️ ansible-test-units-amazon-aws-python38 SUCCESS in 6m 05s
✔️ ansible-test-splitter SUCCESS in 2m 25s
⚠️ integration-amazon.aws-1 SKIPPED
⚠️ integration-amazon.aws-2 SKIPPED
⚠️ integration-amazon.aws-3 SKIPPED
⚠️ integration-amazon.aws-4 SKIPPED
⚠️ integration-amazon.aws-5 SKIPPED
⚠️ integration-amazon.aws-6 SKIPPED
⚠️ integration-amazon.aws-7 SKIPPED
⚠️ integration-amazon.aws-8 SKIPPED
⚠️ integration-amazon.aws-9 SKIPPED
⚠️ integration-amazon.aws-10 SKIPPED
⚠️ integration-amazon.aws-11 SKIPPED
⚠️ integration-amazon.aws-12 SKIPPED
⚠️ integration-amazon.aws-13 SKIPPED
⚠️ integration-community.aws-1 SKIPPED
⚠️ integration-community.aws-2 SKIPPED
⚠️ integration-community.aws-3 SKIPPED
⚠️ integration-community.aws-4 SKIPPED
⚠️ integration-community.aws-5 SKIPPED
⚠️ integration-community.aws-6 SKIPPED
⚠️ integration-community.aws-7 SKIPPED
⚠️ integration-community.aws-8 SKIPPED
⚠️ integration-community.aws-9 SKIPPED
⚠️ integration-community.aws-10 SKIPPED
⚠️ integration-community.aws-11 SKIPPED
⚠️ integration-community.aws-12 SKIPPED
⚠️ integration-community.aws-13 SKIPPED

@softwarefactory-project-zuul
Copy link
Contributor

Build failed.

✔️ ansible-galaxy-importer SUCCESS in 4m 41s
✔️ build-ansible-collection SUCCESS in 4m 45s
ansible-test-sanity-aws-ansible-python38 FAILURE in 9m 24s
ansible-test-sanity-aws-ansible-2.9-python38 FAILURE in 12m 24s
ansible-test-sanity-aws-ansible-2.11-python38 FAILURE in 10m 22s
✔️ ansible-test-units-amazon-aws-python38 SUCCESS in 6m 01s
✔️ ansible-test-splitter SUCCESS in 2m 33s
⚠️ integration-amazon.aws-1 SKIPPED
⚠️ integration-amazon.aws-2 SKIPPED
⚠️ integration-amazon.aws-3 SKIPPED
⚠️ integration-amazon.aws-4 SKIPPED
⚠️ integration-amazon.aws-5 SKIPPED
⚠️ integration-amazon.aws-6 SKIPPED
⚠️ integration-amazon.aws-7 SKIPPED
⚠️ integration-amazon.aws-8 SKIPPED
⚠️ integration-amazon.aws-9 SKIPPED
⚠️ integration-amazon.aws-10 SKIPPED
⚠️ integration-amazon.aws-11 SKIPPED
⚠️ integration-amazon.aws-12 SKIPPED
⚠️ integration-amazon.aws-13 SKIPPED
⚠️ integration-community.aws-1 SKIPPED
⚠️ integration-community.aws-2 SKIPPED
⚠️ integration-community.aws-3 SKIPPED
⚠️ integration-community.aws-4 SKIPPED
⚠️ integration-community.aws-5 SKIPPED
⚠️ integration-community.aws-6 SKIPPED
⚠️ integration-community.aws-7 SKIPPED
⚠️ integration-community.aws-8 SKIPPED
⚠️ integration-community.aws-9 SKIPPED
⚠️ integration-community.aws-10 SKIPPED
⚠️ integration-community.aws-11 SKIPPED
⚠️ integration-community.aws-12 SKIPPED
⚠️ integration-community.aws-13 SKIPPED

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.

✔️ ansible-galaxy-importer SUCCESS in 5m 22s
✔️ build-ansible-collection SUCCESS in 5m 18s
✔️ ansible-test-sanity-aws-ansible-python38 SUCCESS in 10m 06s
✔️ ansible-test-sanity-aws-ansible-2.9-python38 SUCCESS in 10m 47s
✔️ ansible-test-sanity-aws-ansible-2.11-python38 SUCCESS in 8m 57s
✔️ ansible-test-units-amazon-aws-python38 SUCCESS in 6m 08s
✔️ ansible-test-splitter SUCCESS in 2m 29s
⚠️ integration-amazon.aws-1 SKIPPED
⚠️ integration-amazon.aws-2 SKIPPED
⚠️ integration-amazon.aws-3 SKIPPED
⚠️ integration-amazon.aws-4 SKIPPED
⚠️ integration-amazon.aws-5 SKIPPED
⚠️ integration-amazon.aws-6 SKIPPED
⚠️ integration-amazon.aws-7 SKIPPED
⚠️ integration-amazon.aws-8 SKIPPED
⚠️ integration-amazon.aws-9 SKIPPED
⚠️ integration-amazon.aws-10 SKIPPED
⚠️ integration-amazon.aws-11 SKIPPED
⚠️ integration-amazon.aws-12 SKIPPED
⚠️ integration-amazon.aws-13 SKIPPED
⚠️ integration-community.aws-1 SKIPPED
⚠️ integration-community.aws-2 SKIPPED
⚠️ integration-community.aws-3 SKIPPED
⚠️ integration-community.aws-4 SKIPPED
⚠️ integration-community.aws-5 SKIPPED
⚠️ integration-community.aws-6 SKIPPED
⚠️ integration-community.aws-7 SKIPPED
⚠️ integration-community.aws-8 SKIPPED
⚠️ integration-community.aws-9 SKIPPED
⚠️ integration-community.aws-10 SKIPPED
⚠️ integration-community.aws-11 SKIPPED
⚠️ integration-community.aws-12 SKIPPED
⚠️ integration-community.aws-13 SKIPPED

@alinabuzachis
Copy link
Collaborator

alinabuzachis commented May 24, 2022

@Cicatrice could you also please add a changelog fragment for this fix https://docs.ansible.com/ansible/latest/community/development_process.html#changelogs-how-to? Thank you.

Copy link
Contributor

@tremble tremble left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking the time to submit this PR.
2 minor things:

  1. Please add a changelog fragment https://docs.ansible.com/ansible/latest/community/development_process.html#changelogs-how-to
  2. boto3_conn already catches the various botocore exceptions, there's no need to re-catch them.

Comment on lines +214 to +222
try:
client = boto3_conn(module=self, **cli_boto_params)
except (
botocore.exceptions.ProfileNotFound,
botocore.exceptions.PartialCredentialsError,
botocore.exceptions.ClientError,
botocore.exceptions.ParamValidationError,
):
raise AnsibleError("Insufficient credentials found.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
try:
client = boto3_conn(module=self, **cli_boto_params)
except (
botocore.exceptions.ProfileNotFound,
botocore.exceptions.PartialCredentialsError,
botocore.exceptions.ClientError,
botocore.exceptions.ParamValidationError,
):
raise AnsibleError("Insufficient credentials found.")
client = boto3_conn(module=self, **cli_boto_params)

The botocore exceptions are already caught

@alinabuzachis
Copy link
Collaborator

Superseded by #837
@Cicatrice Thank you very much for this contribution!

softwarefactory-project-zuul bot pushed a commit that referenced this pull request May 25, 2022
Fix support envvars for lookup aws ssm

SUMMARY

Took over from #623 to apply reviewer's comments and add a changelog fragment.
Working on support in lookup plugin amazon.aws.aws_ssm for endpoint parameters, as well of tradional environment variable for client configuration (AWS_PROFILE, AWS_ACCESS_KEY_ID, ...).
This should fixes #519
Depends-On: #728
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
aws_ssm
ADDITIONAL INFORMATION
It seems LookupModule cannot benefit from AnsibleAWSModule (it expect several methods/params, I am not familiar enough with Python and Ansible to sort it out) ; so this PR uses boto3_conn and get_aws_connection_info defined in utils.ec2.
This is a simple snippet how it can be used:
- name: Load env
  collections:
  - amazon.aws
  gather_facts: no
  hosts: localhost
  connection: local
  vars:
    my_env: "{{ lookup('amazon.aws.aws_ssm', 'status', endpoint='http://localhost:4566') }}"
  tasks:
    - name: show the env
      debug:
        msg: "{{ my_env }}"

Command line test:
ANSIBLE_COLLECTIONS_PATHS=${ANSIBLE_HOME}/collections ansible-playbook test.yml
Output:
PLAY [Load env] *************************************************************************************************************************************************************************************************************************************************************

TASK [show the env] *********************************************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
    "msg": "INIT"
}

PLAY RECAP ******************************************************************************************************************************************************************************************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

Another test with envars:
AWS_ACCESS_KEY_ID='foo' AWS_ACCESS_SECRET_KEY='bar' AWS_URL='http://localhost:4566' ANSIBLE_COLLECTIONS_PATHS=${ANSIBLE_HOME}/collections ansible-playbook test.yml
where we remove the endpoint from lookup:
- name: Load env
  collections:
  - amazon.aws
  gather_facts: no
  hosts: localhost
  connection: local
  vars:
    my_env: "{{ lookup('amazon.aws.aws_ssm', 'status') }}"
  tasks:
    - name: show the env
      debug:
        msg: "{{ my_env }}"
(provides same output)

Reviewed-by: Mark Chappell <None>
alinabuzachis added a commit to alinabuzachis/amazon.aws that referenced this pull request May 25, 2022
Fix support envvars for lookup aws ssm

SUMMARY

Took over from ansible-collections#623 to apply reviewer's comments and add a changelog fragment.
Working on support in lookup plugin amazon.aws.aws_ssm for endpoint parameters, as well of tradional environment variable for client configuration (AWS_PROFILE, AWS_ACCESS_KEY_ID, ...).
This should fixes ansible-collections#519
Depends-On: ansible-collections#728
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
aws_ssm
ADDITIONAL INFORMATION
It seems LookupModule cannot benefit from AnsibleAWSModule (it expect several methods/params, I am not familiar enough with Python and Ansible to sort it out) ; so this PR uses boto3_conn and get_aws_connection_info defined in utils.ec2.
This is a simple snippet how it can be used:
- name: Load env
  collections:
  - amazon.aws
  gather_facts: no
  hosts: localhost
  connection: local
  vars:
    my_env: "{{ lookup('amazon.aws.aws_ssm', 'status', endpoint='http://localhost:4566') }}"
  tasks:
    - name: show the env
      debug:
        msg: "{{ my_env }}"

Command line test:
ANSIBLE_COLLECTIONS_PATHS=${ANSIBLE_HOME}/collections ansible-playbook test.yml
Output:
PLAY [Load env] *************************************************************************************************************************************************************************************************************************************************************

TASK [show the env] *********************************************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
    "msg": "INIT"
}

PLAY RECAP ******************************************************************************************************************************************************************************************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

Another test with envars:
AWS_ACCESS_KEY_ID='foo' AWS_ACCESS_SECRET_KEY='bar' AWS_URL='http://localhost:4566' ANSIBLE_COLLECTIONS_PATHS=${ANSIBLE_HOME}/collections ansible-playbook test.yml
where we remove the endpoint from lookup:
- name: Load env
  collections:
  - amazon.aws
  gather_facts: no
  hosts: localhost
  connection: local
  vars:
    my_env: "{{ lookup('amazon.aws.aws_ssm', 'status') }}"
  tasks:
    - name: show the env
      debug:
        msg: "{{ my_env }}"
(provides same output)

Reviewed-by: Mark Chappell <None>
(cherry picked from commit 9639325)
alinabuzachis added a commit to alinabuzachis/amazon.aws that referenced this pull request May 25, 2022
Fix support envvars for lookup aws ssm

SUMMARY

Took over from ansible-collections#623 to apply reviewer's comments and add a changelog fragment.
Working on support in lookup plugin amazon.aws.aws_ssm for endpoint parameters, as well of tradional environment variable for client configuration (AWS_PROFILE, AWS_ACCESS_KEY_ID, ...).
This should fixes ansible-collections#519
Depends-On: ansible-collections#728
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
aws_ssm
ADDITIONAL INFORMATION
It seems LookupModule cannot benefit from AnsibleAWSModule (it expect several methods/params, I am not familiar enough with Python and Ansible to sort it out) ; so this PR uses boto3_conn and get_aws_connection_info defined in utils.ec2.
This is a simple snippet how it can be used:
- name: Load env
  collections:
  - amazon.aws
  gather_facts: no
  hosts: localhost
  connection: local
  vars:
    my_env: "{{ lookup('amazon.aws.aws_ssm', 'status', endpoint='http://localhost:4566') }}"
  tasks:
    - name: show the env
      debug:
        msg: "{{ my_env }}"

Command line test:
ANSIBLE_COLLECTIONS_PATHS=${ANSIBLE_HOME}/collections ansible-playbook test.yml
Output:
PLAY [Load env] *************************************************************************************************************************************************************************************************************************************************************

TASK [show the env] *********************************************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
    "msg": "INIT"
}

PLAY RECAP ******************************************************************************************************************************************************************************************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

Another test with envars:
AWS_ACCESS_KEY_ID='foo' AWS_ACCESS_SECRET_KEY='bar' AWS_URL='http://localhost:4566' ANSIBLE_COLLECTIONS_PATHS=${ANSIBLE_HOME}/collections ansible-playbook test.yml
where we remove the endpoint from lookup:
- name: Load env
  collections:
  - amazon.aws
  gather_facts: no
  hosts: localhost
  connection: local
  vars:
    my_env: "{{ lookup('amazon.aws.aws_ssm', 'status') }}"
  tasks:
    - name: show the env
      debug:
        msg: "{{ my_env }}"
(provides same output)

Reviewed-by: Mark Chappell <None>
(cherry picked from commit 9639325)
alinabuzachis added a commit to alinabuzachis/amazon.aws that referenced this pull request May 25, 2022
Fix support envvars for lookup aws ssm

SUMMARY

Took over from ansible-collections#623 to apply reviewer's comments and add a changelog fragment.
Working on support in lookup plugin amazon.aws.aws_ssm for endpoint parameters, as well of tradional environment variable for client configuration (AWS_PROFILE, AWS_ACCESS_KEY_ID, ...).
This should fixes ansible-collections#519
Depends-On: ansible-collections#728
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
aws_ssm
ADDITIONAL INFORMATION
It seems LookupModule cannot benefit from AnsibleAWSModule (it expect several methods/params, I am not familiar enough with Python and Ansible to sort it out) ; so this PR uses boto3_conn and get_aws_connection_info defined in utils.ec2.
This is a simple snippet how it can be used:
- name: Load env
  collections:
  - amazon.aws
  gather_facts: no
  hosts: localhost
  connection: local
  vars:
    my_env: "{{ lookup('amazon.aws.aws_ssm', 'status', endpoint='http://localhost:4566') }}"
  tasks:
    - name: show the env
      debug:
        msg: "{{ my_env }}"

Command line test:
ANSIBLE_COLLECTIONS_PATHS=${ANSIBLE_HOME}/collections ansible-playbook test.yml
Output:
PLAY [Load env] *************************************************************************************************************************************************************************************************************************************************************

TASK [show the env] *********************************************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
    "msg": "INIT"
}

PLAY RECAP ******************************************************************************************************************************************************************************************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

Another test with envars:
AWS_ACCESS_KEY_ID='foo' AWS_ACCESS_SECRET_KEY='bar' AWS_URL='http://localhost:4566' ANSIBLE_COLLECTIONS_PATHS=${ANSIBLE_HOME}/collections ansible-playbook test.yml
where we remove the endpoint from lookup:
- name: Load env
  collections:
  - amazon.aws
  gather_facts: no
  hosts: localhost
  connection: local
  vars:
    my_env: "{{ lookup('amazon.aws.aws_ssm', 'status') }}"
  tasks:
    - name: show the env
      debug:
        msg: "{{ my_env }}"
(provides same output)

Reviewed-by: Mark Chappell <None>
(cherry picked from commit 9639325)
alinabuzachis added a commit to alinabuzachis/amazon.aws that referenced this pull request May 25, 2022
Fix support envvars for lookup aws ssm

SUMMARY

Took over from ansible-collections#623 to apply reviewer's comments and add a changelog fragment.
Working on support in lookup plugin amazon.aws.aws_ssm for endpoint parameters, as well of tradional environment variable for client configuration (AWS_PROFILE, AWS_ACCESS_KEY_ID, ...).
This should fixes ansible-collections#519
Depends-On: ansible-collections#728
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
aws_ssm
ADDITIONAL INFORMATION
It seems LookupModule cannot benefit from AnsibleAWSModule (it expect several methods/params, I am not familiar enough with Python and Ansible to sort it out) ; so this PR uses boto3_conn and get_aws_connection_info defined in utils.ec2.
This is a simple snippet how it can be used:
- name: Load env
  collections:
  - amazon.aws
  gather_facts: no
  hosts: localhost
  connection: local
  vars:
    my_env: "{{ lookup('amazon.aws.aws_ssm', 'status', endpoint='http://localhost:4566') }}"
  tasks:
    - name: show the env
      debug:
        msg: "{{ my_env }}"

Command line test:
ANSIBLE_COLLECTIONS_PATHS=${ANSIBLE_HOME}/collections ansible-playbook test.yml
Output:
PLAY [Load env] *************************************************************************************************************************************************************************************************************************************************************

TASK [show the env] *********************************************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
    "msg": "INIT"
}

PLAY RECAP ******************************************************************************************************************************************************************************************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

Another test with envars:
AWS_ACCESS_KEY_ID='foo' AWS_ACCESS_SECRET_KEY='bar' AWS_URL='http://localhost:4566' ANSIBLE_COLLECTIONS_PATHS=${ANSIBLE_HOME}/collections ansible-playbook test.yml
where we remove the endpoint from lookup:
- name: Load env
  collections:
  - amazon.aws
  gather_facts: no
  hosts: localhost
  connection: local
  vars:
    my_env: "{{ lookup('amazon.aws.aws_ssm', 'status') }}"
  tasks:
    - name: show the env
      debug:
        msg: "{{ my_env }}"
(provides same output)

Reviewed-by: Mark Chappell <None>
(cherry picked from commit 9639325)
softwarefactory-project-zuul bot pushed a commit that referenced this pull request May 25, 2022
Fix support envvars for lookup aws ssm (#837)

This is a manual backport to stable-3 because #837 failed to be automatically backported.
Fix support envvars for lookup aws ssm
SUMMARY
Took over from #623 to apply reviewer's comments and add a changelog fragment.
Working on support in lookup plugin amazon.aws.aws_ssm for endpoint parameters, as well of tradional environment variable for client configuration (AWS_PROFILE, AWS_ACCESS_KEY_ID, ...).
This should fixes #519
Depends-On: #728
ISSUE TYPE
Feature Pull Request
COMPONENT NAME
aws_ssm
ADDITIONAL INFORMATION
It seems LookupModule cannot benefit from AnsibleAWSModule (it expect several methods/params, I am not familiar enough with Python and Ansible to sort it out) ; so this PR uses boto3_conn and get_aws_connection_info defined in utils.ec2.
This is a simple snippet how it can be used:

name: Load env
collections:

amazon.aws
gather_facts: no
hosts: localhost
connection: local
vars:
my_env: "{{ lookup('amazon.aws.aws_ssm', 'status', endpoint='http://localhost:4566') }}"
tasks:

name: show the env
debug:
msg: "{{ my_env }}"





Command line test:
ANSIBLE_COLLECTIONS_PATHS=${ANSIBLE_HOME}/collections ansible-playbook test.yml
Output:
PLAY [Load env] *************************************************************************************************************************************************************************************************************************************************************
TASK [show the env] *********************************************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
"msg": "INIT"
}
PLAY RECAP ******************************************************************************************************************************************************************************************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
Another test with envars:
AWS_ACCESS_KEY_ID='foo' AWS_ACCESS_SECRET_KEY='bar' AWS_URL='http://localhost:4566' ANSIBLE_COLLECTIONS_PATHS=${ANSIBLE_HOME}/collections ansible-playbook test.yml
where we remove the endpoint from lookup:

name: Load env
collections:

amazon.aws
gather_facts: no
hosts: localhost
connection: local
vars:
my_env: "{{ lookup('amazon.aws.aws_ssm', 'status') }}"
tasks:

name: show the env
debug:
msg: "{{ my_env }}"
(provides same output)





Reviewed-by: Mark Chappell 
(cherry picked from commit 9639325)
SUMMARY


ISSUE TYPE


Bugfix Pull Request
Docs Pull Request
Feature Pull Request
New Module Pull Request

COMPONENT NAME

ADDITIONAL INFORMATION

Reviewed-by: Joseph Torcasso <None>
Reviewed-by: Mark Chappell <None>
alinabuzachis pushed a commit to alinabuzachis/amazon.aws that referenced this pull request Sep 21, 2022
…nsible-collections#623)

Added support for InputTransformer attribute of cloudwatchevent_rule

SUMMARY
EventBridge has the InputTransformer attribute on target to allow providing custom input to a target based on certain event data. This PR adds this functionality and includes an example usage.
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
aws.cloudwatchevent_rule
ADDITIONAL INFORMATION
    ...
        "targets": [
            {
                "arn": "arn:aws:sns:us-east-1:123456789012:MySNSTopic",
                "id": "MySNSTopic",
                "input_transformer": {
                    "input_paths_map": {
                        "instance": "$.detail.instance-id",
                        "state": "$.detail.state"
                    },
                    "input_template": "\"<instance> is in state <state>\""
                }
            }
        ]

Reviewed-by: Markus Bergholz <[email protected]>
Reviewed-by: Alina Buzachis <None>
Reviewed-by: Avishay Bar <[email protected]>
Reviewed-by: Jill R <None>
Reviewed-by: Mark Chappell <None>

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@bd097b5
goneri pushed a commit to alinabuzachis/amazon.aws that referenced this pull request Sep 21, 2022
…nsible-collections#623)

Added support for InputTransformer attribute of cloudwatchevent_rule

SUMMARY
EventBridge has the InputTransformer attribute on target to allow providing custom input to a target based on certain event data. This PR adds this functionality and includes an example usage.
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
aws.cloudwatchevent_rule
ADDITIONAL INFORMATION
    ...
        "targets": [
            {
                "arn": "arn:aws:sns:us-east-1:123456789012:MySNSTopic",
                "id": "MySNSTopic",
                "input_transformer": {
                    "input_paths_map": {
                        "instance": "$.detail.instance-id",
                        "state": "$.detail.state"
                    },
                    "input_template": "\"<instance> is in state <state>\""
                }
            }
        ]

Reviewed-by: Markus Bergholz <[email protected]>
Reviewed-by: Alina Buzachis <None>
Reviewed-by: Avishay Bar <[email protected]>
Reviewed-by: Jill R <None>
Reviewed-by: Mark Chappell <None>

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@bd097b5
goneri pushed a commit to alinabuzachis/amazon.aws that referenced this pull request Sep 21, 2022
…nsible-collections#623)

Added support for InputTransformer attribute of cloudwatchevent_rule

SUMMARY
EventBridge has the InputTransformer attribute on target to allow providing custom input to a target based on certain event data. This PR adds this functionality and includes an example usage.
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
aws.cloudwatchevent_rule
ADDITIONAL INFORMATION
    ...
        "targets": [
            {
                "arn": "arn:aws:sns:us-east-1:123456789012:MySNSTopic",
                "id": "MySNSTopic",
                "input_transformer": {
                    "input_paths_map": {
                        "instance": "$.detail.instance-id",
                        "state": "$.detail.state"
                    },
                    "input_template": "\"<instance> is in state <state>\""
                }
            }
        ]

Reviewed-by: Markus Bergholz <[email protected]>
Reviewed-by: Alina Buzachis <None>
Reviewed-by: Avishay Bar <[email protected]>
Reviewed-by: Jill R <None>
Reviewed-by: Mark Chappell <None>

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@bd097b5
goneri pushed a commit to alinabuzachis/amazon.aws that referenced this pull request Sep 21, 2022
…nsible-collections#623)

Added support for InputTransformer attribute of cloudwatchevent_rule

SUMMARY
EventBridge has the InputTransformer attribute on target to allow providing custom input to a target based on certain event data. This PR adds this functionality and includes an example usage.
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
aws.cloudwatchevent_rule
ADDITIONAL INFORMATION
    ...
        "targets": [
            {
                "arn": "arn:aws:sns:us-east-1:123456789012:MySNSTopic",
                "id": "MySNSTopic",
                "input_transformer": {
                    "input_paths_map": {
                        "instance": "$.detail.instance-id",
                        "state": "$.detail.state"
                    },
                    "input_template": "\"<instance> is in state <state>\""
                }
            }
        ]

Reviewed-by: Markus Bergholz <[email protected]>
Reviewed-by: Alina Buzachis <None>
Reviewed-by: Avishay Bar <[email protected]>
Reviewed-by: Jill R <None>
Reviewed-by: Mark Chappell <None>

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@bd097b5
abikouo pushed a commit to abikouo/amazon.aws that referenced this pull request Sep 18, 2023
…nsible-collections#623)

Added support for InputTransformer attribute of cloudwatchevent_rule

SUMMARY
EventBridge has the InputTransformer attribute on target to allow providing custom input to a target based on certain event data. This PR adds this functionality and includes an example usage.
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
aws.cloudwatchevent_rule
ADDITIONAL INFORMATION
    ...
        "targets": [
            {
                "arn": "arn:aws:sns:us-east-1:123456789012:MySNSTopic",
                "id": "MySNSTopic",
                "input_transformer": {
                    "input_paths_map": {
                        "instance": "$.detail.instance-id",
                        "state": "$.detail.state"
                    },
                    "input_template": "\"<instance> is in state <state>\""
                }
            }
        ]

Reviewed-by: Markus Bergholz <[email protected]>
Reviewed-by: Alina Buzachis <None>
Reviewed-by: Avishay Bar <[email protected]>
Reviewed-by: Jill R <None>
Reviewed-by: Mark Chappell <None>
abikouo pushed a commit to abikouo/amazon.aws that referenced this pull request Sep 18, 2023
…nsible-collections#623)

Added support for InputTransformer attribute of cloudwatchevent_rule

SUMMARY
EventBridge has the InputTransformer attribute on target to allow providing custom input to a target based on certain event data. This PR adds this functionality and includes an example usage.
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
aws.cloudwatchevent_rule
ADDITIONAL INFORMATION
    ...
        "targets": [
            {
                "arn": "arn:aws:sns:us-east-1:123456789012:MySNSTopic",
                "id": "MySNSTopic",
                "input_transformer": {
                    "input_paths_map": {
                        "instance": "$.detail.instance-id",
                        "state": "$.detail.state"
                    },
                    "input_template": "\"<instance> is in state <state>\""
                }
            }
        ]

Reviewed-by: Markus Bergholz <[email protected]>
Reviewed-by: Alina Buzachis <None>
Reviewed-by: Avishay Bar <[email protected]>
Reviewed-by: Jill R <None>
Reviewed-by: Mark Chappell <None>
abikouo pushed a commit to abikouo/amazon.aws that referenced this pull request Oct 24, 2023
…nsible-collections#623)

Added support for InputTransformer attribute of cloudwatchevent_rule

SUMMARY
EventBridge has the InputTransformer attribute on target to allow providing custom input to a target based on certain event data. This PR adds this functionality and includes an example usage.
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
aws.cloudwatchevent_rule
ADDITIONAL INFORMATION
    ...
        "targets": [
            {
                "arn": "arn:aws:sns:us-east-1:123456789012:MySNSTopic",
                "id": "MySNSTopic",
                "input_transformer": {
                    "input_paths_map": {
                        "instance": "$.detail.instance-id",
                        "state": "$.detail.state"
                    },
                    "input_template": "\"<instance> is in state <state>\""
                }
            }
        ]

Reviewed-by: Markus Bergholz <[email protected]>
Reviewed-by: Alina Buzachis <None>
Reviewed-by: Avishay Bar <[email protected]>
Reviewed-by: Jill R <None>
Reviewed-by: Mark Chappell <None>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-3 PR should be backported to the stable-3 branch community_review feature This issue/PR relates to a feature request lookup lookup plugin new_contributor Help guide this first time contributor plugins plugin (any type) tests tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aws_ssm look does not support endpoint_url
7 participants