Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<% autogen_exception -%>
package google

<% unless version == 'ga' -%>
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func dataSourceIAMBetaWorkloadIdentityPool() *schema.Resource {

dsSchema := (resourceIAMBetaWorkloadIdentityPool().Schema)
addRequiredFieldsToSchema(dsSchema, "workload_identity_pool_id")
addOptionalFieldsToSchema(dsSchema, "project")

return &schema.Resource{
Read: dataSourceIAMBetaWorkloadIdentityPoolRead,
Schema: dsSchema,
}
}

func dataSourceIAMBetaWorkloadIdentityPoolRead(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)

id, err := replaceVars(d, config, "projects/{{project}}/locations/global/workloadIdentityPools/{{workload_identity_pool_id}}")
if err != nil {
return fmt.Errorf("Error constructing id: %s", err)
}
d.SetId(id)
return resourceIAMBetaWorkloadIdentityPoolRead(d, meta)

}
<% end -%>
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<% autogen_exception -%>
package google

<% unless version == 'ga' -%>
import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestAccDataSourceIAMBetaWorkloadIdentityPool_basic(t *testing.T) {
t.Parallel()

context := map[string]interface{}{
"random_suffix": randString(t, 10),
}

vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckIAMBetaWorkloadIdentityPoolDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccDataSourceIAMBetaWorkloadIdentityPoolBasic(context),
Check: resource.ComposeTestCheckFunc(
checkDataSourceStateMatchesResourceState("data.google_iam_workload_identity_pool.foo", "google_iam_workload_identity_pool.bar"),
),
},
},
})
}

func testAccDataSourceIAMBetaWorkloadIdentityPoolBasic(context map[string]interface{}) string {
return Nprintf(`
resource "google_iam_workload_identity_pool" "bar" {
workload_identity_pool_id = "bar-pool-%{random_suffix}"
display_name = "Name of pool"
description = "Identity pool for automated test"
disabled = true
}

data "google_iam_workload_identity_pool" "foo" {
workload_identity_pool_id = google_iam_workload_identity_pool.bar.workload_identity_pool_id
}
`, context)
}
<% end -%>
3 changes: 3 additions & 0 deletions third_party/terraform/utils/provider.go.erb
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ func Provider() *schema.Provider {
"google_iam_policy": dataSourceGoogleIamPolicy(),
"google_iam_role": dataSourceGoogleIamRole(),
"google_iam_testable_permissions": dataSourceGoogleIamTestablePermissions(),
<% unless version == 'ga' -%>
"google_iam_workload_identity_pool": dataSourceIAMBetaWorkloadIdentityPool(),
<% end -%>
"google_kms_crypto_key": dataSourceGoogleKmsCryptoKey(),
"google_kms_crypto_key_version": dataSourceGoogleKmsCryptoKeyVersion(),
"google_kms_key_ring": dataSourceGoogleKmsKeyRing(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
subcategory: "Cloud IAM"
layout: "google"
page_title: "Google: google_iam_workload_identity_pool"
sidebar_current: "docs-google-datasource-iam-workload-identity-pool"
description: |-
Get a IAM workload identity pool from Google Cloud
---

# google\_iam\_workload_\identity\_pool

Get a IAM workload identity pool from Google Cloud by its id.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably want a note that this resource is in beta only here:

~> **Warning:** This resource is in beta, and should be used with the terraform-provider-google-beta provider.
See [Provider Versions](https://terraform.io/docs/providers/google/guides/provider_versions.html) for more details on beta resources.

is the one that we generally use

Similar to: https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_managed_ssl_certificate

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

~> **Warning:** This resource is in beta, and should be used with the terraform-provider-google-beta provider.
See [Provider Versions](https://terraform.io/docs/providers/google/guides/provider_versions.html) for more details on beta resources.

## Example Usage

```tf
data "google_iam_workload_identity_pool" "foo" {
workload_identity_pool_id = "foo-pool"
}
```

## Argument Reference

The following arguments are supported:

* `workload_identity_pool_id` - (Required) The id of the pool which is the
final component of the resource name.

- - -

* `project` - (Optional) The project in which the resource belongs. If it
is not provided, the provider project is used.

## Attributes Reference
See [google_iam_workload_identity_pool](https://www.terraform.io/docs/providers/google/r/iam_workload_identity_pool.html) resource for details of all the available attributes.