Description
Describe the Bug
README.md claims the following about the region setting:
In order of precedence:
- region: in the inventory or config file
- ENV['AWS_REGION']
- ~/.aws/credentials
The Bolt task does not seem to respect the region set in either ~/.aws/credentials or in ~/.aws/config. In general reading the region from the credentials file might or might not work, but it seems incorrect. The official AWS documentation says thats ensitive settings should go to credentials and insensitive to config. That's what "aws configure" command also does.
A related issue is that setting AWS_REGION environment variable (as documented) does not seem to work. You need to explicitly set the region with env_var plugin, e.g. like this:
--- snip ---
region:
_plugin: env_var
var: AWS_REGION
--- snip ---
Expected Behavior
I would expect the region setting in a named profile in ~/.aws/config to be respected by this inventory plugin. I would also expect AWS_REGION environment parameter to be respected without extra tricks like using the env_var plugin.
Steps to Reproduce
Add an aws_inventory group to inventory.yaml. For example:
groups:
- name: aws
targets:
- _plugin: aws_inventory
target_mapping:
name: tags.Name
uri: private_ip_address
Create ~/.aws/credentials:
[foobar]
aws_access_key_id=access-key-id
aws_secret_access_key=secret-access-key
Create ~/.aws/config:
[profile foobar]
region=eu-central-1
Set AWS_PROFILE environment variable:
export AWS_PROFILE=foobar
Now try to use the inventory:
$ bolt inventory show
Task aws_inventory::resolve_reference:
expects a value for parameter 'region'
Environment
- Fedora release 35 (Thirty Five)
- Bolt 3.22.1
Additional context
Things that did not help:
- Defining the AWS profile name (profile: foobar) in the inventory
- Defining the region in the default section of the AWS credentials or config files