-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding datasources for folder and project org policy
Signed-off-by: Modular Magician <magic-modules@google.com>
- Loading branch information
1 parent
42b2d22
commit ef88e78
Showing
6 changed files
with
141 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package google | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/hashicorp/terraform/helper/schema" | ||
) | ||
|
||
func dataSourceGoogleFolderOrganizationPolicy() *schema.Resource { | ||
// Generate datasource schema from resource | ||
dsSchema := datasourceSchemaFromResourceSchema(resourceGoogleFolderOrganizationPolicy().Schema) | ||
|
||
addRequiredFieldsToSchema(dsSchema, "folder") | ||
addRequiredFieldsToSchema(dsSchema, "constraint") | ||
|
||
return &schema.Resource{ | ||
Read: datasourceGoogleFolderOrganizationPolicyRead, | ||
Schema: dsSchema, | ||
} | ||
} | ||
|
||
func datasourceGoogleFolderOrganizationPolicyRead(d *schema.ResourceData, meta interface{}) error { | ||
|
||
d.SetId(fmt.Sprintf("%s:%s", d.Get("folder"), d.Get("constraint"))) | ||
|
||
return resourceGoogleFolderOrganizationPolicyRead(d, meta) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package google | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/hashicorp/terraform/helper/schema" | ||
) | ||
|
||
func dataSourceGoogleProjectOrganizationPolicy() *schema.Resource { | ||
// Generate datasource schema from resource | ||
dsSchema := datasourceSchemaFromResourceSchema(resourceGoogleProjectOrganizationPolicy().Schema) | ||
|
||
addRequiredFieldsToSchema(dsSchema, "project") | ||
addRequiredFieldsToSchema(dsSchema, "constraint") | ||
|
||
return &schema.Resource{ | ||
Read: datasourceGoogleProjectOrganizationPolicyRead, | ||
Schema: dsSchema, | ||
} | ||
} | ||
|
||
func datasourceGoogleProjectOrganizationPolicyRead(d *schema.ResourceData, meta interface{}) error { | ||
|
||
d.SetId(fmt.Sprintf("%s:%s", d.Get("project"), d.Get("constraint"))) | ||
|
||
return resourceGoogleProjectOrganizationPolicyRead(d, meta) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
website/docs/d/datasource_google_folder_organization_policy.html.markdown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
layout: "google" | ||
page_title: "Google: google_folder_organization_policy" | ||
sidebar_current: "docs-google-datasource-folder-organization-policy" | ||
description: |- | ||
Retrieve Organization policies for a Google Folder | ||
--- | ||
|
||
# google\_folder\_organization\_policy | ||
|
||
Allows management of Organization policies for a Google Folder. For more information see | ||
[the official | ||
documentation](https://cloud.google.com/resource-manager/docs/organization-policy/overview) | ||
|
||
## Example Usage | ||
|
||
```hcl | ||
data "google_folder_organization_policy" "policy" { | ||
folder = "folders/folderid" | ||
constraint = "constraints/compute.trustedImageProjects" | ||
} | ||
output "version" { | ||
value = "${data.google_folder_organization_policy.policy.version}" | ||
} | ||
``` | ||
|
||
## Argument Reference | ||
|
||
The following arguments are supported: | ||
|
||
* `folder` - (Required) The resource name of the folder to set the policy for. Its format is folders/{folder_id}. | ||
|
||
* `constraint` - (Required) (Required) The name of the Constraint the Policy is configuring, for example, `serviceuser.services`. Check out the [complete list of available constraints](https://cloud.google.com/resource-manager/docs/organization-policy/understanding-constraints#available_constraints). | ||
|
||
|
||
## Attributes Reference | ||
|
||
See [google_folder_organization_policy](https://www.terraform.io/docs/providers/google/r/google_folder_organization_policy.html) resource for details of the available attributes. |
40 changes: 40 additions & 0 deletions
40
website/docs/d/datasource_google_project_organization_policy.html.markdown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--- | ||
layout: "google" | ||
page_title: "Google: google_project_organization_policy" | ||
sidebar_current: "docs-google-datasource-project-organization-policy" | ||
description: |- | ||
Retrieve Organization policies for a Google Project. | ||
--- | ||
|
||
# google\_project\_organization\_policy | ||
|
||
Allows management of Organization policies for a Google Project. For more information see | ||
[the official | ||
documentation](https://cloud.google.com/resource-manager/docs/organization-policy/overview) | ||
|
||
## Example Usage | ||
|
||
```hcl | ||
data "google_project_organization_policy" "policy" { | ||
project = "project-id" | ||
constraint = "constraints/serviceuser.services" | ||
} | ||
output "version" { | ||
value = "${data.google_project_organization_policy.policy.version}" | ||
} | ||
``` | ||
|
||
## Argument Reference | ||
|
||
The following arguments are supported: | ||
|
||
* `project` - (Required) The project ID. | ||
|
||
* `constraint` - (Required) (Required) The name of the Constraint the Policy is configuring, for example, `serviceuser.services`. Check out the [complete list of available constraints](https://cloud.google.com/resource-manager/docs/organization-policy/understanding-constraints#available_constraints). | ||
|
||
|
||
## Attributes Reference | ||
|
||
See [google_project_organization_policy](https://www.terraform.io/docs/providers/google/r/google_project.html) resource for details of the available attributes. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters