-
Notifications
You must be signed in to change notification settings - Fork 2.2k
adding data source for identity pool #4134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
slevenick
merged 3 commits into
GoogleCloudPlatform:master
from
wvanderdeijl:identity-fed-pool-data-source
Oct 30, 2020
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
third_party/terraform/data_sources/data_source_iam_beta_workload_identity_pool.go.erb
This file contains hidden or 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,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 -%> | ||
47 changes: 47 additions & 0 deletions
47
third_party/terraform/tests/data_source_iam_beta_workload_identity_pool_test.go.erb
This file contains hidden or 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,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 | ||
slevenick marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| `, context) | ||
| } | ||
| <% end -%> | ||
This file contains hidden or 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
38 changes: 38 additions & 0 deletions
38
third_party/terraform/website/docs/d/iam_workload_identity_pool.markdown
This file contains hidden or 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,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. | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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: is the one that we generally use
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.