-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
adding data source for identity pool provider #4181
Merged
rileykarson
merged 13 commits into
GoogleCloudPlatform:master
from
wvanderdeijl:identity-fed-pool-provider-data-source
Nov 6, 2020
Merged
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
bf8be14
add iam workload identity pool provider
wvanderdeijl 0f737e6
Apply suggestions from code review
wvanderdeijl 722051c
make clear that name and self_link contain project number, not id
wvanderdeijl 6a8f2ee
fixed wrong file naming
wvanderdeijl 477ffa7
sync provider docs to pool docs
wvanderdeijl 4112f07
add tests for provider
wvanderdeijl e4b227f
workload identity resources have no self_link
wvanderdeijl 6ef4396
Merge branch 'master' into workload-identity-federation-provider
wvanderdeijl 7f61a29
treat delete state as gone
wvanderdeijl 273a3b8
Merge branch 'master' into identity-fed-pool-provider-data-source
wvanderdeijl 9f431ca
google_iam_workload_identity_pool_provider data source
wvanderdeijl 52e989a
Merge branch 'master' into identity-fed-pool-provider-data-source
wvanderdeijl adead0d
Make sure provider depends on pool
wvanderdeijl 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
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
33 changes: 33 additions & 0 deletions
33
..._party/terraform/data_sources/data_source_iam_beta_workload_identity_pool_provider.go.erb
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,33 @@ | ||
<% autogen_exception -%> | ||
package google | ||
|
||
<% unless version == 'ga' -%> | ||
import ( | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
func dataSourceIAMBetaWorkloadIdentityPoolProvider() *schema.Resource { | ||
|
||
dsSchema := datasourceSchemaFromResourceSchema(resourceIAMBetaWorkloadIdentityPoolProvider().Schema) | ||
addRequiredFieldsToSchema(dsSchema, "workload_identity_pool_id") | ||
addRequiredFieldsToSchema(dsSchema, "workload_identity_pool_provider_id") | ||
addOptionalFieldsToSchema(dsSchema, "project") | ||
|
||
return &schema.Resource{ | ||
Read: dataSourceIAMBetaWorkloadIdentityPoolProviderRead, | ||
Schema: dsSchema, | ||
} | ||
} | ||
|
||
func dataSourceIAMBetaWorkloadIdentityPoolProviderRead(d *schema.ResourceData, meta interface{}) error { | ||
config := meta.(*Config) | ||
|
||
id, err := replaceVars(d, config, "projects/{{project}}/locations/global/workloadIdentityPools/{{workload_identity_pool_id}}/providers/{{workload_identity_pool_provider_id}}") | ||
if err != nil { | ||
return fmt.Errorf("Error constructing id: %s", err) | ||
} | ||
d.SetId(id) | ||
return resourceIAMBetaWorkloadIdentityPoolProviderRead(d, meta) | ||
|
||
} | ||
<% end -%> |
61 changes: 61 additions & 0 deletions
61
third_party/terraform/tests/data_source_iam_beta_workload_identity_pool_provider_test.go.erb
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,61 @@ | ||
<% autogen_exception -%> | ||
package google | ||
|
||
<% unless version == 'ga' -%> | ||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
func TestAccDataSourceIAMBetaWorkloadIdentityPoolProvider_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: testAccCheckIAMBetaWorkloadIdentityPoolProviderDestroyProducer(t), | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccDataSourceIAMBetaWorkloadIdentityPoolProviderBasic(context), | ||
Check: resource.ComposeTestCheckFunc( | ||
checkDataSourceStateMatchesResourceState("data.google_iam_workload_identity_pool_provider.foo", "google_iam_workload_identity_pool_provider.bar"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccDataSourceIAMBetaWorkloadIdentityPoolProviderBasic(context map[string]interface{}) string { | ||
return Nprintf(` | ||
resource "google_iam_workload_identity_pool" "pool" { | ||
workload_identity_pool_id = "pool-%{random_suffix}" | ||
} | ||
|
||
resource "google_iam_workload_identity_pool_provider" "bar" { | ||
workload_identity_pool_id = "pool-%{random_suffix}" | ||
workload_identity_pool_provider_id = "bar-provider-%{random_suffix}" | ||
display_name = "Name of provider" | ||
description = "OIDC identity pool provider for automated test" | ||
disabled = true | ||
attribute_condition = "\"e968c2ef-047c-498d-8d79-16ca1b61e77e\" in assertion.groups" | ||
attribute_mapping = { | ||
"google.subject" = "assertion.sub" | ||
} | ||
oidc { | ||
allowed_audiences = ["https://example.com/gcp-oidc-federation"] | ||
issuer_uri = "https://sts.windows.net/azure-tenant-id" | ||
} | ||
} | ||
|
||
data "google_iam_workload_identity_pool_provider" "foo" { | ||
workload_identity_pool_id = google_iam_workload_identity_pool.pool.workload_identity_pool_id | ||
workload_identity_pool_provider_id = google_iam_workload_identity_pool_provider.bar.workload_identity_pool_provider_id | ||
} | ||
`, context) | ||
} | ||
<% end -%> |
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
41 changes: 41 additions & 0 deletions
41
third_party/terraform/website/docs/d/iam_workload_identity_pool_provider.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,41 @@ | ||
--- | ||
subcategory: "Cloud IAM" | ||
layout: "google" | ||
page_title: "Google: google_iam_workload_identity_pool_provider" | ||
sidebar_current: "docs-google-datasource-iam-workload-identity-pool-provider" | ||
description: |- | ||
Get a IAM workload identity pool provider from Google Cloud | ||
--- | ||
|
||
# google\_iam\_workload_\identity\_pool\_provider | ||
|
||
Get a IAM workload identity provider from Google Cloud by its id. | ||
|
||
~> **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_provider" "foo" { | ||
workload_identity_pool_id = "foo-pool" | ||
workload_identity_pool_provider_id = "bar-provider" | ||
} | ||
``` | ||
|
||
## Argument Reference | ||
|
||
The following arguments are supported: | ||
|
||
* `workload_identity_pool_id` - (Required) The id of the pool which is the | ||
final component of the pool resource name. | ||
* `workload_identity_pool_provider_id` - (Required) The id of the provider 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_provider](https://www.terraform.io/docs/providers/google/r/iam_workload_identity_pool_provider.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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll want to interpolate this value off the
google_iam_workload_identity_pool
above, otherwise this gets created at the same time as it's parent.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed it