In the following sections, we'll see how to generate an SSH key pair to connect to your EC2 instances, and also install the puppetlabs/aws
module with its dependencies.
You'll need an SSH key pair in order to connect to any EC2 instances you create. We will generate and download your key pair in this section.
pbg
for this example.pbg.pem
will be automatically downloaded by your browser. Move this file to your ~/.ssh
directory on your own computer (or copy it to the ubuntu
user's ~/.ssh
directory on the Vagrant VM, if you'd rather access your AWS instances from there).chmod 600 ~/.ssh/pbg.pem
Follow these steps to install the puppetlabs/aws
module:
If you've already set up the r10k
module management tool, as shown in Chapter 7, Mastering modules, the required module will already be installed. If not, run the following commands to install it:
cd /etc/puppetlabs/code/environments/pbg sudo r10k puppetfile install
The
puppetlabs/aws
module requires a couple of gems, which we can install easily using Puppet, with the following manifest (aws_sdk.pp
):
ensure_packages([ 'aws-sdk-core', 'retries' ], { provider => puppet_gem })
Notice the provider => puppet_gem
in that example? You might remember from Chapter 4, Understanding Puppet resources, that puppet_gem
installs a Ruby gem in Puppet's context (as opposed to the system Ruby context, which is completely separate). Gems which are required by Puppet modules need to be installed in this way or Puppet won't be able to load them.
sudo puppet apply --environment pbg /examples/aws_sdk.pp
/home/ubuntu/.aws/config
file with the following contents:[default] region=us-east-1
3.138.110.105