Create GCP folders using terraform
Trying to create a folder under a organisation in GCP using terraform seems to be annoying.
I have just a simple main.tf and variables.tf files that are looking like this:
main.tf:
display_name = var.folder_name
parent = "organizations/${996491585571}"
}```
variables.tf:
type = string
description = "The ID of the parent"
default = "996491585571"
}
variable "folder_name" {
type = string
description = "The name of the folder to be created"
default = "folder-test"
}```
The idea here is that the folder is created because I can list it via cli, but when I go and check the web console the folder is not listed under the organisation.
So on cli it looks ok and in the web console not.
Here is the terraform command
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
### # google_folder.parent_folder_creation will be created
+ resource "google_folder" "parent_folder_creation" {
+ create_time = (known after apply)
+ display_name = "folder-test"
+ folder_id = (known after apply)
+ id = (known after apply)
+ lifecycle_state = (known after apply)
+ name = (known after apply)
+ parent = "organizations/996491585571"
}
Plan: 1 to add, 0 to change, 0 to destroy.
google_folder.parent_folder_creation: Creating...
google_folder.parent_folder_creation: Still creating... [10s elapsed]
google_folder.parent_folder_creation: Creation complete after 14s [id=folders/629504649365]
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.```
The cli return that the folder is created
gcloud resource-manager folders list --organization 996491585571
DISPLAY_NAME PARENT_NAME ID
folder-test organizations/996491585571 629504649365
gcloud resource-manager folders describe 629504649365
createTime: '2022-10-06T08:50:10.151Z'
displayName: folder-test
lifecycleState: ACTIVE
name: folders/629504649365
parent: organizations/996491585571
But looking at the web console

I will investigate further why this is not showing in the console and I will update the post.