ariga / terraform-provider-atlas

Terraform Provider for Atlas
https://atlasgo.io
Apache License 2.0
56 stars 8 forks source link

Planned invalid value for version #90

Closed dubcanada closed 1 year ago

dubcanada commented 1 year ago

Hello,

I am getting an error with a very basic setup I have a single SQL file 20231102125726_create_database.sql and I am getting

Provider "registry.terraform.io/ariga/atlas" planned an invalid value for atlas_migration.backend-migration.version: planned value cty.StringVal("20231102125726") does not match config value cty.UnknownVal(cty.String).

I have

data "atlas_migration" "backend-migration-data" {
  dir = "./../database?format=atlas"
  url = "URL"
}

resource "atlas_migration" "backend-migration" {
  dir     = "./../database?format=atlas"
  url     = data.atlas_migration.backend-migration-data.url
  version = data.atlas_migration.backend-migration-data.version
  dev_url = "docker://maria/10.7/database" // 10.6 doesn't exist, it's only used for validating SQL
}
Terraform v1.6.3
on linux_amd64
+ provider registry.terraform.io/ariga/atlas v0.5.5
+ provider registry.terraform.io/hashicorp/aws v5.23.1
+ provider registry.terraform.io/hashicorp/external v2.3.1
+ provider registry.terraform.io/hashicorp/local v2.4.0
+ provider registry.terraform.io/hashicorp/null v3.2.1
+ provider registry.terraform.io/hashicorp/random v3.5.1

Thanks,

giautm commented 1 year ago

Hello @dubcanada, there is no version attribute on the datasource. Please use latest instead.

data "atlas_migration" "backend-migration-data" {
  dir = "./../database?format=atlas"
  url = "URL"
}

resource "atlas_migration" "backend-migration" {
  dir     = "./../database?format=atlas"
  url     = data.atlas_migration.backend-migration-data.url
  version = data.atlas_migration.backend-migration-data.latest // <-- latest
  dev_url = "docker://maria/10.7/database" // 10.6 doesn't exist, it's only used for validating SQL
}