Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot iterate over range of type number #200

Open
brandonpollack23 opened this issue Oct 9, 2024 · 2 comments
Open

Cannot iterate over range of type number #200

brandonpollack23 opened this issue Oct 9, 2024 · 2 comments
Labels
kind/bug Some behavior is incorrect or out of spec

Comments

@brandonpollack23
Copy link
Contributor

brandonpollack23 commented Oct 9, 2024

resource "public" "aws:ec2/subnet:Subnet" {
  options {
    range = createPublicSubnets && (!oneNatGatewayPerAz || lenPublicSubnets >= length(azs)) ? lenPublicSubnets : 0

  }
  assignIpv6AddressOnCreation = enableIpv6 && publicSubnetIpv6Native ? true : publicSubnetAssignIpv6AddressOnCreation
  availabilityZone            = length(notImplemented("regexall(\"^[a-z]{2}-\",element(var.azs,count.index))")) > 0 ? element(azs, range.value) : null
  availabilityZoneId          = length(notImplemented("regexall(\"^[a-z]{2}-\",element(var.azs,count.index))")) == 0 ? element(azs, range.value) : null
  cidrBlock = publicSubnetIpv6Native ? null : element(invoke("std:index:concat", {
    input = [publicSubnets, [""]]
  }).result, range.value)
  enableDns64                             = enableIpv6 && publicSubnetEnableDns64
  enableResourceNameDnsAaaaRecordOnLaunch = enableIpv6 && publicSubnetEnableResourceNameDnsAaaaRecordOnLaunch
  enableResourceNameDnsARecordOnLaunch    = !publicSubnetIpv6Native && publicSubnetEnableResourceNameDnsARecordOnLaunch
  ipv6CidrBlock = enableIpv6 && length(publicSubnetIpv6Prefixes) > 0 ? invoke("std:index:cidrsubnet", {
    input   = this[0].ipv6CidrBlock
    newbits = 8
    netnum  = publicSubnetIpv6Prefixes[range.value]
  }).result : null
  ipv6Native                     = enableIpv6 && publicSubnetIpv6Native
  mapPublicIpOnLaunch            = mapPublicIpOnLaunch
  privateDnsHostnameTypeOnLaunch = publicSubnetPrivateDnsHostnameTypeOnLaunch
  vpcId                          = vpcId
  tags                           = notImplemented("merge(\n{\nName=try(\nvar.public_subnet_names[count.index],\nformat(\"$${var.name}-$${var.public_subnet_suffix}-%s\",element(var.azs,count.index))\n)\n},\nvar.tags,\nvar.public_subnet_tags,\nlookup(var.public_subnet_tags_per_az,element(var.azs,count.index),{})\n)")
}

When trying to convert VPC to PCL, the above code has the error:

vpc_5.13.0/main.pp:97,5-115: cannot iterate over a value of type number; , and 43 other diagnostic(s);

Upon a brief investigation of VPC terraform provider, we can observe that this section of the code maps to here

This code assigns to resource field "count" not "options.range" which may be the source of the trouble.

@pulumi-bot pulumi-bot added the needs-triage Needs attention from the triage team label Oct 9, 2024
@brandonpollack23
Copy link
Contributor Author

tf.go#L2364 contains the code which generates this, worth looking at

@justinvp justinvp added kind/bug Some behavior is incorrect or out of spec and removed needs-triage Needs attention from the triage team labels Oct 9, 2024
@brandonpollack23
Copy link
Contributor Author

brandonpollack23 commented Oct 9, 2024

When the line is hard coded as an integer it works so something is invalid about the syntax potentially.

It does reveal that this is still blocked by #202

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Some behavior is incorrect or out of spec
Projects
None yet
Development

No branches or pull requests

3 participants