ansible-collections / amazon.aws

Ansible Collection for Amazon AWS
GNU General Public License v3.0
304 stars 334 forks source link

Region is not showed as required, but fails if not included in module #2308

Open Figrol opened 14 hours ago

Figrol commented 14 hours ago

Summary

When using the ec2_instance module, the examples and the table of parameters do not show the region parameter as being required. However, when running the module, the below error occurs:

"msg": "The amazon.aws.ec2_instance module requires a region and none was found in configuration, environment variables or module parameters",

When a region is added, it seems to work fine.

The same is present in the ec2_instance_info module.

Issue Type

Documentation Report

Component Name

ec2_instance, ec2_instance_info

Ansible Version

$ ansible --version
ansible [core 2.15.11]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/runner/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.9/site-packages/ansible
  ansible collection location = /runner/requirements_collections:/home/runner/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.9.19 (main, May 16 2024, 08:45:40) [GCC 8.5.0 20210514 (Red Hat 8.5.0-22)] (/usr/bin/python3.9)
  jinja version = 3.1.4
  libyaml = True

Collection Versions

$ ansible-galaxy collection list
# /runner/requirements_collections/ansible_collections
Collection                      Version
------------------------------- -------
amazon.aws                      8.1.0  
ansible.controller              4.5.7  
community.aws                   8.0.0  
community.general               9.3.0  

# /usr/share/ansible/collections/ansible_collections
Collection                      Version
------------------------------- -------
amazon.aws                      6.4.0  
ansible.controller              4.5.7  
ansible.netcommon               6.0.0  
ansible.network                 3.0.0  
ansible.posix                   1.5.4  
ansible.scm                     2.0.0  
ansible.security                2.0.0  
ansible.snmp                    2.0.0  
ansible.utils                   3.0.0  
ansible.windows                 1.14.0 
ansible.yang                    2.0.0  
arista.eos                      7.0.0  
cisco.asa                       5.0.0  
cisco.ios                       6.1.0  
cisco.iosxr                     7.0.0  
cisco.nxos                      6.0.0  
cloud.common                    2.1.2  
cloud.terraform                 1.1.1  
frr.frr                         2.0.2  
ibm.qradar                      3.0.0  
junipernetworks.junos           6.0.0  
kubernetes.core                 3.0.1  
microsoft.ad                    1.1.0  
openvswitch.openvswitch         2.1.1  
redhat.amq_broker               1.3.0  
redhat.eap                      1.3.1  
redhat.insights                 1.2.2  
redhat.openshift                2.3.0  
redhat.openshift_virtualization 1.2.3  
redhat.redhat_csp_download      1.2.2  
redhat.rhel_idm                 1.10.0 
redhat.rhel_system_roles        1.21.1 
redhat.rhv                      2.4.2  
redhat.runtimes_common          1.1.3  
redhat.sap_install              1.2.1  
redhat.satellite                3.10.0 
redhat.satellite_operations     1.3.0  
redhat.sso                      1.3.0  
sap.sap_operations              1.0.4  
servicenow.itsm                 2.1.0  
splunk.es                       3.0.0  
trendmicro.deepsec              3.0.0  
vmware.vmware_rest              2.3.1  
vyos.vyos                       4.0.2  

Configuration

$ ansible-config dump --only-changed

OS / Environment

RHEL 9 Ansible Automation Platform

Additional Information

No response

Code of Conduct

tremble commented 6 hours ago

Hi @Figrol,

Thanks for taking the time to submit this issue. While this may seem like an obvious "it is required", unfortunately it's not that simple. The practical need to set the parameter depends on the configuration of your local environment. Specifically, there are a number of alternative mechanisms for setting the region (as well as the AWS credentials), which we respect:

Setting the region parameter is highly recommended, since you generally want to place your resources in a specific region (rather than assuming your AWS configs will stay unchanged), but as a parameter it's not strictly required.

There's a note at the end of the parameter documentation which attempts to explain this:

The AWS SDK (boto3) that Ansible uses may also read defaults for credentials and other settings, such as the region, from its configuration files in the Ansible ‘host’ context (typically ~/.aws/credentials). See https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html for more information.