Skip to content

dod-iac/terraform-aws-image-builder-infrastructure-configuration

Repository files navigation

Usage

Creates an infrastructure configuration for EC2 Image Builder.

module "image_builder_instance_role" {
  source  = "dod-iac/ec2-instance-role/aws"
  version = "1.0.2"

  allow_image_builder = true
  name                = format("app-%s-image-builder-instance-role-%s", var.application, var.environment)
}

resource "aws_iam_instance_profile" "image_builder_instance_role" {
  name = module.image_builder_instance_role.name
  role = module.image_builder_instance_role.name
}

module "image_builder_infrastructure_configuration" {
  source = "dod-iac/image-builder-infrastructure-configuration/aws"

  iam_instance_profile_name     = aws_iam_instance_profile.image_builder_instance_role.name
  logging_bucket                = var.logging_bucket
  name                          = format("app-%s-%s", var.application, var.environment)
  subnet_id                     = coalesce(var.subnet_ids...)
  vpc_id                        = var.vpc_id
}

Terraform Version

Terraform 0.13. Pin module version to ~> 1.0.0 . Submit pull-requests to main branch.

Terraform 0.11 and 0.12 are not supported.

License

This project constitutes a work of the United States Government and is not subject to domestic copyright protection under 17 USC § 105. However, because the project utilizes code licensed from contributors and other third parties, it therefore is licensed under the MIT License. See LICENSE file for more information.

Requirements

Name Version
terraform >= 0.13
aws >= 3.0, < 5.0

Providers

Name Version
aws >= 3.0, < 5.0

Modules

No modules.

Resources

Name Type
aws_imagebuilder_infrastructure_configuration.main resource
aws_security_group.main resource

Inputs

Name Description Type Default Required
description n/a string "An infrastructure configuration for EC2 Image Builder." no
iam_instance_profile_name The name of the IAM instance profile used when building images. string n/a yes
instance_types The list of EC2 instance types to build. list(string)
[
"t3.small"
]
no
key_name Name of EC2 key pair used to connect to the instances. string "" no
logging_bucket The name of the bucket that will receive the log objects. string "" no
logging_prefix The key prefix to use when logging. Defaults to "imagebuilder/[NAME]/" if not specified. string "" no
name The name of the infrastructure configuration. string n/a yes
sns_topic_arn The ARN of the SNS topic receiving notifications during builds. string "" no
subnet_id The ID of the VPC subnet used when building images. string n/a yes
tags The tags to apply to the infrastructure configuration. map(string) {} no
terminate_instance_on_failure Enable if the instance should be terminated when the pipeline fails. bool true no
vpc_id The ID of the VPC used when building images. string n/a yes

Outputs

Name Description
arn The ARN of the EC2 Image Builder infrastructure configuration.