From d4a758e12c7b14c09906b2cf3529077965fe0993 Mon Sep 17 00:00:00 2001 From: The Magician Date: Tue, 21 Jul 2020 14:09:27 -0700 Subject: [PATCH] add folder_id as output to folder datasource and resource (#3763) (#2287) Signed-off-by: Modular Magician --- .changelog/3763.txt | 3 +++ google-beta/data_source_google_folder.go | 4 ++++ .../resource_cloud_asset_folder_feed_generated_test.go | 2 +- google-beta/resource_google_folder.go | 8 +++++++- website/docs/r/cloud_asset_folder_feed.html.markdown | 2 +- 5 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 .changelog/3763.txt diff --git a/.changelog/3763.txt b/.changelog/3763.txt new file mode 100644 index 0000000000..36c2ef2c34 --- /dev/null +++ b/.changelog/3763.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resourcemanager: added `folder_id` as computed attribute to `google_folder` resource and datasource. +``` diff --git a/google-beta/data_source_google_folder.go b/google-beta/data_source_google_folder.go index fc2f3e08c6..6960228f89 100644 --- a/google-beta/data_source_google_folder.go +++ b/google-beta/data_source_google_folder.go @@ -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, diff --git a/google-beta/resource_cloud_asset_folder_feed_generated_test.go b/google-beta/resource_cloud_asset_folder_feed_generated_test.go index 6f584c6b75..ea66fe4922 100644 --- a/google-beta/resource_cloud_asset_folder_feed_generated_test.go +++ b/google-beta/resource_cloud_asset_folder_feed_generated_test.go @@ -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" diff --git a/google-beta/resource_google_folder.go b/google-beta/resource_google_folder.go index e653119423..61bfb4195f 100644 --- a/google-beta/resource_google_folder.go +++ b/google-beta/resource_google_folder.go @@ -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": { @@ -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) diff --git a/website/docs/r/cloud_asset_folder_feed.html.markdown b/website/docs/r/cloud_asset_folder_feed.html.markdown index 704b389444..b19bd43ca1 100644 --- a/website/docs/r/cloud_asset_folder_feed.html.markdown +++ b/website/docs/r/cloud_asset_folder_feed.html.markdown @@ -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"