Skip to content

Add new resource iam_projects_policy_binding. addresses https://github.com/hashicorp/terraform-provider-google/issues/20198 #8756

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
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
3 changes: 3 additions & 0 deletions .changelog/12302.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:new-resource
`google_iam_projects_policy_binding` (beta)
```
5 changes: 3 additions & 2 deletions google-beta/provider/provider_mmv1_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -505,9 +505,9 @@ var handwrittenIAMDatasources = map[string]*schema.Resource{
}

// Resources
// Generated resources: 556
// Generated resources: 557
// Generated IAM resources: 291
// Total generated resources: 847
// Total generated resources: 848
var generatedResources = map[string]*schema.Resource{
"google_folder_access_approval_settings": accessapproval.ResourceAccessApprovalFolderSettings(),
"google_organization_access_approval_settings": accessapproval.ResourceAccessApprovalOrganizationSettings(),
Expand Down Expand Up @@ -1019,6 +1019,7 @@ var generatedResources = map[string]*schema.Resource{
"google_iam_folders_policy_binding": iam3.ResourceIAM3FoldersPolicyBinding(),
"google_iam_organizations_policy_binding": iam3.ResourceIAM3OrganizationsPolicyBinding(),
"google_iam_principal_access_boundary_policy": iam3.ResourceIAM3PrincipalAccessBoundaryPolicy(),
"google_iam_projects_policy_binding": iam3.ResourceIAM3ProjectsPolicyBinding(),
"google_iam_workload_identity_pool": iambeta.ResourceIAMBetaWorkloadIdentityPool(),
"google_iam_workload_identity_pool_provider": iambeta.ResourceIAMBetaWorkloadIdentityPoolProvider(),
"google_iam_workforce_pool": iamworkforcepool.ResourceIAMWorkforcePoolWorkforcePool(),
Expand Down
13 changes: 8 additions & 5 deletions google-beta/services/iam3/iam3_operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
type IAM3OperationWaiter struct {
Config *transport_tpg.Config
UserAgent string
Project string
tpgresource.CommonOperationWaiter
}

Expand All @@ -43,15 +44,17 @@ func (w *IAM3OperationWaiter) QueryOp() (interface{}, error) {
return transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Config: w.Config,
Method: "GET",
Project: w.Project,
RawURL: url,
UserAgent: w.UserAgent,
})
}

func createIAM3Waiter(config *transport_tpg.Config, op map[string]interface{}, activity, userAgent string) (*IAM3OperationWaiter, error) {
func createIAM3Waiter(config *transport_tpg.Config, op map[string]interface{}, project, activity, userAgent string) (*IAM3OperationWaiter, error) {
w := &IAM3OperationWaiter{
Config: config,
UserAgent: userAgent,
Project: project,
}
if err := w.CommonOperationWaiter.SetOp(op); err != nil {
return nil, err
Expand All @@ -60,8 +63,8 @@ func createIAM3Waiter(config *transport_tpg.Config, op map[string]interface{}, a
}

// nolint: deadcode,unused
func IAM3OperationWaitTimeWithResponse(config *transport_tpg.Config, op map[string]interface{}, response *map[string]interface{}, activity, userAgent string, timeout time.Duration) error {
w, err := createIAM3Waiter(config, op, activity, userAgent)
func IAM3OperationWaitTimeWithResponse(config *transport_tpg.Config, op map[string]interface{}, response *map[string]interface{}, project, activity, userAgent string, timeout time.Duration) error {
w, err := createIAM3Waiter(config, op, project, activity, userAgent)
if err != nil {
return err
}
Expand All @@ -75,12 +78,12 @@ func IAM3OperationWaitTimeWithResponse(config *transport_tpg.Config, op map[stri
return json.Unmarshal(rawResponse, response)
}

func IAM3OperationWaitTime(config *transport_tpg.Config, op map[string]interface{}, activity, userAgent string, timeout time.Duration) error {
func IAM3OperationWaitTime(config *transport_tpg.Config, op map[string]interface{}, project, activity, userAgent string, timeout time.Duration) error {
if val, ok := op["name"]; !ok || val == "" {
// This was a synchronous call - there is no operation to wait for.
return nil
}
w, err := createIAM3Waiter(config, op, activity, userAgent)
w, err := createIAM3Waiter(config, op, project, activity, userAgent)
if err != nil {
// If w is nil, the op was synchronous.
return err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ to the policy kind) - The input policy kind Possible values: POLICY_KIND_UNSP
}

func resourceIAM3FoldersPolicyBindingCreate(d *schema.ResourceData, meta interface{}) error {
var project string
config := meta.(*transport_tpg.Config)
userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent)
if err != nil {
Expand Down Expand Up @@ -295,7 +296,7 @@ func resourceIAM3FoldersPolicyBindingCreate(d *schema.ResourceData, meta interfa
// identity fields and d.Id() before read
var opRes map[string]interface{}
err = IAM3OperationWaitTimeWithResponse(
config, res, &opRes, "Creating FoldersPolicyBinding", userAgent,
config, res, &opRes, project, "Creating FoldersPolicyBinding", userAgent,
d.Timeout(schema.TimeoutCreate))
if err != nil {
// The resource didn't actually create
Expand Down Expand Up @@ -396,6 +397,7 @@ func resourceIAM3FoldersPolicyBindingRead(d *schema.ResourceData, meta interface
}

func resourceIAM3FoldersPolicyBindingUpdate(d *schema.ResourceData, meta interface{}) error {
var project string
config := meta.(*transport_tpg.Config)
userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent)
if err != nil {
Expand Down Expand Up @@ -486,7 +488,7 @@ func resourceIAM3FoldersPolicyBindingUpdate(d *schema.ResourceData, meta interfa
}

err = IAM3OperationWaitTime(
config, res, "Updating FoldersPolicyBinding", userAgent,
config, res, project, "Updating FoldersPolicyBinding", userAgent,
d.Timeout(schema.TimeoutUpdate))

if err != nil {
Expand All @@ -498,6 +500,7 @@ func resourceIAM3FoldersPolicyBindingUpdate(d *schema.ResourceData, meta interfa
}

func resourceIAM3FoldersPolicyBindingDelete(d *schema.ResourceData, meta interface{}) error {
var project string
config := meta.(*transport_tpg.Config)
userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent)
if err != nil {
Expand Down Expand Up @@ -536,7 +539,7 @@ func resourceIAM3FoldersPolicyBindingDelete(d *schema.ResourceData, meta interfa
}

err = IAM3OperationWaitTime(
config, res, "Deleting FoldersPolicyBinding", userAgent,
config, res, project, "Deleting FoldersPolicyBinding", userAgent,
d.Timeout(schema.TimeoutDelete))

if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ to the policy kind) - The input policy kind Possible values: POLICY_KIND_UNSP
}

func resourceIAM3OrganizationsPolicyBindingCreate(d *schema.ResourceData, meta interface{}) error {
var project string
config := meta.(*transport_tpg.Config)
userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent)
if err != nil {
Expand Down Expand Up @@ -295,7 +296,7 @@ func resourceIAM3OrganizationsPolicyBindingCreate(d *schema.ResourceData, meta i
// identity fields and d.Id() before read
var opRes map[string]interface{}
err = IAM3OperationWaitTimeWithResponse(
config, res, &opRes, "Creating OrganizationsPolicyBinding", userAgent,
config, res, &opRes, project, "Creating OrganizationsPolicyBinding", userAgent,
d.Timeout(schema.TimeoutCreate))
if err != nil {
// The resource didn't actually create
Expand Down Expand Up @@ -396,6 +397,7 @@ func resourceIAM3OrganizationsPolicyBindingRead(d *schema.ResourceData, meta int
}

func resourceIAM3OrganizationsPolicyBindingUpdate(d *schema.ResourceData, meta interface{}) error {
var project string
config := meta.(*transport_tpg.Config)
userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent)
if err != nil {
Expand Down Expand Up @@ -486,7 +488,7 @@ func resourceIAM3OrganizationsPolicyBindingUpdate(d *schema.ResourceData, meta i
}

err = IAM3OperationWaitTime(
config, res, "Updating OrganizationsPolicyBinding", userAgent,
config, res, project, "Updating OrganizationsPolicyBinding", userAgent,
d.Timeout(schema.TimeoutUpdate))

if err != nil {
Expand All @@ -498,6 +500,7 @@ func resourceIAM3OrganizationsPolicyBindingUpdate(d *schema.ResourceData, meta i
}

func resourceIAM3OrganizationsPolicyBindingDelete(d *schema.ResourceData, meta interface{}) error {
var project string
config := meta.(*transport_tpg.Config)
userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent)
if err != nil {
Expand Down Expand Up @@ -536,7 +539,7 @@ func resourceIAM3OrganizationsPolicyBindingDelete(d *schema.ResourceData, meta i
}

err = IAM3OperationWaitTime(
config, res, "Deleting OrganizationsPolicyBinding", userAgent,
config, res, project, "Deleting OrganizationsPolicyBinding", userAgent,
d.Timeout(schema.TimeoutDelete))

if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ won't get updated when new versions are released.`,
}

func resourceIAM3PrincipalAccessBoundaryPolicyCreate(d *schema.ResourceData, meta interface{}) error {
var project string
config := meta.(*transport_tpg.Config)
userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent)
if err != nil {
Expand Down Expand Up @@ -247,7 +248,7 @@ func resourceIAM3PrincipalAccessBoundaryPolicyCreate(d *schema.ResourceData, met
// identity fields and d.Id() before read
var opRes map[string]interface{}
err = IAM3OperationWaitTimeWithResponse(
config, res, &opRes, "Creating PrincipalAccessBoundaryPolicy", userAgent,
config, res, &opRes, project, "Creating PrincipalAccessBoundaryPolicy", userAgent,
d.Timeout(schema.TimeoutCreate))
if err != nil {
// The resource didn't actually create
Expand Down Expand Up @@ -336,6 +337,7 @@ func resourceIAM3PrincipalAccessBoundaryPolicyRead(d *schema.ResourceData, meta
}

func resourceIAM3PrincipalAccessBoundaryPolicyUpdate(d *schema.ResourceData, meta interface{}) error {
var project string
config := meta.(*transport_tpg.Config)
userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent)
if err != nil {
Expand Down Expand Up @@ -416,7 +418,7 @@ func resourceIAM3PrincipalAccessBoundaryPolicyUpdate(d *schema.ResourceData, met
}

err = IAM3OperationWaitTime(
config, res, "Updating PrincipalAccessBoundaryPolicy", userAgent,
config, res, project, "Updating PrincipalAccessBoundaryPolicy", userAgent,
d.Timeout(schema.TimeoutUpdate))

if err != nil {
Expand All @@ -428,6 +430,7 @@ func resourceIAM3PrincipalAccessBoundaryPolicyUpdate(d *schema.ResourceData, met
}

func resourceIAM3PrincipalAccessBoundaryPolicyDelete(d *schema.ResourceData, meta interface{}) error {
var project string
config := meta.(*transport_tpg.Config)
userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent)
if err != nil {
Expand Down Expand Up @@ -466,7 +469,7 @@ func resourceIAM3PrincipalAccessBoundaryPolicyDelete(d *schema.ResourceData, met
}

err = IAM3OperationWaitTime(
config, res, "Deleting PrincipalAccessBoundaryPolicy", userAgent,
config, res, project, "Deleting PrincipalAccessBoundaryPolicy", userAgent,
d.Timeout(schema.TimeoutDelete))

if err != nil {
Expand Down
Loading