hashicorp / terraform-provider-awscc

Terraform AWS Cloud Control provider
https://registry.terraform.io/providers/hashicorp/awscc/latest/docs
Mozilla Public License 2.0
240 stars 107 forks source link

Image Builder Distribution Configuration does not recognise launch template configuration #370

Open Computer15776 opened 2 years ago

Computer15776 commented 2 years ago

For the given resource

resource "awscc_imagebuilder_distribution_configuration" "main" {
  name        = var.distribution_name
  description = var.distribution_description
  tags        = var.distribution_tags
  distributions = [{
    ami_distribution_configuration = {
      name = "{{imagebuilder:buildDate}}"
    }
    launch_template_configurations = [{
      launchTemplateId  = "lt-12345678abcde"
      accountId         = "1234567890"
      setDefaultVersion = true
    }]
    license_configuration_arns = [""]
    region                     = "us-east-1"
  }]
}

Terraform outputs a plan of the following:

  + resource "awscc_imagebuilder_distribution_configuration" "main" {
      + arn           = (known after apply)
      + distributions = [
          + {
              + ami_distribution_configuration = {
                  + name = "{{imagebuilder:buildDate}}"
                }
              + launch_template_configurations = [
                  + {
                    },
                ]
              + license_configuration_arns     = [
                  + "",
                ]
              + region                         = "us-east-1"
            },
        ]
      + id            = (known after apply)
      + name          = "foobar"
    }

Why does the distribution_configuration show an empty attribute for launch_template_configuration when it's definitely set? I've confirmed the values given for the other attributes/parameters are correct.

ewbankkit commented 1 year ago

@Computer15776 Thanks for raising this issue. The launch_template_configurations nested attributes are in-fact named account_id, launch_template_id and set_default_version, in which case:

% terraform plan
...
  # awscc_imagebuilder_distribution_configuration.main will be created
  + resource "awscc_imagebuilder_distribution_configuration" "main" {
      + arn           = (known after apply)
      + description   = "test"
      + distributions = [
          + {
            + ami_distribution_configuration = {
              + name = "{{imagebuilder:buildDate}}"
            }
            + launch_template_configurations = [
                + {
                  + account_id          = "1234567890"
                  + launch_template_id  = "lt-12345678abcde"
                  + set_default_version = true
                },
              ]
            + region                         = "us-east-1"
          },
        ]
      + id            = (known after apply)
      + name          = "test"
    }

Plan: 1 to add, 0 to change, 0 to destroy.

This incorrect attributes should be trapped though - see #460.