Forge Home

aws_inventory

A task to generate Bolt inventory from AWS EC2 instances

61,592 downloads

19,295 latest version

5.0 quality score

We run a couple of automated
scans to help you access a
module's quality. Each module is
given a score based on how well
the author has formatted their
code and documentation and
modules are also checked for
malware using VirusTotal.

Please note, the information below
is for guidance only and neither of
these methods should be considered
an endorsement by Puppet.

Version information

  • 0.7.0 (latest)
  • 0.6.0
  • 0.5.2
  • 0.5.0
  • 0.4.0
  • 0.3.0
  • 0.2.0
  • 0.1.0
released Mar 25th 2021
This version is compatible with:
  • Puppet Enterprise 2023.2.x, 2023.1.x, 2023.0.x, 2021.7.x, 2021.6.x, 2021.5.x, 2021.4.x, 2021.3.x, 2021.2.x, 2021.1.x, 2021.0.x, 2019.8.x, 2019.7.x, 2019.5.x, 2019.4.x, 2019.3.x, 2019.2.x, 2019.1.x, 2019.0.x, 2018.1.x, 2017.3.x, 2017.2.x, 2016.4.x
  • Puppet >= 4.10.0 < 8.0.0
  • , , , , , ,

Start using this module

  • r10k or Code Manager
  • Bolt
  • Manual installation
  • Direct download

Add this module to your Puppetfile:

mod 'puppetlabs-aws_inventory', '0.7.0'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add puppetlabs-aws_inventory
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install puppetlabs-aws_inventory --version 0.7.0

Direct download is not typically how you would use a Puppet module to manage your infrastructure, but you may want to download the module in order to inspect the code.

Download

Documentation

puppetlabs/aws_inventory — version 0.7.0 Mar 25th 2021

aws_inventory

Table of Contents

  1. Description
  2. Requirements
  3. Usage

Description

This module includes a Bolt plugin to generate Bolt targets from AWS EC2 instances.

Requirements

You will need an aws_access_key_id and a aws_secret_access_key (see providing aws credentials) in order to authenticate against aws API.

Usage

The AWS Inventory plugin supports looking up running AWS EC2 instances. It supports several fields:

  • profile: The named profile to use when loading from AWS config and credentials files. (optional, defaults to default)
  • region: The region to look up EC2 instances from.
  • credentials: The path to an AWS credentials file to load. (optional, defaults to ~/.aws/credentials)
  • aws_access_key_id: The AWS access key id to use. (optional)
  • aws_secret_access_key: The AWS secret access key to use. (optional)
  • filters: The filter request parameters used to filter the EC2 instances by. Filters are name-values pairs, where the name is a request parameter and the values are an array of values to filter by. (optional)
  • target_mapping: A hash of target attributes to populate with resource values. The following attributes are available.

Note: One of uri or name is required. If only uri is set, then the value of uri will be used as the name.

Accessing EC2 instances requires a region and valid credentials to be specified. The following locations are searched in order until a value is found:

Region

In order of precedence:

  • region: <region> in the inventory or config file
  • ENV['AWS_REGION']
  • ~/.aws/credentials

Credentials

In order of precedence:

  • credentials: <filepath> in the inventory or config file
  • aws_access_key_id and aws_secret_access_key in the inventory or config file
  • ENV['AWS_ACCESS_KEY_ID'] and ENV['AWS_SECRET_ACCESS_KEY']
  • ~/.aws/credentials

If the region or credentials are located in a shared credentials file, a profile can be specified in the inventory file to choose which set of credentials to use. For example, if the inventory file were set to profile: user1, the second set of credentials would be used:

[default]
aws_access_key_id=...
aws_secret_access_key=...
region=...

[user1]
aws_access_key_id=...
aws_secret_access_key=...
region=...

AWS credential files stored in a non-standard location (~/.aws/credentials) can be configured in Bolt:

plugins:
  aws:
    credentials: ~/alternate_path/credentials

Examples

inventory.yaml

groups:
  - name: aws
    targets:
      - _plugin: aws_inventory
        profile: user1
        region: us-west-1
        filters:
          - name: tag:Owner
            values: [Devs]
          - name: instance-type
            values: [t2.micro, c5.large]
        target_mapping:
          name: public_dns_name
          uri: public_ip_address
          config:
            ssh:
              host: public_dns_name
    config:
      ssh:
        user: ec2-user
        private-key: ~/.aws/private-key.pem
        host-key-check: false