Skip to content

Commit 6e56ae6

Browse files
committed
added project_ids
1 parent 22bdc14 commit 6e56ae6

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

tfe/data_source_variable_set.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ func dataSourceTFEVariableSet() *schema.Resource {
4848
Computed: true,
4949
Elem: &schema.Schema{Type: schema.TypeString},
5050
},
51+
52+
"project_ids": {
53+
Type: schema.TypeSet,
54+
Optional: true,
55+
Computed: true,
56+
Elem: &schema.Schema{Type: schema.TypeString},
57+
},
5158
},
5259
}
5360
}
@@ -104,6 +111,12 @@ func dataSourceTFEVariableSetRead(d *schema.ResourceData, meta interface{}) erro
104111
}
105112
d.Set("variable_ids", variables)
106113

114+
var projects []interface{}
115+
for _, project := range vs.Projects {
116+
projects = append(projects, project.ID)
117+
}
118+
d.Set("project_ids", projects)
119+
107120
d.SetId(vs.ID)
108121
return nil
109122
}

tfe/data_source_variable_set_test.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ func TestAccTFEVariableSetsDataSource_full(t *testing.T) {
5656
"data.tfe_variable_set.foobar", "workspace_ids.#", "1"),
5757
resource.TestCheckResourceAttr(
5858
"data.tfe_variable_set.foobar", "variable_ids.#", "1"),
59+
resource.TestCheckResourceAttr(
60+
"data.tfe_variable_set.foobar", "project_ids.#", "1"),
5961
),
6062
},
6163
},
@@ -94,11 +96,17 @@ resource "tfe_workspace" "foobar" {
9496
organization = tfe_organization.foobar.id
9597
}
9698
99+
resource "tfe_project" "foobar" {
100+
name = "project-foo-%d"
101+
organization = tfe_organization.foobar.id
102+
}
103+
97104
resource "tfe_variable_set" "foobar" {
98105
name = "varset-foo-%d"
99106
description = "a description"
100107
organization = tfe_organization.foobar.id
101108
workspace_ids = [tfe_workspace.foobar.id]
109+
project_ids = [tfe_project.foobar.id]
102110
}
103111
104112
resource "tfe_variable" "envfoo" {
@@ -112,5 +120,5 @@ data "tfe_variable_set" "foobar" {
112120
name = tfe_variable_set.foobar.name
113121
organization = tfe_variable_set.foobar.organization
114122
depends_on = [tfe_variable.envfoo]
115-
}`, rInt, rInt, rInt)
123+
}`, rInt, rInt, rInt, rInt)
116124
}

website/docs/d/variable_set.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,4 @@ The following arguments are supported:
3636
* `global` - Whether or not the variable set applies to all workspaces in the organization.
3737
* `workspace_ids` - IDs of the workspaces that use the variable set.
3838
* `variable_ids` - IDs of the variables attached to the variable set.
39+
* `project_ids` - IDs of the projects that use the variable set.

0 commit comments

Comments
 (0)