Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extension comments not added to Terraform state when using Terraform apply with the Atlas provider #2757

Open
ttrine opened this issue May 8, 2024 · 3 comments
Assignees

Comments

@ttrine
Copy link

ttrine commented May 8, 2024

Atlas itself detects no changes:

% atlas schema apply --dry-run -c file://schema/atlas.hcl --env dev
Schema is synced, no changes to be made

with the dev env configured as

env {
  name = atlas.env
  src = "file://schema/public.hcl"
  url = "postgres://127.0.0.1?sslmode=disable"
  dev = "postgres://127.0.0.1/atlas_dev?sslmode=disable"
}

But Terraform gives the following plan repeatedly on apply:

% terraform plan

      ...

      extension "google_columnar_engine" {
        schema  = schema.public
        version = "1.0"
    +   comment = "Google extension for columnar engine"
      }
      extension "google_db_advisor" {
        schema  = schema.public
        version = "1.0"
    +   comment = "Google extension for Database Advisor"
      }
      extension "hypopg" {
        schema  = schema.public
        version = "1.3.2"
    +   comment = "Hypothetical indexes for PostgreSQL"
      }
      extension "postgis" {
        schema  = schema.public
        version = "3.2.5"
        comment = "PostGIS geometry and geography spatial types and functions"
      }

I happen to be using GCP's AlloyDB which is essentially a managed PostgreSQL instance with some added Google-proprietary extensions. The Terraform configuration gives Atlas a separate database (on the same instance) to use as a dev database.

data "atlas_schema" "public" {
  src = file("${path.module}/schema/public.hcl")
  dev_url = "postgres://127.0.0.1/atlas_dev?sslmode=disable"
  depends_on = [
    postgresql_database.kateri,
    postgresql_database.atlas_dev
  ]
}

resource "atlas_schema" "public" {
  hcl = data.atlas_schema.public.hcl
  url = "postgres://127.0.0.1?sslmode=disable"
  dev_url = data.atlas_schema.public.dev_url

  depends_on = [ 
    postgresql_database.kateri,
    postgresql_database.atlas_dev
  ]
}

The dev database is empty except for the public schema.

It's possible this is user error but I haven't seen any references to this issue online or been able to track down the cause myself.

@ttrine ttrine changed the title Extension comments don't update on apply when using the Atlas Terraform provider Extension comments not added to Terraform state when using Terraform apply with the Atlas provider May 8, 2024
@giautm
Copy link
Member

giautm commented May 8, 2024

Thank you for report this, I'll look into it soon.

@giautm giautm self-assigned this May 8, 2024
@a8m
Copy link
Member

a8m commented May 8, 2024

I think that's because the database (defined in TF) information schema does not return the comments as defined and returned from your local dev-database. You can simply remove these comments from the schema.hcl and re-run this.

@ttrine
Copy link
Author

ttrine commented May 8, 2024

Thanks for your suggestion @a8m. I did try that, but for some reason it yields the same Terraform plan I gave above after several applications of terraform apply.

@giautm thank you. Please let me know if you need more detail to reproduce this - I'm not sure which extra information is relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants