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

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

Open
1 task done
Figrol opened this issue Sep 24, 2024 · 1 comment
Open
1 task done

Comments

@Figrol
Copy link
Contributor

Figrol commented Sep 24, 2024

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

  • I agree to follow the Ansible Code of Conduct
@tremble
Copy link
Contributor

tremble commented Sep 25, 2024

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:

  • The "endpoint_url" parameter (mostly used by folks talking to an AWS-like service, but can be used to set the region)
  • The "AWS_REGION" environment variable
  • The local AWS configuration files (Typically in ~/.aws/)

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.

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

No branches or pull requests

3 participants