Skip to content

Commit

Permalink
add folder_id as output to folder datasource and resource (#3763) (#2287
Browse files Browse the repository at this point in the history
)

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Jul 21, 2020
1 parent 594b60d commit d4a758e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .changelog/3763.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resourcemanager: added `folder_id` as computed attribute to `google_folder` resource and datasource.
```
4 changes: 4 additions & 0 deletions google-beta/data_source_google_folder.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ func dataSourceGoogleFolder() *schema.Resource {
Type: schema.TypeString,
Required: true,
},
"folder_id": {
Type: schema.TypeString,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func testAccCloudAssetFolderFeed_cloudAssetFolderFeedExample(context map[string]
# particular folder.
resource "google_cloud_asset_folder_feed" "folder_feed" {
billing_project = "%{project}"
folder = google_folder.my_folder.name
folder = google_folder.my_folder.folder_id
feed_id = "tf-test-network-updates%{random_suffix}"
content_type = "RESOURCE"
Expand Down
8 changes: 7 additions & 1 deletion google-beta/resource_google_folder.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ func resourceGoogleFolder() *schema.Resource {
Required: true,
Description: `The folder's display name. A folder's display name must be unique amongst its siblings, e.g. no two folders with the same parent can share the same display name. The display name must start and end with a letter or digit, may contain letters, digits, spaces, hyphens and underscores and can be no longer than 30 characters.`,
},

"folder_id": {
Type: schema.TypeString,
Computed: true,
Description: `The folder id from the name "folders/{folder_id}"`,
},
// Format is 'folders/{folder_id}.
// The terraform id holds the same value.
"name": {
Expand Down Expand Up @@ -119,6 +123,8 @@ func resourceGoogleFolderRead(d *schema.ResourceData, meta interface{}) error {
}

d.Set("name", folder.Name)
folderId := strings.TrimPrefix(folder.Name, "folders/")
d.Set("folder_id", folderId)
d.Set("parent", folder.Parent)
d.Set("display_name", folder.DisplayName)
d.Set("lifecycle_state", folder.LifecycleState)
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/cloud_asset_folder_feed.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ To get more information about FolderFeed, see:
# particular folder.
resource "google_cloud_asset_folder_feed" "folder_feed" {
billing_project = "my-project-name"
folder = google_folder.my_folder.name
folder = google_folder.my_folder.folder_id
feed_id = "network-updates"
content_type = "RESOURCE"
Expand Down

0 comments on commit d4a758e

Please sign in to comment.