From b09915e9db430b079f71c384d01c5d7693a3f489 Mon Sep 17 00:00:00 2001 From: Simone Ferraro Date: Wed, 20 Jul 2022 12:23:27 +0200 Subject: [PATCH 1/8] feat: initial draft #1 --- .gitignore | 32 +++++++ main.tf | 178 +++++++++++++++++++++++++++++++++++++ outputs.tf | 69 +++++++++++++++ variables.tf | 243 +++++++++++++++++++++++++++++++++++++++++++++++++++ versions.tf | 10 +++ 5 files changed, 532 insertions(+) create mode 100644 .gitignore create mode 100644 main.tf create mode 100644 outputs.tf create mode 100644 variables.tf create mode 100644 versions.tf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..08054b7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,32 @@ +# Local .terraform directories +**/.terraform/* + +# .tfstate files +*.tfstate +*.tfstate.* + +# Crash log files +crash.log + +# Ignore any .tfvars files that are generated automatically for each Terraform run. Most +# .tfvars files are managed as part of configuration and so should be included in +# version control. +# +# example.tfvars + +# Ignore override files as they are usually used to override resources locally and so +# are not checked in +override.tf +override.tf.json +*_override.tf +*_override.tf.json + +# Include override files you do wish to add to version control using negated pattern +# +# !example_override.tf + +# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan +# example: *tfplan* + +# Terraform Provider lock file +.terraform.lock.hcl \ No newline at end of file diff --git a/main.tf b/main.tf new file mode 100644 index 0000000..4261619 --- /dev/null +++ b/main.tf @@ -0,0 +1,178 @@ +locals { + create = var.create +} + +resource "aws_imagebuilder_component" "this" { + for_each = { for component in var.components : component.name => component } + + data = lookup(each.value, "data", null) + uri = lookup(each.value, "uri", null) + name = each.key + description = each.value.description + version = each.value.version + platform = lookup(each.value, "platform", "Linux") + supported_os_versions = lookup(each.value, "supported_os_versions", null) + kms_key_id = lookup(each.value, "kms_key_id", null) + tags = lookup(each.value, "tags", null) +} + +resource "aws_imagebuilder_image_recipe" "this" { + count = local.create && var.create_image_recipe ? 1 : 0 + + name = var.name + parent_image = var.image_recipe_parent_image + version = var.image_recipe_version + + dynamic "block_device_mapping" { + for_each = var.block_device_mapping + content { + device_name = lookup(block_device_mapping.value, "device_name", "/dev/xvdb") + no_device = lookup(block_device_mapping.value, "no_device", null) + virtual_name = lookup(block_device_mapping.value, "virtual_name", null) + + dynamic "ebs" { + for_each = var.ebs + content { + delete_on_termination = lookup(block_device_mapping.value, "delete_on_termination", null) + iops = lookup(block_device_mapping.value, "iops", null) + volume_size = lookup(block_device_mapping.value, "volume_size", null) + volume_type = lookup(block_device_mapping.value, "volume_type", null) + encrypted = lookup(block_device_mapping.value, "encrypted", null) + kms_key_id = lookup(block_device_mapping.value, "kms_key_id", null) + } + } + } + } + + dynamic "component" { + for_each = { for component in var.components : component.name => component } + content { + component_arn = aws_imagebuilder_component.this[component.name].arn + + dynamic "parameter" { + for_each = [for parameter in try(component.parameters, []) : parameter] + content { + name = parameter.key + value = parameter.value + } + } + } + } + + tags = merge({ "Name" = var.name }, var.tags) +} + +resource "aws_imagebuilder_infrastructure_configuration" "this" { + count = local.create && var.create_infrastructure_configuration ? 1 : 0 + + name = var.name + description = var.infrastructure_configuration_description + instance_profile_name = var.infrastructure_configuration_instance_profile_name + instance_types = var.infrastructure_configuration_instance_types + key_pair = var.infrastructure_configuration_key_pair + security_group_ids = var.infrastructure_configuration_security_group_ids + sns_topic_arn = var.infrastructure_configuration_sns_topic_arn + subnet_id = var.infrastructure_configuration_subnet_id + terminate_instance_on_failure = var.infrastructure_configuration_terminate_instance_on_failure + + logging { + dynamic "s3_logs" { + for_each = var.infrastructure_configuration_s3_logs_enabled ? [1] : [] + content { + s3_bucket_name = var.infrastructure_configuration_s3_bucket_name + s3_key_prefix = var.infrastructure_configuration_s3_key_prefix + } + } + } + + resource_tags = var.enable_resource_tags ? var.resource_tags : null + tags = merge({ "Name" = var.name }, var.tags) +} + +resource "aws_imagebuilder_distribution_configuration" "this" { + count = local.create && var.create_distribution_configuration ? 1 : 0 + + name = var.name + description = var.distribution_configuration_description + + distribution { + region = var.distribution_configuration_region + + dynamic "ami_distribution_configuration" { + for_each = var.ami_distribution_configuration + content { + name = lookup(ami_distribution_configuration.value, "name", null) + description = lookup(ami_distribution_configuration.value, "description", null) + kms_key_id = lookup(ami_distribution_configuration.value, "kms_key_id", null) + target_account_ids = lookup(ami_distribution_configuration.value, "target_account_ids", null) + ami_tags = lookup(ami_distribution_configuration.value, "ami_tags", null) + + dynamic "launch_permission" { + for_each = var.ami_distribution_configuration != null ? [var.launch_permission] : [] + content { + organization_arns = lookup(launch_permission.value, "organization_arns", null) + organizational_unit_arns = lookup(launch_permission.value, "organizational_unit_arns", null) + user_groups = lookup(launch_permission.value, "user_groups", null) + user_ids = lookup(launch_permission.value, "user_ids", null) + } + } + } + } + + dynamic "fast_launch_configuration" { + for_each = var.fast_launch_configuration + content { + account_id = lookup(fast_launch_configuration.value, "account_id", null) + enabled = lookup(fast_launch_configuration.value, "enabled", null) + max_parallel_launches = lookup(fast_launch_configuration.value, "max_parallel_launches", null) + + dynamic "launch_template" { + for_each = var.fast_launch_configuration != null ? [var.launch_template] : [] + content { + launch_template_id = lookup(launch_template.value, "launch_template_id", null) + launch_template_name = lookup(launch_template.value, "launch_template_name", null) + launch_template_version = lookup(launch_template.value, "launch_template_version", null) + } + } + } + } + + dynamic "launch_template_configuration" { + for_each = var.launch_template_configuration + content { + default = lookup(launch_template_configuration.value, "default", null) + account_id = lookup(launch_template_configuration.value, "account_id", null) + launch_template_id = lookup(launch_template_configuration.value, "launch_template_id", null) + } + } + + } + + tags = merge({ "Name" = var.name }, var.tags) +} + +resource "aws_imagebuilder_image_pipeline" "this" { + count = local.create && var.image_pipeline ? 1 : 0 + + name = var.name + description = var.image_pipeline_description + enhanced_image_metadata_enabled = var.image_pipeline_enhanced_image_metadata_enabled + status = var.image_pipeline_status + image_recipe_arn = var.image_recipe_arn != "" ? var.image_recipe_arn : aws_imagebuilder_image_recipe.this[0].arn + infrastructure_configuration_arn = var.infrastructure_configuration_arn != "" ? var.infrastructure_configuration_arn : aws_imagebuilder_infrastructure_configuration.this[0].arn + distribution_configuration_arn = var.distribution_configuration_arn != "" ? var.distribution_configuration_arn : aws_imagebuilder_distribution_configuration.this[0].arn + + dynamic "image_tests_configuration" { + for_each = var.image_tests_configuration + content { + image_tests_enabled = lookup(image_tests_configuration.value, "image_tests_enabled", null) + timeout_minutes = lookup(image_tests_configuration.value, "timeout_minutes", null) + } + } + + schedule { + schedule_expression = var.image_pipeline_schedule_expression + } + + tags = merge({ "Name" = var.name }, var.tags) +} \ No newline at end of file diff --git a/outputs.tf b/outputs.tf new file mode 100644 index 0000000..e866150 --- /dev/null +++ b/outputs.tf @@ -0,0 +1,69 @@ +output "component" { + description = "Map of Component" + value = aws_imagebuilder_component.this +} + +output "component_name" { + description = "List of Name of the component." + value = [for k, v in aws_imagebuilder_component.this : v.name] +} + +output "component_arn" { + description = "List of Arn of the component." + value = [for k, v in aws_imagebuilder_component.this : v.arn] +} + +output "image_recipe_name" { + description = "Name of the image recipe" + value = try(aws_imagebuilder_image_recipe.this[0].name, "") +} + +output "image_recipe_component" { + description = "Name of the image recipe" + value = try(aws_imagebuilder_image_recipe.this[0].component, "") +} + +output "image_recipe_arn" { + description = "Amazon Resource Name (ARN) of the image recipe" + value = try(aws_imagebuilder_image_recipe.this[0].arn, "") +} + +output "image_recipe_owner" { + description = "Owner of the image recipe" + value = try(aws_imagebuilder_image_recipe.this[0].owner, "") +} + +output "infrastructure_configuration_name" { + description = "Name of the infrastructure configuration" + value = try(aws_imagebuilder_infrastructure_configuration.this[0].name, "") +} + +output "infrastructure_configuration_arn" { + description = "arn of the infrastructure configuration" + value = try(aws_imagebuilder_infrastructure_configuration.this[0].arn, "") +} + +output "infrastructure_configuration_instance_profile_name" { + description = "Instance Profile name of the infrastructure configuration" + value = try(aws_imagebuilder_infrastructure_configuration.this[0].instance_profile_name, "") +} + +output "infrastructure_configuration_instance_types" { + description = "Instance Types of the infrastructure configuration" + value = try(aws_imagebuilder_infrastructure_configuration.this[0].instance_types, "") +} + +output "distribution_configuration_name" { + description = "Name of the distribution configuration" + value = try(aws_imagebuilder_distribution_configuration.this[0].name, "") +} + +output "image_pipeline_name" { + description = "Name of the image pipeline" + value = try(aws_imagebuilder_image_pipeline.this[0].name, "") +} + +output "image_pipeline_arn" { + description = "Arn of the image pipeline" + value = try(aws_imagebuilder_image_pipeline.this[0].arn, "") +} \ No newline at end of file diff --git a/variables.tf b/variables.tf new file mode 100644 index 0000000..f2d4009 --- /dev/null +++ b/variables.tf @@ -0,0 +1,243 @@ +variable "create" { + description = "Controls whether resources should be created" + type = bool + default = true +} + +variable "name" { + description = "Generic resource name" + type = string +} + +variable "components" { + description = "Image Builder Component" + type = map(string) + default = {} +} + +variable "create_image_recipe" { + description = "Controls whether resources should be created" + type = bool + default = true +} + +variable "image_recipe_parent_image" { + description = "Platform of the image recipe" + type = string +} + +variable "image_recipe_version" { + description = "Version of the image recipe" + type = number +} + +variable "block_device_mapping" { + description = "Configuration block(s) with block device mappings for the image recipe. Detailed below" + type = list(map(string)) + nullable = true + default = [] +} + +variable "ebs" { + description = "Configuration block with Elastic Block Storage (EBS) block device mapping settings" + type = list(map(string)) + nullable = true + default = [] +} + +variable "enable_resource_tags" { + description = "Whether to enable resource tags" + type = bool + default = false +} + +variable "resource_tags" { + description = "Key-value map of resource tags to assign to infrastructure created by the configuration" + type = map(string) + default = {} +} + +variable "create_infrastructure_configuration" { + description = "Controls whether resources should be created" + type = bool + default = true +} + +variable "infrastructure_configuration_description" { + description = "Description for the configuration" + type = string + default = null +} + +variable "infrastructure_configuration_instance_profile_name" { + description = "Name of IAM Instance Profile" + type = string +} + +variable "infrastructure_configuration_instance_types" { + description = "EC2 Instance Types" + type = list(string) + nullable = true + default = ["t3.nano", "t3.micro"] +} + +variable "infrastructure_configuration_key_pair" { + description = "Name of EC2 Key Pair" + type = string + default = null +} + +variable "infrastructure_configuration_security_group_ids" { + description = "EC2 Security Group identifiers" + type = list(string) + default = null +} + +variable "infrastructure_configuration_sns_topic_arn" { + description = "Amazon Resource Name (ARN) of SNS Topic" + type = string + default = null +} + +variable "infrastructure_configuration_subnet_id" { + description = "EC2 Subnet identifier. Also requires security_group_ids argument" + type = string + default = null +} + +variable "infrastructure_configuration_terminate_instance_on_failure" { + description = "Enable if the instance should be terminated when the pipeline fails" + type = bool + default = false +} + +variable "infrastructure_configuration_s3_logs_enabled" { + description = "Whether to enable s3 logs" + type = bool + default = false +} + +variable "infrastructure_configuration_s3_bucket_name" { + description = "Name of the S3 Bucket." + type = string + default = null +} + +variable "infrastructure_configuration_s3_key_prefix" { + description = "Prefix to use for S3 logs" + type = string + default = "/" +} + +variable "create_distribution_configuration" { + description = "Controls whether resources should be created" + type = bool + default = true +} + +variable "distribution_configuration_description" { + description = "Description of the distribution configuration" + type = string + default = null +} + +variable "distribution_configuration_kms_key_id" { + description = "Amazon Resource Name (ARN) of the Key Management Service (KMS) Key used to encrypt the distribution configuration" + type = string + default = null +} + +variable "distribution_configuration_region" { + description = "AWS Region for the distribution" + type = string +} + +variable "ami_distribution_configuration" { + description = "Configuration block with Amazon Machine Image (AMI) distribution settings" + type = map(string) + default = null +} + +variable "launch_permission" { + description = "Configuration block of EC2 launch permissions to apply to the distributed AMI" + type = map(string) + default = null +} + +variable "fast_launch_configuration" { + description = "Set of Windows faster-launching configurations to use for AMI distribution" + type = map(string) + default = null +} + +variable "launch_template" { + description = "Configuration block for the launch template that the fast-launch enabled Windows AMI uses when it launches Windows instances to create pre-provisioned snapshots" + type = map(string) + default = null +} + +variable "launch_template_configuration" { + description = "Set of launch template configuration settings that apply to image distribution" + type = map(string) + default = null +} + +variable "image_pipeline" { + description = "Controls whether resources should be created" + type = bool + default = true +} + +variable "image_pipeline_description" { + description = "Description of the image pipeline" + type = string + default = null +} + +variable "image_pipeline_enhanced_image_metadata_enabled" { + description = "Whether additional information about the image being created is collected" + type = bool + default = true +} + +variable "image_pipeline_status" { + description = "Status of the image pipeline,Valid values are DISABLED and ENABLED" + type = string + default = "ENABLED" +} + +variable "image_tests_configuration" { + description = "Configuration block with image tests configuration" + type = map(string) + default = null +} + +variable "image_pipeline_schedule_expression" { + description = "Cron expression of how often the pipeline start condition is evaluated" + type = string + default = null +} + +variable "image_recipe_arn" { + description = "Amazon Resource Name (ARN) of the image recipe" + type = string + default = null +} + +variable "infrastructure_configuration_arn" { + description = "mazon Resource Name (ARN) of the Image Builder Infrastructure Configuration" + type = string + default = null +} + +variable "distribution_configuration_arn" { + description = "Amazon Resource Name (ARN) of the Image Builder Distribution" + type = string + default = null +} + +variable "tags" { + description = "A mapping of tags to assign to the resource" + type = map(string) + default = {} +} \ No newline at end of file diff --git a/versions.tf b/versions.tf new file mode 100644 index 0000000..6b84a10 --- /dev/null +++ b/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 0.14.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 4.20" + } + } +} \ No newline at end of file From d46c784d48081e446a8f34d875d37dbf2035ca47 Mon Sep 17 00:00:00 2001 From: Simone Ferraro Date: Mon, 1 Aug 2022 09:51:09 +0200 Subject: [PATCH 2/8] fix: changes in the code following the tests done to the module. The code in the present resource block was changed without adding any new resources. --- main.tf | 70 ++++++++++++++++++++++++++++------------------------ variables.tf | 44 +++++++++++++++++++-------------- 2 files changed, 63 insertions(+), 51 deletions(-) diff --git a/main.tf b/main.tf index 4261619..f92e802 100644 --- a/main.tf +++ b/main.tf @@ -1,5 +1,5 @@ locals { - create = var.create + component_external_arns = [for external_arn in var.component_external_arns : { name = split("/", external_arn)[1], arn = external_arn }] } resource "aws_imagebuilder_component" "this" { @@ -17,7 +17,7 @@ resource "aws_imagebuilder_component" "this" { } resource "aws_imagebuilder_image_recipe" "this" { - count = local.create && var.create_image_recipe ? 1 : 0 + count = var.create_image_recipe ? 1 : 0 name = var.name parent_image = var.image_recipe_parent_image @@ -26,12 +26,13 @@ resource "aws_imagebuilder_image_recipe" "this" { dynamic "block_device_mapping" { for_each = var.block_device_mapping content { - device_name = lookup(block_device_mapping.value, "device_name", "/dev/xvdb") + device_name = lookup(block_device_mapping.value, "device_name", null) no_device = lookup(block_device_mapping.value, "no_device", null) virtual_name = lookup(block_device_mapping.value, "virtual_name", null) dynamic "ebs" { - for_each = var.ebs + for_each = var.block_device_mapping + content { delete_on_termination = lookup(block_device_mapping.value, "delete_on_termination", null) iops = lookup(block_device_mapping.value, "iops", null) @@ -45,12 +46,12 @@ resource "aws_imagebuilder_image_recipe" "this" { } dynamic "component" { - for_each = { for component in var.components : component.name => component } + for_each = { for component in concat(local.component_external_arns, var.components) : component.name => component } content { - component_arn = aws_imagebuilder_component.this[component.name].arn + component_arn = try(aws_imagebuilder_component.this[component.value["name"]].arn, component.value["arn"]) dynamic "parameter" { - for_each = [for parameter in try(component.parameters, []) : parameter] + for_each = { for name, value in lookup(component.value, "parameters", {}) : name => value } content { name = parameter.key value = parameter.value @@ -63,7 +64,7 @@ resource "aws_imagebuilder_image_recipe" "this" { } resource "aws_imagebuilder_infrastructure_configuration" "this" { - count = local.create && var.create_infrastructure_configuration ? 1 : 0 + count = var.create_infrastructure_configuration ? 1 : 0 name = var.name description = var.infrastructure_configuration_description @@ -75,10 +76,11 @@ resource "aws_imagebuilder_infrastructure_configuration" "this" { subnet_id = var.infrastructure_configuration_subnet_id terminate_instance_on_failure = var.infrastructure_configuration_terminate_instance_on_failure - logging { - dynamic "s3_logs" { - for_each = var.infrastructure_configuration_s3_logs_enabled ? [1] : [] - content { + dynamic "logging" { + for_each = var.infrastructure_configuration_s3_logs_enabled ? [1] : [] + + content { + s3_logs { s3_bucket_name = var.infrastructure_configuration_s3_bucket_name s3_key_prefix = var.infrastructure_configuration_s3_key_prefix } @@ -90,7 +92,7 @@ resource "aws_imagebuilder_infrastructure_configuration" "this" { } resource "aws_imagebuilder_distribution_configuration" "this" { - count = local.create && var.create_distribution_configuration ? 1 : 0 + count = var.create_distribution_configuration ? 1 : 0 name = var.name description = var.distribution_configuration_description @@ -99,21 +101,21 @@ resource "aws_imagebuilder_distribution_configuration" "this" { region = var.distribution_configuration_region dynamic "ami_distribution_configuration" { - for_each = var.ami_distribution_configuration + for_each = [var.ami_distribution_configuration] content { - name = lookup(ami_distribution_configuration.value, "name", null) + name = "${lookup(ami_distribution_configuration.value, "name", null)}-{{ imagebuilder:buildDate }}" description = lookup(ami_distribution_configuration.value, "description", null) kms_key_id = lookup(ami_distribution_configuration.value, "kms_key_id", null) - target_account_ids = lookup(ami_distribution_configuration.value, "target_account_ids", null) - ami_tags = lookup(ami_distribution_configuration.value, "ami_tags", null) + target_account_ids = try(ami_distribution_configuration.value["target_account_ids"], null) + ami_tags = lookup(ami_distribution_configuration.value, "ami_tags", {}) dynamic "launch_permission" { - for_each = var.ami_distribution_configuration != null ? [var.launch_permission] : [] + for_each = var.ami_distribution_configuration != "" ? [var.launch_permission] : [] content { - organization_arns = lookup(launch_permission.value, "organization_arns", null) - organizational_unit_arns = lookup(launch_permission.value, "organizational_unit_arns", null) - user_groups = lookup(launch_permission.value, "user_groups", null) - user_ids = lookup(launch_permission.value, "user_ids", null) + organization_arns = try(launch_permission.value["organization_arns"], []) + organizational_unit_arns = try(launch_permission.value["organizational_unit_arns"], []) + user_groups = try(launch_permission.value["user_groups"], []) + user_ids = try(launch_permission.value["user_ids"], []) } } } @@ -129,20 +131,20 @@ resource "aws_imagebuilder_distribution_configuration" "this" { dynamic "launch_template" { for_each = var.fast_launch_configuration != null ? [var.launch_template] : [] content { - launch_template_id = lookup(launch_template.value, "launch_template_id", null) - launch_template_name = lookup(launch_template.value, "launch_template_name", null) - launch_template_version = lookup(launch_template.value, "launch_template_version", null) + launch_template_id = try(launch_template.value["launch_template_id"], []) + launch_template_name = try(launch_template.value["launch_template_name"], []) + launch_template_version = try(launch_template.value["launch_template_version"], []) } } } } dynamic "launch_template_configuration" { - for_each = var.launch_template_configuration + for_each = var.launch_template_configuration != null ? [var.launch_template_configuration] : [] content { - default = lookup(launch_template_configuration.value, "default", null) - account_id = lookup(launch_template_configuration.value, "account_id", null) - launch_template_id = lookup(launch_template_configuration.value, "launch_template_id", null) + default = try(launch_template_configuration.value["default"], null) + account_id = try(launch_template_configuration.value["account_id"], null) + launch_template_id = try(launch_template_configuration.value["launch_template_id"], null) } } @@ -152,7 +154,7 @@ resource "aws_imagebuilder_distribution_configuration" "this" { } resource "aws_imagebuilder_image_pipeline" "this" { - count = local.create && var.image_pipeline ? 1 : 0 + count = var.image_pipeline ? 1 : 0 name = var.name description = var.image_pipeline_description @@ -170,8 +172,12 @@ resource "aws_imagebuilder_image_pipeline" "this" { } } - schedule { - schedule_expression = var.image_pipeline_schedule_expression + dynamic "schedule" { + for_each = var.image_tests_configuration_schedule_enabled ? [1] : [] + + content { + schedule_expression = var.image_tests_configuration_schedule_expression + } } tags = merge({ "Name" = var.name }, var.tags) diff --git a/variables.tf b/variables.tf index f2d4009..805227e 100644 --- a/variables.tf +++ b/variables.tf @@ -1,9 +1,3 @@ -variable "create" { - description = "Controls whether resources should be created" - type = bool - default = true -} - variable "name" { description = "Generic resource name" type = string @@ -11,7 +5,7 @@ variable "name" { variable "components" { description = "Image Builder Component" - type = map(string) + type = any default = {} } @@ -28,7 +22,7 @@ variable "image_recipe_parent_image" { variable "image_recipe_version" { description = "Version of the image recipe" - type = number + type = string } variable "block_device_mapping" { @@ -38,6 +32,12 @@ variable "block_device_mapping" { default = [] } +variable "component_external_arns" { + description = "" + type = list(string) + default = [] +} + variable "ebs" { description = "Configuration block with Elastic Block Storage (EBS) block device mapping settings" type = list(map(string)) @@ -126,7 +126,7 @@ variable "infrastructure_configuration_s3_bucket_name" { variable "infrastructure_configuration_s3_key_prefix" { description = "Prefix to use for S3 logs" type = string - default = "/" + default = null } variable "create_distribution_configuration" { @@ -154,20 +154,20 @@ variable "distribution_configuration_region" { variable "ami_distribution_configuration" { description = "Configuration block with Amazon Machine Image (AMI) distribution settings" - type = map(string) - default = null + type = any + default = {} } variable "launch_permission" { description = "Configuration block of EC2 launch permissions to apply to the distributed AMI" - type = map(string) - default = null + type = map(list(string)) + default = {} } variable "fast_launch_configuration" { description = "Set of Windows faster-launching configurations to use for AMI distribution" type = map(string) - default = null + default = {} } variable "launch_template" { @@ -209,10 +209,16 @@ variable "image_pipeline_status" { variable "image_tests_configuration" { description = "Configuration block with image tests configuration" type = map(string) - default = null + default = {} } -variable "image_pipeline_schedule_expression" { +variable "image_tests_configuration_schedule_enabled" { + description = "Whether to enable schedule expression" + type = bool + default = false +} + +variable "image_tests_configuration_schedule_expression" { description = "Cron expression of how often the pipeline start condition is evaluated" type = string default = null @@ -221,19 +227,19 @@ variable "image_pipeline_schedule_expression" { variable "image_recipe_arn" { description = "Amazon Resource Name (ARN) of the image recipe" type = string - default = null + default = "" } variable "infrastructure_configuration_arn" { description = "mazon Resource Name (ARN) of the Image Builder Infrastructure Configuration" type = string - default = null + default = "" } variable "distribution_configuration_arn" { description = "Amazon Resource Name (ARN) of the Image Builder Distribution" type = string - default = null + default = "" } variable "tags" { From e9aa8b256eee2bc64d4601632015a1e17eaf61e6 Mon Sep 17 00:00:00 2001 From: Simone Ferraro Date: Mon, 1 Aug 2022 16:15:48 +0200 Subject: [PATCH 3/8] fix: change the description of the output component_name and component_arn --- outputs.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/outputs.tf b/outputs.tf index e866150..af1f673 100644 --- a/outputs.tf +++ b/outputs.tf @@ -4,12 +4,12 @@ output "component" { } output "component_name" { - description = "List of Name of the component." + description = "List of Name of the component" value = [for k, v in aws_imagebuilder_component.this : v.name] } output "component_arn" { - description = "List of Arn of the component." + description = "List of Arn of the component" value = [for k, v in aws_imagebuilder_component.this : v.arn] } From cb602bc989b040c644a0a5de08e8b5b64d7ec593 Mon Sep 17 00:00:00 2001 From: Simone Ferraro Date: Mon, 1 Aug 2022 16:21:43 +0200 Subject: [PATCH 4/8] feat(examples): add of the complete example --- examples/complete/README.md | 70 +++++++++++++++++ examples/complete/data.tf | 1 + examples/complete/locals.tf | 6 ++ examples/complete/main.tf | 140 +++++++++++++++++++++++++++++++++ examples/complete/outputs.tf | 34 ++++++++ examples/complete/variables.tf | 27 +++++++ examples/complete/versions.tf | 18 +++++ 7 files changed, 296 insertions(+) create mode 100644 examples/complete/README.md create mode 100644 examples/complete/data.tf create mode 100644 examples/complete/locals.tf create mode 100644 examples/complete/main.tf create mode 100644 examples/complete/outputs.tf create mode 100644 examples/complete/variables.tf create mode 100644 examples/complete/versions.tf diff --git a/examples/complete/README.md b/examples/complete/README.md new file mode 100644 index 0000000..08f7a21 --- /dev/null +++ b/examples/complete/README.md @@ -0,0 +1,70 @@ +# EC2-Image-Builder + +This example will manage the creation of EC2 Image builder with the creation of an iam role and Bucket S3 for logs. + +## Usage + +To run this example, you need to execute the following commands: + +```shell +$ terraform init +$ terraform plan +$ terraform apply +``` + +:memo: **Note:** You will need a Terraform Cloud/Enterprise API token for authentication. +You'll be prompted to insert it to provide a value for "tfc_token" variable. +See [here](https://www.terraform.io/cloud-docs/users-teams-organizations/api-tokens) +for further information. + +:memo: **Note:** This root modules defines other several sensitive variables. +You'll be prompted to insert the required values by default on every "plan" and "apply" action +Choose the appropriate method to automatically specify these values, like described [here](https://www.terraform.io/language/values/variables#assigning-values-to-root-module-variables) + +:warning: **Warning:** This example may create resources that cost money. Execute the command +`terraform destroy` when the resources are no longer needed. + + +## Requirements + +| Name | Version | +|---------------------------------------------------------------------------|----------| +| [terraform](#requirement\_terraform) | ~> 1.1.0 | +| [aws](#requirement\aws) | ~> 4.4 | + +## Providers + +No providers. + +## Modules + +| Name | Source | Version | +|---------------------------------------------------------------------------------------|--------|---------| +| [imagebuilder](#module\_advanced\_workspace) | ../../ | n/a | + +## Resources + +No resources. + +## Inputs + +| Name | Description | Type | Default | Required | +|--------------------------------------------------------------------------------------------|----------------------------------------------------------|----------------|---------|:--------:| +| [region](#input\_region) | Region where resources are created | `string` | n/a | yes | +| [name](#input\_name) | Generic resource name | `string` | n/a | yes | +| [account\_id](#account\_id) | The account ID used in the launch template configuration | `string` | n/a | yes | +| [launch\_template\_id](#ilaunch\_template\_id) | The ID of the Amazon EC2 launch template to use | `list(string)` | n/a | yes | +| [user\_ids](#iuser\_ids) | Set of AWS Account user in the launch_permission | `string` | n/a | yes | + +## Outputs + +| Name | Description | +|------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------| +| [component](#output\_component) | Map of Component | +| [component\_name](#output\_component\_name) | List of Name of the component | +| [component\_arn](#output\_component\_arn) | List of Arn of the component | +| [image\_recipe\_arn](#output\_image\_recipe\_arn) | Amazon Resource Name (ARN) of the image recipe | +| [infrastructure\_configuration\_arn](#output\_infrastructure\_configuration\_arn) | arn of the infrastructure configuration | +| [distribution\_configuration\_name](#output\_distribution\_configuration\_name) | Name of the distribution configuration | +| [image\_pipeline\_arn](#output\_image\_pipeline\_arn) | Name of the distribution configuration | + \ No newline at end of file diff --git a/examples/complete/data.tf b/examples/complete/data.tf new file mode 100644 index 0000000..d9adb62 --- /dev/null +++ b/examples/complete/data.tf @@ -0,0 +1 @@ +data "aws_partition" "current" {} \ No newline at end of file diff --git a/examples/complete/locals.tf b/examples/complete/locals.tf new file mode 100644 index 0000000..6ada097 --- /dev/null +++ b/examples/complete/locals.tf @@ -0,0 +1,6 @@ +locals { + common_tags = { + Terraform = true + Project = var.name + } +} \ No newline at end of file diff --git a/examples/complete/main.tf b/examples/complete/main.tf new file mode 100644 index 0000000..ee85795 --- /dev/null +++ b/examples/complete/main.tf @@ -0,0 +1,140 @@ +################################################################################ +# Role IAM for EC2-Image-Builder Module +################################################################################ +resource "aws_iam_role" "iam_role" { + name = var.name + path = "/${var.name}/" + + assume_role_policy = < Date: Thu, 4 Aug 2022 10:17:26 +0200 Subject: [PATCH 5/8] fix (terraform version) change terraform required version --- versions.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/versions.tf b/versions.tf index 6b84a10..d2a49a0 100644 --- a/versions.tf +++ b/versions.tf @@ -1,5 +1,5 @@ terraform { - required_version = ">= 0.14.0" + required_version = ">= 1.1.0" required_providers { aws = { From 3ba92cd5752f342733467b2aeb40656ae5e7d428 Mon Sep 17 00:00:00 2001 From: Simone Ferraro Date: Thu, 4 Aug 2022 16:43:02 +0200 Subject: [PATCH 6/8] fix (examples): in the variables in the main and in the README.md - Added new variables in README.md and revised descriptions - variables.tf changed the description of the variables and added the variable launch_template_id_2 - main.tf changed the code of the module - versions.tf changed the terraform required version and required providers --- examples/complete/README.md | 32 +++++++++++++++++++++----------- examples/complete/main.tf | 16 +++++++++++----- examples/complete/variables.tf | 10 ++++++++-- examples/complete/versions.tf | 4 ++-- 4 files changed, 42 insertions(+), 20 deletions(-) diff --git a/examples/complete/README.md b/examples/complete/README.md index 08f7a21..3ee8fc2 100644 --- a/examples/complete/README.md +++ b/examples/complete/README.md @@ -29,12 +29,14 @@ Choose the appropriate method to automatically specify these values, like descri | Name | Version | |---------------------------------------------------------------------------|----------| -| [terraform](#requirement\_terraform) | ~> 1.1.0 | -| [aws](#requirement\aws) | ~> 4.4 | +| [terraform](#requirement\_terraform) | >= 1.1.0 | +| [aws](#requirement\aws) | >= 4.20 | ## Providers -No providers. +| Name | Version | +|---------------------------------------------------|---------| +| [aws](#provider\_aws) | >= 4.20 | ## Modules @@ -44,17 +46,25 @@ No providers. ## Resources -No resources. +| Name | Type | +|------------------------------------------------------------------------------------------------------------------------------------------------------------|----------| +| [aws_iam_role.iam_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource | +| [aws_iam_instance_profile.istance_profile](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_account_alias) | resource | +| [aws_iam_role_policy_attachment.policy_attachment](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_instance_profile) | resource | +| [aws_s3_bucket.bucket_logs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket) | resource | +| [aws_s3_bucket_public_access_block.bucket_logs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_public_access_block) | resource | +| [aws_s3_bucket_acl.bucket_logs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_acl) | resource | ## Inputs -| Name | Description | Type | Default | Required | -|--------------------------------------------------------------------------------------------|----------------------------------------------------------|----------------|---------|:--------:| -| [region](#input\_region) | Region where resources are created | `string` | n/a | yes | -| [name](#input\_name) | Generic resource name | `string` | n/a | yes | -| [account\_id](#account\_id) | The account ID used in the launch template configuration | `string` | n/a | yes | -| [launch\_template\_id](#ilaunch\_template\_id) | The ID of the Amazon EC2 launch template to use | `list(string)` | n/a | yes | -| [user\_ids](#iuser\_ids) | Set of AWS Account user in the launch_permission | `string` | n/a | yes | +| Name | Description | Type | Default | Required | +|------------------------------------------------------------------------------------------|----------------------------------------------------------|----------|---------|:--------:| +| [region](#input\_region) | Region where resources are created | `string` | `n/a` | yes | +| [name](#input\_name) | Generic resource name | `string` | `n/a` | yes | +| [account\_id](#account\_id) | The account ID used in the launch template configuration | `string` | `n/a` | yes | +| [launch\_template\_id\_1](#ilaunch\_template\_id\_1) | The ID of the Amazon EC2 launch template one | `string` | `n/a` | yes | +| [launch\_template\_id\_2](#ilaunch\_template\_id\_2) | The ID of the Amazon EC2 launch template two | `string` | `n/a` | yes | +| [user\_ids](#iuser\_ids) | Set of AWS Account user in the launch_permission | `string` | `n/a` | yes | ## Outputs diff --git a/examples/complete/main.tf b/examples/complete/main.tf index ee85795..a1b9684 100644 --- a/examples/complete/main.tf +++ b/examples/complete/main.tf @@ -118,7 +118,7 @@ module "imagebuilder" { distribution_configuration_region = var.region ami_distribution_configuration = { - name = "image" + name = var.name ami_tags = { CostCenter = "IT" @@ -130,10 +130,16 @@ module "imagebuilder" { user_ids = var.user_ids } - launch_template_configuration = { - launch_template_id = var.launch_template_id - account_id = var.account_id - } + launch_template_configuration = [ + { + launch_template_id = var.launch_template_id_1 + account_id = var.account_id + }, + { + launch_template_id = var.launch_template_id_2 + account_id = var.account_id + } + ] image_tests_configuration_schedule_enabled = true image_tests_configuration_schedule_expression = "cron(0 0 * * ? *)" diff --git a/examples/complete/variables.tf b/examples/complete/variables.tf index c4380f0..6d3dc7d 100644 --- a/examples/complete/variables.tf +++ b/examples/complete/variables.tf @@ -14,8 +14,14 @@ variable "account_id" { sensitive = true } -variable "launch_template_id" { - description = "The ID of the Amazon EC2 launch template to use" +variable "launch_template_id_1" { + description = "The ID of the Amazon EC2 launch template one" + type = string + sensitive = true +} + +variable "launch_template_id_2" { + description = "The ID of the Amazon EC2 launch template two" type = string sensitive = true } diff --git a/examples/complete/versions.tf b/examples/complete/versions.tf index 9ad3f83..3231892 100644 --- a/examples/complete/versions.tf +++ b/examples/complete/versions.tf @@ -1,10 +1,10 @@ terraform { - required_version = ">= 0.14.0" + required_version = ">= 1.1.0" required_providers { aws = { source = "hashicorp/aws" - version = ">= 4.20" + version = ">= 4.24" } } } From b92e6c8ed0ff171e87656936e27b8765c0769054 Mon Sep 17 00:00:00 2001 From: Simone Ferraro Date: Thu, 4 Aug 2022 17:04:35 +0200 Subject: [PATCH 7/8] fix (module): change file variables.tf, main.tf,version.tf and outputs.tf - variables.tf changed the description and type - outputs.tf changed the descriptyion - main.tf changed the code of the module - versions.tf changed the terraform required version and required providers --- main.tf | 2 +- outputs.tf | 2 +- variables.tf | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/main.tf b/main.tf index f92e802..46d215c 100644 --- a/main.tf +++ b/main.tf @@ -140,7 +140,7 @@ resource "aws_imagebuilder_distribution_configuration" "this" { } dynamic "launch_template_configuration" { - for_each = var.launch_template_configuration != null ? [var.launch_template_configuration] : [] + for_each = var.launch_template_configuration content { default = try(launch_template_configuration.value["default"], null) account_id = try(launch_template_configuration.value["account_id"], null) diff --git a/outputs.tf b/outputs.tf index af1f673..fcddbb4 100644 --- a/outputs.tf +++ b/outputs.tf @@ -39,7 +39,7 @@ output "infrastructure_configuration_name" { } output "infrastructure_configuration_arn" { - description = "arn of the infrastructure configuration" + description = "Arn of the infrastructure configuration" value = try(aws_imagebuilder_infrastructure_configuration.this[0].arn, "") } diff --git a/variables.tf b/variables.tf index 805227e..4bd3328 100644 --- a/variables.tf +++ b/variables.tf @@ -33,7 +33,7 @@ variable "block_device_mapping" { } variable "component_external_arns" { - description = "" + description = "Components created externally" type = list(string) default = [] } @@ -118,7 +118,7 @@ variable "infrastructure_configuration_s3_logs_enabled" { } variable "infrastructure_configuration_s3_bucket_name" { - description = "Name of the S3 Bucket." + description = "Name of the S3 Bucket" type = string default = null } @@ -178,8 +178,8 @@ variable "launch_template" { variable "launch_template_configuration" { description = "Set of launch template configuration settings that apply to image distribution" - type = map(string) - default = null + type = list(map(string)) + default = [] } variable "image_pipeline" { @@ -231,7 +231,7 @@ variable "image_recipe_arn" { } variable "infrastructure_configuration_arn" { - description = "mazon Resource Name (ARN) of the Image Builder Infrastructure Configuration" + description = "Amazon Resource Name (ARN) of the Image Builder Infrastructure Configuration" type = string default = "" } From 38c8adc5d069a0097a4753a48ff52d088fdc4695 Mon Sep 17 00:00:00 2001 From: Simone Ferraro Date: Thu, 4 Aug 2022 17:12:41 +0200 Subject: [PATCH 8/8] docs: add README.md --- README.md | 192 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 192 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..f2e1dc3 --- /dev/null +++ b/README.md @@ -0,0 +1,192 @@ +# EC2-Image-Builder +Terraform module that creates and manages an Amazon Machine Image (AMI) with EC2 Image Builder service. + +:warning: The module initially only manages the creation of AMIs and not Container Image. + +## Usage + +### Simple workspace with local run mode +``` +module "imagebuilder" { + source = "../../" + + name = var.name + + components = [ + { + "data" = yamlencode({ + phases = [ + { + name = "build" + steps = [ + { + action = "ExecuteBash" + inputs = { + commands = ["echo 'hello world'"] + } + name = "helloworld" + onFailure = "Continue" + } + ] + } + ] + schemaVersion = 1.0 + }), + "name" = "hello world", + "description" = "component hello world", + "version" = "1.0.0" + } + ] + + component_external_arns = ["arn:aws:imagebuilder:${var.region}:aws:component/amazon-cloudwatch-agent-linux/1.0.1/1"] + + image_recipe_parent_image = "arn:${data.aws_partition.current.partition}:imagebuilder:${var.region}:aws:image/ubuntu-server-20-lts-x86/2022.3.8" + image_recipe_version = "1.0.0" + + block_device_mapping = [ + { + device_name = "/dev/sda" + delete_on_termination = true + volume_size = 10 + volume_type = "gp3" + } + ] + + infrastructure_configuration_instance_profile_name = aws_iam_instance_profile.istance_profile.name + infrastructure_configuration_instance_types = ["t3.nano"] + + infrastructure_configuration_s3_logs_enabled = false + infrastructure_configuration_s3_bucket_name = aws_s3_bucket.bucket_logs.bucket + + enable_resource_tags = true + resource_tags = local.common_tags + + + distribution_configuration_region = var.region + + ami_distribution_configuration = { + name = var.name + + ami_tags = { + CostCenter = "IT" + } + + } + + launch_permission = { + user_ids = var.user_ids + } + + launch_template_configuration = [ + { + launch_template_id = var.launch_template_id_1 + account_id = var.account_id + }, + { + launch_template_id = var.launch_template_id_2 + account_id = var.account_id + } + ] + + image_tests_configuration_schedule_enabled = true + image_tests_configuration_schedule_expression = "cron(0 0 * * ? *)" +} +``` +## Examples + +- [Complete EC2-Image-Builder](https://github.com/flowingis/terraform-aws-imagebuilder/tree/master/examples/complete) + + +## Requirements + +| Name | Version | +|---------------------------------------------------------------------------|----------| +| [terraform](#requirement\_terraform) | >= 1.1.0 | +| [aws](#requirement\_aws) | >= 4.20 | + +## Providers + +| Name | Version | +|---------------------------------------------------|---------| +| [aws](#provider\_aws) | >= 4.20 | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------| +| [aws_imagebuilder_component.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/imagebuilder_component) | resource | +| [aws_imagebuilder_image_recipe.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/imagebuilder_image_recipe) | resource | +| [aws_imagebuilder_infrastructure_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/imagebuilder_infrastructure_configuration) | resource | +| [aws_imagebuilder_distribution_configurations.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/imagebuilder_distribution_configuration) | resource | +| [aws_imagebuilder_image_pipeline.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/imagebuilder_image_pipeline) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------|---------------------------|:--------:| +| [name](#input\_name) | Generic resource name | `string` | `n/a` | yes | +| [components](#input\_components) | Image Builder Component | `any` | `{}` | no | +| [create\_image\_recipe](#input\_create\_image\_recipe) | Controls whether resources should be created | `bool` | `true` | no | +| [image\_recipe\_parent\_image](#input\_image\_recipe\_parent\_image) | Platform of the image recip | `string` | `n/a` | yes | +| [image\_recipe\_version](#input\_image\_recipe\_version) | Version of the image recipe | `string` | `n/a` | yes | +| [block\_device\_mapping](#input\_block\_device\_mapping) | Configuration block(s) with block device mappings for the image recipe. Detailed below | `list(map(string))` | `[]` | no | +| [component\_external\_arns](#input\_component\_external\_arns) | Components created externally | `list(string)` | `[]` | no | +| [ebs](#input\_ebs) | Configuration block with Elastic Block Storage (EBS) block device mapping settings | `list(map(string))` | `[]` | no | +| [enable\_resource\_tags](#input\_enable\_resource\_tags) | Whether to enable resource tags | `bool` | `false` | no | +| [resource\_tags](#input\_resource\_tags) | Key-value map of resource tags to assign to infrastructure created by the configuration | `map(string)` | `{}` | no | +| [create\_infrastructure\_configuration](#input\_create\_infrastructure\_configuration) | Controls whether resources should be created | `bool` | `true` | no | +| [infrastructure\_configuration\_description](#input\_infrastructure\_configuration\_description) | Description for the configuration | `string` | `null` | no | +| [infrastructure\_configuration\_instance\_profile\_name](#input\_infrastructure\_configuration\_instance\_profile\_name) | Name of IAM Instance Profile | `string` | `n/a` | yes | +| [infrastructure\_configuration\_instance\_types](#input\_infrastructure\_configuration\_instance\_types) | EC2 Instance Types | `list(string)` | `["t3.nano", "t3.micro"]` | no | +| [infrastructure\_configuration\_key\_pair](#input\_infrastructure\_configuration\_key\_pair) | Name of EC2 Key Pair | `string` | `null` | no | +| [infrastructure\_configuration\_security\_group\_ids](#input\_infrastructure\_configuration\_security\_group\_ids) | EC2 Security Group identifiers | `list(string)` | `null` | no | +| [infrastructure\_configuration\_sns\_topic\_arn](#input\_infrastructure\_configuration\_sns\_topic\_ar) | Amazon Resource Name (ARN) of SNS Topic | `string` | `null` | no | +| [infrastructure\_configuration\_subnet\_id](#input\_infrastructure\_configuration\_subnet\_id) | EC2 Subnet identifier. Also requires security_group_ids argument | `string` | `null` | no | +| [infrastructure\_configuration\_terminate\_instance\_on\_failure](#input\_infrastructure\_configuration\_terminate\_instance\_on\_failure]) | Enable if the instance should be terminated when the pipeline fails | `bool` | `false` | no | +| [infrastructure\_configuration\_s3\_logs\_enabled](#input\_infrastructure\_configuration\_s3\_logs\_enabled) | Whether to enable s3 logs | `bool` | `false` | no | +| [infrastructure\_configuration\_s3\_bucket\_name"](#input\_infrastructure\_configuration\_s3\_bucket\_name) | Name of the S3 Bucket | `string` | `null` | no | +| [infrastructure\_configuration\_s3\_key\_prefix](#input\_infrastructure\_configuration\_s3\_key\_prefix) | Prefix to use for S3 logs | `string` | `null` | no | +| [create\_distribution\_configuration](#input\_create\_distribution\_configuration) | Controls whether resources should be created | `bool` | `true` | no | +| [distribution\_configuration\_description](#input\_distribution\_configuration\_description) | Description of the distribution configuration | `string` | `null` | no | +| [distribution\_configuration\_kms\_key\_id](#input\_distribution\_configuration\_kms\_key\_id) | Amazon Resource Name (ARN) of the Key Management Service (KMS) Key used to encrypt the distribution configuration | `string` | `null` | no | +| [distribution\_configuration\_region](#input\_distribution\_configuration\_region) | AWS Region for the distribution | `string` | `n/a` | yes | +| [ami\_distribution\_configuration](#input\_ami\_distribution\_configuration) | Configuration block with Amazon Machine Image (AMI) distribution settings | `any` | `{}` | no | +| [launch\_permission](#input\_launch\_permission) | Configuration block of EC2 launch permissions to apply to the distributed AMI | `map(list(string))` | `{}` | no | +| [fast\_launch\_configuration](#input\_fast\_launch\_configuration) | Set of Windows faster-launching configurations to use for AMI distribution | `map(string)` | `{}` | no | +| [launch\_template](#input\_launch\_template) | Configuration block for the launch template that the fast-launch enabled Windows AMI uses when it launches Windows instances to create pre-provisioned snapshots | `map(string)` | `null` | no | +| [launch\_template\_configuratio](#input\_launch\_template\_configuratio) | Set of launch template configuration settings that apply to image distribution | `list(map(string))` | `[]` | no | +| [image\_pipeline](#input\_image\_pipeline) | Controls whether resources should be created | `bool` | `true` | no | +| [image\_pipeline\_description](#input\_image\_pipeline\_description) | Description of the image pipeline | `string` | `null` | no | +| [image\_pipeline\_enhanced\_image\_metadata\_enabled](#input\_image\_pipeline\_enhanced\_image\_metadata\_enabled) | Whether additional information about the image being created is collected | `bool` | `true` | no | +| [image\_pipeline\_status](#input\_image\_pipeline\_status) | Status of the image pipeline,Valid values are DISABLED and ENABLED | `string` | `ENABLED` | no | +| [image\_tests\_configuration](#input\_image\_tests\_configuration) | Configuration block with image tests configuration | `map(string)` | `{}` | no | +| [image\_tests\_configuration\_schedule\_enabled](#input\_image\_tests\_configuration\_schedule\_enabled) | Whether to enable schedule expression | `bool` | `false` | no | +| [image\_tests\_configuration\_schedule\_expression](#input\_image\_tests\_configuration\_schedule\_expression) | Cron expression of how often the pipeline start condition is evaluated | `string` | `null` | no | +| [image\_recipe\_arn](#input\_image\_recipe\_arn) | Amazon Resource Name (ARN) of the image recipe | `string` | `n/a` | no | +| [infrastructure\_configuration\_arn](#input\_infrastructure\_configuration\_arn) | Amazon Resource Name (ARN) of the Image Builder Infrastructure Configuration | `string` | `n/a` | no | +| [distribution\_configuration\_arn](#input\_distribution\_configuration\_arn) | Amazon Resource Name (ARN) of the Image Builder Distribution | `string` | `n/a` | no | +| [tags](#input\_tags) | A mapping of tags to assign to the resource | `map(string)` | `{}` | no | + +## Outputs + +| Name | Description | +|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------| +| [component](#output\_component) | Map of Component | +| [component\_name](#output\_component\_name) | List of Name of the component | +| [component\_arn](#output\_component\_arn) | List of Arn of the component | +| [image\_recipe\_name](#output\_image\_recipe\_name) | Name of the image recipe | +| [image\_recipe\_component](#output\_image\_recipe\_component) | Name of the image recipe | +| [image\_recipe\_arn](#output\_image\_recipe\_arn) | Amazon Resource Name (ARN) of the image recipe | +| [image\_recipe\_owner](#output\_image\_recipe\_owner) | Owner of the image recipe | +| [infrastructure\_configuration\_name](#output\_infrastructure\_configuration\_name) | Name of the infrastructure configuration | +| [infrastructure\_configuration\_arn](#output\_infrastructure\_configuration\_arn) | Arn of the infrastructure configuratio | +| [infrastructure\_configuration\_instance\_profile\_name](#output\_infrastructure\_configuration\_instance\_profile\_name) | Instance Profile name of the infrastructure configuration | +| [infrastructure\_configuration\_instance\_types](#output\_infrastructure\_configuration\_instance\_types) | Instance Types of the infrastructure configuration | +| [distribution\_configuration\_name](#output\_distribution\_configuration\_name) | Name of the distribution configuration | +| [image\_pipeline\_name](#output\_image\_pipeline\_name) | Name of the image pipeline | +| [image\_pipeline\_arn](#output\_image\_pipeline\_arn) | Arn of the image pipeline | + \ No newline at end of file