Setting up an Amazon AWS account

If you already have an AWS account, skip to the next section. Otherwise, you can follow these instructions to set up a new account and get the credentials you need to start building infrastructure with Puppet.

Creating an AWS account

Follow these steps to create a new AWS account:

  1. Browse to the following URL:

    https://aws.amazon.com/

  2. Click Sign In to the Console.
  3. Follow the instructions to create and verify your account.

To manage AWS resources using Puppet, we will create an additional AWS user account specifically for Puppet, using Amazon's Identiy and Access Management (IAM) framework. We'll see how to do this in the following sections.

Creating an IAM policy

Before we create the user account for Puppet, we need to grant specific permissions for the things it needs to do, such as read and create EC2 instances. This involves creating an IAM policy, which is a set of named permissions you can associate with a user account.

IAM policies are expressed as a JSON-format document. There is a policy JSON file in the example repo, named /examples/iam_policy.json. Open this file and copy the contents, ready to paste into your web browser.

Follow these steps to create the policy and associate it with the Puppet user:

  1. In the AWS console, select Services | IAM.
  2. Select Policies.
  3. Click Create Policy.
  4. On the Create Policy screen, select Create Your Own Policy.
  5. Enter Policy Name (for example, puppet).
  6. In the Policy Document textbox, paste the text you copied from the iam_policy.json file.
  7. Click Create Policy at the bottom to save this.
    Creating an IAM policy

Creating an IAM user

To create the Puppet IAM user and associate it with the policy, follow these steps:

  1. Sign in to the AWS console.
  2. Select Services | IAM | Users.
  3. Click Add user.
  4. Enter the username you want to use for this account (for example, puppet).
  5. In the Access type section, select Programmatic access.
    Creating an IAM user
  6. Click Next: Permissions.
  7. Create Attach existing policies directly.
  8. Type puppet in the Policy Type search box and press Enter.
    Creating an IAM user
  9. You should see the policy we created in the previous section, so check the box next to it and click Next: Review.
  10. Check that the settings are correct and click on Create user.

When you finish creating the IAM user and policy, you should see the Success screen, which lists your access credentials. Copy the access key ID and the secret access key (click Show to see the secret access key). You will need these credentials for the next steps (but keep them safe).

Storing your AWS credentials

Follow these steps to configure your VM for access to AWS with your newly-generated credentials:

  1. On your Vagrant VM, run the following command to create the directory to hold your credentials file:
    mkdir /home/ubuntu/.aws
    
  2. Create a file named /home/ubuntu/.aws/credentials with the following contents (substitute your Access Key ID and Secret Access Key values from the AWS console screen):
    [default]
    aws_access_key_id = AKIAINSZUVFYMBFDJCEQ
    aws_secret_access_key = pghia0r5/GjU7WEQj2Hr7Yr+MFkf+mqQdsBk0BQr

Tip

Creating the file manually is fine for this example, but for production use, you should manage the credentials file with Puppet using encrypted Hiera data, as shown in the Managing secret data section in Chapter 6, Managing data with Hiera.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.241.51