VladRassokhin / intellij-hcl

HCL language support for IntelliJ platform based IDEs
Apache License 2.0
244 stars 47 forks source link

Better support for TF 0.12 for loops variables #208

Closed VladRassokhin closed 5 years ago

VladRassokhin commented 5 years ago

image

Originally posted by @benosman in https://github.com/VladRassokhin/intellij-hcl/issues/155#issuecomment-497503146

bowczarek commented 5 years ago

Yeah I also noticed that input variables declared as custom types with different attributes cannot be later resolved object({<ATTR NAME> = <TYPE>, ... })

Created a separate issue for that https://github.com/VladRassokhin/intellij-hcl/issues/209

jerrygb commented 5 years ago

Hi @VladRassokhin,

Just a heads up on for_each loop construct within the dynamic block also has a similar issue. The plugin does not seem to interpret key and value as being component of the iterator object.

Ref: https://www.terraform.io/docs/configuration/expressions.html#dynamic-blocks

Thank you once again! Let me know if you want me to create a separate issue.

Also, noticed that the repo here does not have v0.7.0 tag. Is that something you plan to checkin?

VladRassokhin commented 5 years ago

I've fixed all errors on initial screenshot in 0.7.1. Please try it out

apenner-epam commented 5 years ago

Hi, Plugin version - 0.7.1

Issue: unresolved references in dynamic block

image

Here is s3_notification_configuration object

// Optional variables
variable "s3_notification_configuration" {
  description = "s3 notification configuration"
  type = list(object({
    id            = string
    events        = list(string)
    filter_suffix = string
    filter_prefix = string
  }))
}
VladRassokhin commented 5 years ago

@apenner-epam Fixed problems shown on your screenshot, will be available in 0.7.2

@jerrygb Problem with 'key' and 'value' is fixed in 0.7.2 (it's the same as above)

Also, noticed that the repo here does not have v0.7.0 tag. Is that something you plan to checkin?

There's no tag because that 0.7+ is closed-sorced, unless some decisions about plugin feature are made.

d-helios commented 5 years ago

Hi, It resolves value & key attributes, but doesn't resolve object attributes.

Plugin version == 0.7.2
IntelliJ Idea == 2019.1.2

Example:

variable "s3_notification_configuration" {
  description = "s3 notification configuration"
  type = list(object({
    id            = string
    events        = list(string)
    filter_suffix = string
    filter_prefix = string
  }))
  default = []
}

// SQS
resource "aws_s3_bucket_notification" "this" {
  count  = length(var.s3_notification_configuration)
  bucket = aws_s3_bucket.this.id

  dynamic "queue" {
    for_each = var.s3_notification_configuration
    content {
      id            = queue.value.id
      events        = queue.value.events
      filter_suffix = queue.value.filter_suffix == "" ? null : queue.value.filter_suffix
      filter_prefix = queue.value.filter_prefix == "" ? null : queue.value.filter_prefix
      queue_arn = format(
        "arn:aws:sqs:%s:%s:%s",
        data.aws_region.this.name,
        data.aws_caller_identity.this.account_id,
        join("-", [var.name, queue.value.id, var.environment])
      )
    }
  }
}
image
jstewmon commented 5 years ago

Not sure if it is related, but I have a similar issue accessing complex variables with an index:

image

VladRassokhin commented 5 years ago

@d-helios, @jstewmon Fixed in 0.7.3, will be released shortly

jerrygb commented 5 years ago

@VladRassokhin

Thank you once again for 0.7.3 fixing all the registered 0.12 issues.

I would like to report one very minor formatting issue, with trailing commas for HCL1 interpolation syntax/HCL2 functions. See screenshot below.

Screen Shot 2019-06-11 at 6 32 47 AM

Functions that can take variable arguments can end with trailing commas according to HCL grammar, I believe. But the plug-in complains the behaviour as an error. See references below.

It should either be a warning formatting or proposed hint to remove the trailing comma, I think. Please correct me if I am wrong.

Ref: https://www.terraform.io/docs/configuration-0-11/interpolation.html#merge-map1-map2- https://www.terraform.io/docs/configuration/functions.html

jstewmon commented 5 years ago

@VladRassokhin I no longer see errors for valid keys, but there's also no error for invalid keys, and there's no completion help. Is that expected? image

Also, I'm seeing errors referring to another resource from within a content block: image

VladRassokhin commented 5 years ago

@jstewmon

but there's also no error for invalid keys, and there's no completion help. Is that expected?

Yes, for now.

errors referring to another resource from within a content block

Will create separate issue for that.

VladRassokhin commented 5 years ago

@jerrygb Thanks, I've created separate issue.