Skip to content
This repository has been archived by the owner on Jun 5, 2020. It is now read-only.

Latest commit

 

History

History
158 lines (114 loc) · 8.13 KB

README.md

File metadata and controls

158 lines (114 loc) · 8.13 KB

Amazon AWS

Table of contents

  1. Description
  2. Setup
  3. Usage
  4. Reference

Description

Amazon AWS exposes an API for creating and managing its Infrastructure as a Service platform. By leveraging the power of Puppet code, the module enables you to interact with the AWS API to manage your AWS resources, and provides you with the ability to run Puppet tasks on target EC2 instances.

The module is generated from the AWS API specifications and utilizes the AWS Ruby SDK. For additional information, see the AWS SDK for Ruby documentation.

Setup

Installing the module

Install the retries gem and the Amazon AWS Ruby SDK gem, using the same Ruby used by Puppet.

If using Puppet 4.x or higher, install the gems by running the following command:

/opt/puppetlabs/puppet/bin/gem install aws-sdk retries

Set the following environment variables specific to your AWS installation:

export AWS_ACCESS_KEY_ID=your_access_key_id
export AWS_SECRET_ACCESS_KEY=your_secret_access_key
export AWS_REGION=your_region

To install the module, run the following command:

puppet module install puppetlabs-amazon_aws

Validating the module

This module is compliant with the Puppet Development Kit (PDK), which provides the tool to help validate the modules's metadata, syntax, and style. When you run validations, PDK output tells you which validations it is running and notifies you of any errors or warnings it finds for each type of validation; syntax, code style, and metadata.

To run all validations against this module, run the following command:

pdk validate ruby
pdk validate metadata

To change validation behavior, add options flags to the command. For a complete list of command options and usage information, see the PDK command reference.

Usage

Create a virtual machine and subnet

Create an Ubuntu server v16.04:

aws_instances { your_vm:
  ensure             => 'present',
  image_id           => 'ami-c7e0c82c',
  min_count          => 1,
  max_count          => 1,
  key_name           => your-key-name,
  instance_type      => 't2.micro',
  subnet_id          => your-subnet-id,
  tag_specifications => [ { resource_type => "instance", tags => $tag } ]
}

Create a subnet:

aws_subnet{ your_subnet:
  name       => your_subnet,
  cidr_block => 10.9.12.0/24,
  vpc_id     => your_vpc_id,
  ensure     => present,
}

Run a task

Create a VPC:

bolt task run --nodes localhost amazon_aws::ec2_aws_create_vpc cidr_block=10.200.0.0/16

Examples

Note: Due to validation checks carried out by the Resource API, when running any example you receive a warning that states the provider returned data that did not match the Type schema for a specific resource. This warning message can be ignored. The warning is due to mismatched data between an object, and it's property.

In the examples directory you will find:

  • create_vm.pp to create a EC2 virtual machine.
  • create_subnet.pp to create a subnet for the virtual machine.
  • task_example.sh contains a number of sample tasks, each using Puppet Bolt:
    • create and describe Amazon VPCs.
    • create, list, describe, or delete an Amazon EKS cluster.
    • list or delete an AWS Storage Gateway.
    • create or list Amazon S3 buckets.

In the legacy examples directory are examples from the legacy module on how to create an infrastructure using this new module:

Reference

Resources