puppetlabs / puppetlabs-aws_inventory

Apache License 2.0
1 stars 10 forks source link
module supported

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:

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:

Credentials

In order of precedence:

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
              user: tag.User
    config:
      ssh:
        user: ec2-user
        private-key: ~/.aws/private-key.pem
        host-key-check: false