CircleCI-Public / terraform-orb

Deploy your infrastructure via a CircleCI pipeline using the Terraform orb. Integrate Infrastructure-as-Code (IaC) to help provision and manage any cloud, infrastructure, or service of your choice.
https://circleci.com/orbs/registry/orb/circleci/terraform
MIT License
10 stars 44 forks source link

terraform/validate doesn't support import blocks, but terraform v1.7.5 on my machine does #104

Closed henrahmagix closed 7 months ago

henrahmagix commented 7 months ago

Orb Version 3.2.1

Describe the bug Import blocks available from Terraform v1.5.0 and later are valid when terraform validate is ran locally, but the latest orb doesn't recognise it.

To Reproduce

  1. create a terraform configuration with a simple resource and an import {} block that imports that resource that already exists remotely
  2. run terraform validate locally on your configuration
  3. make CircleCI run the terraform/validate job from the circleci/terraform@3.2.1 orb on your configuration

Expected behavior

Locally:

$ terraform validate
Success! The configuration is valid.

In CircleCI job output:

Success! The configuration is valid.

Actual behavior

Locally:

$ terraform validate
Success! The configuration is valid.

In CircleCI job output:

Error: Unsupported block type
│ 
│   on main.tf line 112:
│  112: import {
│ 
│ Blocks of type "import" are not expected here.
image

Additional context

$ terraform -v
Terraform v1.7.5
on darwin_arm64
+ provider registry.terraform.io/cyrilgdn/postgresql v1.19.0
+ provider registry.terraform.io/hashicorp/google v5.21.0
+ provider registry.terraform.io/hashicorp/google-beta v5.21.0
+ provider registry.terraform.io/hashicorp/kubernetes v2.27.0
+ provider registry.terraform.io/hashicorp/random v3.6.0

Example configuration:

resource "google_project_service" "container" {
  project = "my-project-in-google"
  service = "container.googleapis.com"
}
import {
  id = "my-project-in-google/container.googleapis.com"
  to = google_project_service.container
}
henrahmagix commented 7 months ago

I'm so sorry, I never realised you can set the version in terraform/install 🙈 This is all fine then, not an actual issue! I'll get me coat 😅