Closed sc250024 closed 2 years ago
As a followup, I think I found the issue:
https://github.com/terraform-aws-modules/terraform-aws-autoscaling/blob/v5.2.0/main.tf#L149-L154
Basically, the underlying aws_launch_template
resource uses the key license_specification
. In the code above, the dynamic
block is correctly named license_specification
. However, in line https://github.com/terraform-aws-modules/terraform-aws-autoscaling/blob/v5.2.0/main.tf#L152, the license_configuration_arn
key points to license_specifications.value.license_configuration_arn
(Notice the extra s
).
The fix would be:
dynamic "license_specification" {
for_each = var.license_specifications != null ? [var.license_specifications] : []
content {
- license_configuration_arn = license_specifications.value.license_configuration_arn
+ license_configuration_arn = license_specification.value.license_configuration_arn
}
}
This issue has been resolved in version 6.5.1 :tada:
I'm going to lock this issue because it has been closed for 30 days β³. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Description
I cannot use the
license_specifications
block of this module, and receive an error that saysReference to undeclared resource
. It could be that I'm using the wrong format for the input. If I am, then maybe I'll reuse this code to provide an example in theexamples
directory.Versions
Module version [Required]:
5.2.0
Terraform version:
provider registry.terraform.io/hashicorp/archive v2.2.0
provider registry.terraform.io/hashicorp/aws v3.75.2
provider registry.terraform.io/hashicorp/external v2.2.2
provider registry.terraform.io/hashicorp/local v2.2.3
provider registry.terraform.io/hashicorp/null v3.1.1
provider registry.terraform.io/hashicorp/random v3.3.1
provider registry.terraform.io/hashicorp/template v2.2.0
provider registry.terraform.io/hashicorp/vault v3.7.0
Reproduction Code [Required]
Steps to reproduce the behavior:
Using a clean copy of this repository as a basis, do the following:
v5.2.0
of the module (git checkout v5.2.0
)examples
directory, and create a new folder calledlicense
main.tf
andversions.tf
files from the collapsible sections below, and place them in thelicense
folder.terraform init
, and thenterraform plan
.main.tf
```hcl provider "aws" { region = local.region default_tags { tags = { Project = "terraform-aws-autoscaling" } } # Make it faster by skipping something skip_get_ec2_platforms = true skip_metadata_api_check = true skip_region_validation = true skip_credentials_validation = true skip_requesting_account_id = true } locals { name = "ex-asg-complete" region = "us-east-1" tags = { Owner = "user" Environment = "dev" } user_data = <<-EOT #!/bin/bash echo "Hello Terraform!" EOT } ################################################################################ # Supporting Resources ################################################################################ module "vpc" { source = "terraform-aws-modules/vpc/aws" version = "~> 3.0" name = local.name cidr = "10.99.0.0/18" azs = ["${local.region}a", "${local.region}b", "${local.region}c"] public_subnets = ["10.99.0.0/24", "10.99.1.0/24", "10.99.2.0/24"] private_subnets = ["10.99.3.0/24", "10.99.4.0/24", "10.99.5.0/24"] enable_dns_hostnames = true enable_dns_support = true tags = local.tags } data "aws_ami" "amazon_linux" { most_recent = true owners = ["amazon"] filter { name = "name" values = [ "amzn-ami-hvm-*-x86_64-gp2", ] } } ################################################################################ # Launch template only ################################################################################ resource "aws_licensemanager_license_configuration" "test" { license_count = 1 license_count_hard_limit = true license_counting_type = "Socket" name = "test-license" license_rules = [ "#allowedTenancy=EC2-DedicatedHost", "#maximumSockets=2", "#minimumSockets=2", ] } module "launch_template_only" { source = "../../" create = false desired_capacity = 1 image_id = data.aws_ami.amazon_linux.id instance_type = "t3.micro" max_size = 1 min_size = 0 name = "launch-template-only-${local.name}" tags = local.tags vpc_zone_identifier = module.vpc.private_subnets license_specifications = { license_configuration_arn = aws_licensemanager_license_configuration.test.arn } } ```versions.tf
```hcl terraform { required_version = ">= 0.13.1" required_providers { aws = { source = "hashicorp/aws" version = ">= 3.72" } } } ```Expected behavior
I am following the pattern of several other inputs of this module. I would expect that
license_specifications
accepts a mapping like the following:I could be wrong though.
Actual behavior
The actual error that appears is the following:
Terminal Output Screenshot(s)
This basically shows the same as the error above.
Additional context
If this issue leads to a fix version, would it be possible to cut a version
v5.3.0
version of this module to support the AWS provider 3.x version in addition to the normalv6.6.0
version please?