Open skorfmann opened 4 years ago
I think this is an issue when attempting to use the HCL1 parser due to this:
In Terraform v0.12 and later, the language makes a distinction between argument syntax and nested block syntax within blocks
... the JSON syntax cannot support the nested block processing mode for these arguments. This is, unfortunately, one necessary concession on the equivalence between native syntax and JSON syntax made pragmatically for compatibility with existing provider design patterns. Providers may phase out such patterns in future major releases.
I'm now having it use HCL2 by default, however I now have issues when a single block is present. Example:
resource "aws_instance" "ubuntu" {
ami = "ami-0ff8a91507f77f867"
instance_type = "t3.nano"
availability_zone = "us-east-1a"
network_interface {
network_interface_id = "something"
device_index = 0
}
network_interface {
network_interface_id = "something2"
device_index = 1
}
credit_specification {
cpu_credits = "unlimited"
}
security_groups = [
"sg-123",
"sg-456"
]
tags = {
Name = "MyInstance"
}
}
const ubuntu = new Instance(this, 'ubuntu', {
ami: "ami-0ff8a91507f77f867",
availabilityZone: "us-east-1a",
creditSpecification: {
cpuCredits: "unlimited"
},
instanceType: "t3.nano",
networkInterface: [
{
deviceIndex: 0,
networkInterfaceId: "something"
},
{
deviceIndex: 1,
networkInterfaceId: "something2"
}
],
securityGroups: [
"sg-123",
"sg-456"
],
tags: {
name: "MyInstance"
}
});
Note the cpuCredits
should be an array.
I took this example and converted it bare
:
There were three things I had to fix manually:
domainName: b.bucketRegionalDomainName!,
rather than domainName: b.bucket_regional_domain_name!,
s3_distribution
in this case. Not sure how complex. that would be.Overall, just minor things and I think that this is really good already!
however I now have issues when a single block is present
According to the documentation this sounds like an edge case. Perhaps it's ok to ignore for the time being? I'll try to get a feeling for the occurrences of this.
Also, I'll create issues for the things I fixed manually.
The schema for creditSpecification
looks like this:
// On AWS instance resource
"credit_specification": {
"type": ["list", ["object", {
"cpu_credits": "string"
}]],
"description_kind": "plain",
"computed": true
},
For the AWS Provider, there are ~ 100 occurrences of this: "type": ["list", ["object",
- So, we should try to find a solution for this.
The
./test.tf
example renderstags
like this:It should be: