Git Product home page Git Product logo

terraform-aws-images's Introduction

AWS AMI image builder module

Terraform module which creates Amazon Machine Images on AWS with the help of packer

Prerequisites

This module uses a few tools that need to be installed locally

Features

This module integrates packer with terraform by running packer a part of a local provisioner script.

The packer config format (json) does not support commenting, complex interpolation etc., so that maintaining, updating and versioning packer builds can be a challenge. This module converts its own image configuration format (terraform variables) to packer templates.

Currently only the AMI Builder (EBS backed) is supported.

The config format used by this module is a list of image groups. Each image group uses the same set of provisioners
(https://www.packer.io/docs/provisioners/index.html) to configure the images defined within that group, while currently only file and shell provisioners are supported. Each image config uses the same parameters as the EBS builder, while credentials and AMI permissions are handled automatically and wont have to be set for each individual image.

While the list of image groups is a flat list, a hierarchy of dependent images is maintained using the source_ami_name parameter on each image config. With the help of this parameter, a DAG is created, from which only branches with no interdependency will result in an image build. In other words: If an image A depends on image B, and image B needs to be upgraded, image A will not be considered to be built unless the dependent image reached its desired version.

Usage

module "images" {
  source = "janschumann/terraform-aws-images"

  default_allowed_accounts = [
    "1234567890",
    "0123456789"
  ]

  images              = [{
    name = "base"
    provisioners = [{
        type = "shell"
        scripts = [
          "./scripts/base.sh",
        ]
    }],
    images = [{
        name            = "my-aws-linux"
        description     = "my aws linux base image"
        source_ami_name = "aws-linux"
        source_ami_user = "ec2-user"
    }]
  }]
}

Requirements

Name Version
terraform >= 0.12
aws ~> 2.7
external ~> 1.0
local ~> 1.0

Inputs

Name Description Type Default Required
builder_credentials The credentials to use to build the AMI map(string) {} no
debug Only create packer build files bool false no
default_allowed_accounts A list of account ids to allow images access to by default list(string) [] no
default_builder_config The default builder config. map(any) {} no
image_versions_path Path to a json file that contains the image versions as a map of strings. string "./versions.json" no
images A list of maps describing the images to build any n/a yes
jq_executeable Path to the jq executable string "/usr/bin/env jq" no
packer_executeable Path to the packer executable string "/usr/bin/env packer" no
python_executeable Path to the python executable to execute the packerize script with. Make sure to install all requirements in requirements.txt string "/usr/bin/env python" no
source_images A list of source images. By default the latest aws-linux image is referenced
list(object({
name = string,
description = string,
owner = string,
search_pattern = string
}))
[
{
"description": "aws linux 2",
"name": "aws-linux",
"owner": "137112412989",
"search_pattern": "amzn2-ami-hvm-*-x86_64-ebs"
}
]
no

Outputs

Name Description
latest The list of the latest versions of the resulting amis
source_images The list of current source amis

Authors

Module managed by Jan Schumann.

License

Apache 2 Licensed. See LICENSE for full details.

terraform-aws-images's People

Contributors

janschumann avatar this-chris avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.