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

Bug: Plan fails when trying to create a new TFE/TFC project #169

Open
SanderBlom opened this issue Oct 7, 2024 · 0 comments
Open

Bug: Plan fails when trying to create a new TFE/TFC project #169

SanderBlom opened this issue Oct 7, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@SanderBlom
Copy link
Contributor

Description

If we create a new Terraform cloud project using the TFE provider like so in station deploymnets:

resource "tfe_project" "backup" {
  organization = var.organization_name
  name         = "Backup"
}

The plan will fail if you reference it like so:

  tfe = {
    organization_name     = var.organization_name
    project_name          = tfe_project.backup.name
    workspace_name        = "azure-backup"
    workspace_description = "Resources used to backup Azure resources"
    vcs_repo = {
      identifier     = github_repository.repos["backup"].full_name
      branch         = "trunk"
      oauth_token_id = var.vcs_repo_oauth_token_id
    }
    module_outputs_to_workspace_var = {
      groups = true
    }
  }

Steps to Reproduce

  1. Create a new project using the tfe provider:
resource "tfe_project" "backup" {
  organization = var.organization_name
  name         = "backup"
}
  1. Create a new workload and pass name value from the project to the tfe.project_name property like so:
  tfe = {
    organization_name     = var.organization_name
    project_name          = tfe_project.backup.name
    workspace_name        = "azure-backup"
    workspace_description = "Resources used to backup Azure resources"
    vcs_repo = {
      identifier     = github_repository.repos["backup"].full_name
      branch         = "trunk"
      oauth_token_id = var.vcs_repo_oauth_token_id
    }
  }
  1. Run terraform plan and see the error:
╷
│ Error: could not find project myOrgName/backup
│ 
│   with module.backup.module.station-tfe.data.tfe_project.workload,
│   on .terraform/modules/backup/hashicorp/tfe/tfe_project.tf line 1, in data "tfe_project" "workload":
│    1: data "tfe_project" "workload" {
│ 

Expected Behavior

I would expect it to plan fine, then during the apply phase, first create the project and then try to create or update the workspace with the correct project name

Actual Behavior

As we reference the name property that is allready known at plan time it just passes this to the tfe module where it's used in a data source to get the ID. As the project is not yet created the data source fails to the the projectID

Terraform Version

1.9.7

Station Version

1.10.0

@SanderBlom SanderBlom added the bug Something isn't working label Oct 7, 2024
@SanderBlom SanderBlom self-assigned this Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant