Amazon AWS
Table of contents
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 API documentation.
Setup
Installing the module
- Install the retries gem, facets 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 facets
- 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
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
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.