hashicorp/terraform-cdk

Convert command throws error when count is present

scottenriquez opened this issue ยท 2 comments

Community Note

  • Please vote on this issue by adding a ๐Ÿ‘ reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

cdktf & Language Versions

Terraform version: 1.0.3
CDK for Terraform version: 0.5

Debug Output

Link to Gist

Expected Behavior

Source Terraform:

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 3.0"
    }
  }
}

resource "aws_instance" "multiple_servers" {
  count = 4

  ami           = "ami-0c2b8ca1dad447f8a"
  instance_type = "t2.micro"

  tags = {
    Name = "Server ${count.index}"
  }
}

Command:

cat terraform.tf | cdktf convert --language typescript

Expected
One or more Instances to be generated.

new aws.Instance(this, "multiple_server", {
  ami: "ami-0c2b8ca1dad447f8a",
  instanceType: "t2.micro",
  tags: {
    name: "Server ${count.index}",
  },
});

Actual Behavior

Error: Internal Error: input.startsWith is not a function

Steps to Reproduce

  • Copy HCL above into a file named terraform.tf
  • Run cat terraform.tf | cdktf convert --language typescript

My guess for the root cause is that its in the extractReferencesFromExpression function.

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've 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.