terraform-community-providers / terraform-provider-railway

Terraform provider for railway.app
https://registry.terraform.io/providers/terraform-community-providers/railway/latest/docs
Mozilla Public License 2.0
22 stars 1 forks source link

.team_id: was null, but now cty.StringVal when creating project #33

Closed davidvdw closed 2 weeks ago

davidvdw commented 2 weeks ago

Hi, I try to make a new project with 2 environments

my main.tf

terraform {
  required_providers {
    railway = {
      source  = "terraform-community-providers/railway"
      version = "0.4.4"
    }
  }
}

provider "railway" {}

resource "railway_project" "main" {
  name = "newproject"
}

resource "railway_environment" "production" {
  name       = "production"
  project_id = railway_project.main.id
}

resource "railway_environment" "staging" {
  name       = "staging"
  project_id = railway_project.main.id
}

when I apply I got:

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # railway_environment.production will be created
  + resource "railway_environment" "production" {
      + id         = (known after apply)
      + name       = "production"
      + project_id = (known after apply)
    }

  # railway_environment.staging will be created
  + resource "railway_environment" "staging" {
      + id         = (known after apply)
      + name       = "staging"
      + project_id = (known after apply)
    }

  # railway_project.main will be created
  + resource "railway_project" "main" {
      + default_environment = {
          + id   = (known after apply)
          + name = "production"
        }
      + description         = ""
      + has_pr_deploys      = false
      + id                  = (known after apply)
      + name                = "newproject"
      + private             = true
    }

Plan: 3 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

railway_project.main: Creating...

│ Error: Provider produced inconsistent result after apply
│
│ When applying changes to railway_project.main, provider "provider[\"registry.terraform.io/terraform-community-providers/railway\"]" produced an unexpected new value: .team_id: was null, but
│ now cty.StringVal("d6b4101a-04de-4b5b-81ea-4bf900f82d70").
│
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.

Funding

Fund with Polar

pksunkara commented 2 weeks ago

You need to specify team_id for railway_project

pksunkara commented 2 weeks ago

Also, please read the docs first, we already create a default environment for a project, so you production environment would fail too later.

davidvdw commented 1 week ago

You need to specify team_id for railway_project

Thank you, @pksunkara, for the quick reply and for maintaining this project. It works by specifying team_id. team_id is mentioned as optional in the docs.

pksunkara commented 1 week ago

Yeah, it is optional only because it should not be present on personal projects.