Skip to content

Commit 1dda8c6

Browse files
authored
Merge pull request #27 from codebrewer/feature/support-target-project
Use the configured Terraform Cloud project name to determine where to create a workspace
2 parents 69a878e + 6af2fbe commit 1dda8c6

File tree

7 files changed

+63
-0
lines changed

7 files changed

+63
-0
lines changed

aws/tfc-workspace.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,22 @@ provider "tfe" {
55
hostname = var.tfc_hostname
66
}
77

8+
# Data source used to grab the project under which a workspace will be created.
9+
#
10+
# https://registry.terraform.io/providers/hashicorp/tfe/latest/docs/data-sources/project
11+
data "tfe_project" "tfc_project" {
12+
name = var.tfc_project_name
13+
organization = var.tfc_organization_name
14+
}
15+
816
# Runs in this workspace will be automatically authenticated
917
# to AWS with the permissions set in the AWS policy.
1018
#
1119
# https://registry.terraform.io/providers/hashicorp/tfe/latest/docs/resources/workspace
1220
resource "tfe_workspace" "my_workspace" {
1321
name = var.tfc_workspace_name
1422
organization = var.tfc_organization_name
23+
project_id = data.tfe_project.tfc_project.id
1524
}
1625

1726
# The following variables must be set to allow runs

azure/tfc-workspace.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,22 @@ provider "tfe" {
55
hostname = var.tfc_hostname
66
}
77

8+
# Data source used to grab the project under which a workspace will be created.
9+
#
10+
# https://registry.terraform.io/providers/hashicorp/tfe/latest/docs/data-sources/project
11+
data "tfe_project" "tfc_project" {
12+
name = var.tfc_project_name
13+
organization = var.tfc_organization_name
14+
}
15+
816
# Runs in this workspace will be automatically authenticated
917
# to Azure with the permissions set in the Azure policy.
1018
#
1119
# https://registry.terraform.io/providers/hashicorp/tfe/latest/docs/resources/workspace
1220
resource "tfe_workspace" "my_workspace" {
1321
name = var.tfc_workspace_name
1422
organization = var.tfc_organization_name
23+
project_id = data.tfe_project.tfc_project.id
1524
}
1625

1726
# The following variables must be set to allow runs

gcp/tfc-workspace.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,22 @@ provider "tfe" {
55
hostname = var.tfc_hostname
66
}
77

8+
# Data source used to grab the project under which a workspace will be created.
9+
#
10+
# https://registry.terraform.io/providers/hashicorp/tfe/latest/docs/data-sources/project
11+
data "tfe_project" "tfc_project" {
12+
name = var.tfc_project_name
13+
organization = var.tfc_organization_name
14+
}
15+
816
# Runs in this workspace will be automatically authenticated
917
# to GCP with the permissions set in the GCP policy.
1018
#
1119
# https://registry.terraform.io/providers/hashicorp/tfe/latest/docs/resources/workspace
1220
resource "tfe_workspace" "my_workspace" {
1321
name = var.tfc_workspace_name
1422
organization = var.tfc_organization_name
23+
project_id = data.tfe_project.tfc_project.id
1524
}
1625

1726
# The following variables must be set to allow runs

vault-backed/aws/tfc-workspace.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,22 @@ provider "tfe" {
55
hostname = var.tfc_hostname
66
}
77

8+
# Data source used to grab the project under which a workspace will be created.
9+
#
10+
# https://registry.terraform.io/providers/hashicorp/tfe/latest/docs/data-sources/project
11+
data "tfe_project" "tfc_project" {
12+
name = var.tfc_project_name
13+
organization = var.tfc_organization_name
14+
}
15+
816
# Runs in this workspace will be automatically authenticated
917
# to Vault with the permissions set in the Vault policy.
1018
#
1119
# https://registry.terraform.io/providers/hashicorp/tfe/latest/docs/resources/workspace
1220
resource "tfe_workspace" "my_workspace" {
1321
name = var.tfc_workspace_name
1422
organization = var.tfc_organization_name
23+
project_id = data.tfe_project.tfc_project.id
1524
}
1625

1726
# The following variables must be set to allow runs

vault-backed/azure/tfc-workspace.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,22 @@ provider "tfe" {
55
hostname = var.tfc_hostname
66
}
77

8+
# Data source used to grab the project under which a workspace will be created.
9+
#
10+
# https://registry.terraform.io/providers/hashicorp/tfe/latest/docs/data-sources/project
11+
data "tfe_project" "tfc_project" {
12+
name = var.tfc_project_name
13+
organization = var.tfc_organization_name
14+
}
15+
816
# Runs in this workspace will be automatically authenticated
917
# to Vault with the permissions set in the Vault policy.
1018
#
1119
# https://registry.terraform.io/providers/hashicorp/tfe/latest/docs/resources/workspace
1220
resource "tfe_workspace" "my_workspace" {
1321
name = var.tfc_workspace_name
1422
organization = var.tfc_organization_name
23+
project_id = data.tfe_project.tfc_project.id
1524
}
1625

1726
# The following variables must be set to allow runs

vault-backed/gcp/tfc-workspace.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,22 @@ provider "tfe" {
55
hostname = var.tfc_hostname
66
}
77

8+
# Data source used to grab the project under which a workspace will be created.
9+
#
10+
# https://registry.terraform.io/providers/hashicorp/tfe/latest/docs/data-sources/project
11+
data "tfe_project" "tfc_project" {
12+
name = var.tfc_project_name
13+
organization = var.tfc_organization_name
14+
}
15+
816
# Runs in this workspace will be automatically authenticated
917
# to Vault with the permissions set in the Vault policy.
1018
#
1119
# https://registry.terraform.io/providers/hashicorp/tfe/latest/docs/resources/workspace
1220
resource "tfe_workspace" "my_workspace" {
1321
name = var.tfc_workspace_name
1422
organization = var.tfc_organization_name
23+
project_id = data.tfe_project.tfc_project.id
1524
}
1625

1726
# The following variables must be set to allow runs

vault/tfc-workspace.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,22 @@ provider "tfe" {
55
hostname = var.tfc_hostname
66
}
77

8+
# Data source used to grab the project under which a workspace will be created.
9+
#
10+
# https://registry.terraform.io/providers/hashicorp/tfe/latest/docs/data-sources/project
11+
data "tfe_project" "tfc_project" {
12+
name = var.tfc_project_name
13+
organization = var.tfc_organization_name
14+
}
15+
816
# Runs in this workspace will be automatically authenticated
917
# to Vault with the permissions set in the Vault policy.
1018
#
1119
# https://registry.terraform.io/providers/hashicorp/tfe/latest/docs/resources/workspace
1220
resource "tfe_workspace" "my_workspace" {
1321
name = var.tfc_workspace_name
1422
organization = var.tfc_organization_name
23+
project_id = data.tfe_project.tfc_project.id
1524
}
1625

1726
# The following variables must be set to allow runs

0 commit comments

Comments
 (0)