Back to .md Directory

Packerizing your config

1. Install packer [here](https://www.packer.io/downloads).

May 2, 2026
0 downloads
0 views
ai rag
View source

Packerizing your config

  1. Install packer here.
  2. Read up on the docs for your cloud/platform/stack (we're using AWS here).
  3. You can use what's in this directory to get started!

Set up authentication

You'll need API access to your amazon account. To get this set up, log into your AWS Admin Console and navigate to: - IAM - Users - "Add Users" and pick a username - Select AWS Credential Type: "Access key - Programmatic access" - "Next - Permissions" -- add fine-grained permissions here, "Attach policies directly" and attaching AdministratorAccess will work, but it's not particularly safe or best practice. - After creating the IAM User, copy the "AWS Access Key ID" and "Secret Access key" that's displayed. The secret key will only be shown this once, so store it safely!

Export those keys in the shell where you'll be running packer commands, and you'll be good to go:

export AWS_ACCESS_KEY_ID="<YOUR_AWS_ACCESS_KEY_ID>"
export AWS_SECRET_ACCESS_KEY="<YOUR_AWS_SECRET_ACCESS_KEY>"

Run Packer

packer init .

# Format your packer code, if you've changed my example around
packer fmt .
packer validate .

Now you can build your AMI!

packer build wordpress-aws-ubuntu.pkr.hcl

Write down important output

This is an ugly hack which I made to keep things simple and easy to follow:

  • The autogenerated mysql password is echoed out to the shell AND written into /etc/packer-setup.log by default.

Use your instance!

  • Go to your AMIs -- they're region specific, so make sure your packer builder region and the one your're looking at in your AWS Console are the same.
  • Select the AMI you just built and click "Launch instance from AMI"
  • Configure EC2 Instance options like your SSH key and how big the storage volume should be
  • Launch the instance and wait for it to boot.
  • Grab your instance's public IP (click on the instance, then select the "networking" tab and look for "Public IPv4 address")
  • Connect via SSH! (username is ubuntu)

ssh ubuntu@yourInstanceIPAddress

Check out your webite!

Open the WordPress Installer in your Browser http://example.com/wp-admin/setup-config.php

Debugging

If you run into any errors after making modifications to this script, debug them! That's where all the learning really happens, anyway. Here are some resources:

TODO

  • get vars into the config files (they've got tutorialinux hardcoded in them)
  • compare and tune php.ini
  • mysql server root password and mysql_secure_installation
  • occasional failure to find mysql server... ==> packer-wordpress-tutorialinux-aws.amazon-ebs.ubuntu: E: Unable to locate package mysql-server

Basics Course

  • see this readme
  • decompose hands-on course scripts into scriptable chunks
  • base setup script (apt installs)
  • discuss MANUAL steps -- why are they manual? Can we automate or defer them?
    • noninteractive mysql install?
  • add vars to make it more configurable
  • config file templating using packer vars

Related Documents