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 settings not loaded according to what is documented #22

Open
mattock opened this issue May 26, 2022 · 0 comments
Open

Region settings not loaded according to what is documented #22

mattock opened this issue May 26, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@mattock
Copy link
Contributor

mattock commented May 26, 2022

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
@mattock mattock added the bug Something isn't working label May 26, 2022
@mattock mattock changed the title Region not read from ~/.aws/config Region settings not loaded according to what is documented May 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant