Skip to content

Commit 5452ecf

Browse files
Add support for access boundaries (#7144) (#13565)
* Add support for access boundaries * Use IAM v2 API * Use handwritten test to avoid parallelism * Add update step to tests * gofmt Signed-off-by: Modular Magician <[email protected]> Signed-off-by: Modular Magician <[email protected]>
1 parent baf82a9 commit 5452ecf

9 files changed

+1183
-2
lines changed

.changelog/7144.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:new-resource
2+
`google_iam_access_boundary_policy`
3+
```

google/config.go

+4
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ type Config struct {
220220
GKEBackupBasePath string
221221
GKEHubBasePath string
222222
HealthcareBasePath string
223+
IAM2BasePath string
223224
IAMBetaBasePath string
224225
IAMWorkforcePoolBasePath string
225226
IapBasePath string
@@ -323,6 +324,7 @@ const GameServicesBasePathKey = "GameServices"
323324
const GKEBackupBasePathKey = "GKEBackup"
324325
const GKEHubBasePathKey = "GKEHub"
325326
const HealthcareBasePathKey = "Healthcare"
327+
const IAM2BasePathKey = "IAM2"
326328
const IAMBetaBasePathKey = "IAMBeta"
327329
const IAMWorkforcePoolBasePathKey = "IAMWorkforcePool"
328330
const IapBasePathKey = "Iap"
@@ -420,6 +422,7 @@ var DefaultBasePaths = map[string]string{
420422
GKEBackupBasePathKey: "https://gkebackup.googleapis.com/v1/",
421423
GKEHubBasePathKey: "https://gkehub.googleapis.com/v1/",
422424
HealthcareBasePathKey: "https://healthcare.googleapis.com/v1/",
425+
IAM2BasePathKey: "https://iam.googleapis.com/v2/",
423426
IAMBetaBasePathKey: "https://iam.googleapis.com/v1/",
424427
IAMWorkforcePoolBasePathKey: "https://iam.googleapis.com/v1/",
425428
IapBasePathKey: "https://iap.googleapis.com/v1/",
@@ -1279,6 +1282,7 @@ func ConfigureBasePaths(c *Config) {
12791282
c.GKEBackupBasePath = DefaultBasePaths[GKEBackupBasePathKey]
12801283
c.GKEHubBasePath = DefaultBasePaths[GKEHubBasePathKey]
12811284
c.HealthcareBasePath = DefaultBasePaths[HealthcareBasePathKey]
1285+
c.IAM2BasePath = DefaultBasePaths[IAM2BasePathKey]
12821286
c.IAMBetaBasePath = DefaultBasePaths[IAMBetaBasePathKey]
12831287
c.IAMWorkforcePoolBasePath = DefaultBasePaths[IAMWorkforcePoolBasePathKey]
12841288
c.IapBasePath = DefaultBasePaths[IapBasePathKey]

google/config_test_utils.go

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ func configureTestBasePaths(c *Config, url string) {
6767
c.GKEBackupBasePath = url
6868
c.GKEHubBasePath = url
6969
c.HealthcareBasePath = url
70+
c.IAM2BasePath = url
7071
c.IAMBetaBasePath = url
7172
c.IAMWorkforcePoolBasePath = url
7273
c.IapBasePath = url

google/iam2_operation.go

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// ----------------------------------------------------------------------------
2+
//
3+
// *** AUTO GENERATED CODE *** Type: MMv1 ***
4+
//
5+
// ----------------------------------------------------------------------------
6+
//
7+
// This file is automatically generated by Magic Modules and manual
8+
// changes will be clobbered when the file is regenerated.
9+
//
10+
// Please read more about how to change this file in
11+
// .github/CONTRIBUTING.md.
12+
//
13+
// ----------------------------------------------------------------------------
14+
15+
package google
16+
17+
import (
18+
"fmt"
19+
"time"
20+
)
21+
22+
type IAM2OperationWaiter struct {
23+
Config *Config
24+
UserAgent string
25+
CommonOperationWaiter
26+
}
27+
28+
func (w *IAM2OperationWaiter) QueryOp() (interface{}, error) {
29+
if w == nil {
30+
return nil, fmt.Errorf("Cannot query operation, it's unset or nil.")
31+
}
32+
// Returns the proper get.
33+
url := fmt.Sprintf("%s%s", w.Config.IAM2BasePath, w.CommonOperationWaiter.Op.Name)
34+
35+
return sendRequest(w.Config, "GET", "", url, w.UserAgent, nil)
36+
}
37+
38+
func createIAM2Waiter(config *Config, op map[string]interface{}, activity, userAgent string) (*IAM2OperationWaiter, error) {
39+
w := &IAM2OperationWaiter{
40+
Config: config,
41+
UserAgent: userAgent,
42+
}
43+
if err := w.CommonOperationWaiter.SetOp(op); err != nil {
44+
return nil, err
45+
}
46+
return w, nil
47+
}
48+
49+
func iAM2OperationWaitTime(config *Config, op map[string]interface{}, activity, userAgent string, timeout time.Duration) error {
50+
if val, ok := op["name"]; !ok || val == "" {
51+
// This was a synchronous call - there is no operation to wait for.
52+
return nil
53+
}
54+
w, err := createIAM2Waiter(config, op, activity, userAgent)
55+
if err != nil {
56+
// If w is nil, the op was synchronous.
57+
return err
58+
}
59+
return OperationWait(w, activity, timeout, config.PollInterval)
60+
}

google/provider.go

+12-2
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,14 @@ func Provider() *schema.Provider {
541541
"GOOGLE_HEALTHCARE_CUSTOM_ENDPOINT",
542542
}, DefaultBasePaths[HealthcareBasePathKey]),
543543
},
544+
"iam2_custom_endpoint": {
545+
Type: schema.TypeString,
546+
Optional: true,
547+
ValidateFunc: validateCustomEndpoint,
548+
DefaultFunc: schema.MultiEnvDefaultFunc([]string{
549+
"GOOGLE_IAM2_CUSTOM_ENDPOINT",
550+
}, DefaultBasePaths[IAM2BasePathKey]),
551+
},
544552
"iam_beta_custom_endpoint": {
545553
Type: schema.TypeString,
546554
Optional: true,
@@ -972,9 +980,9 @@ func Provider() *schema.Provider {
972980
return provider
973981
}
974982

975-
// Generated resources: 258
983+
// Generated resources: 259
976984
// Generated IAM resources: 168
977-
// Total generated resources: 426
985+
// Total generated resources: 427
978986
func ResourceMap() map[string]*schema.Resource {
979987
resourceMap, _ := ResourceMapWithErrors()
980988
return resourceMap
@@ -1252,6 +1260,7 @@ func ResourceMapWithErrors() (map[string]*schema.Resource, error) {
12521260
"google_healthcare_consent_store_iam_binding": ResourceIamBinding(HealthcareConsentStoreIamSchema, HealthcareConsentStoreIamUpdaterProducer, HealthcareConsentStoreIdParseFunc),
12531261
"google_healthcare_consent_store_iam_member": ResourceIamMember(HealthcareConsentStoreIamSchema, HealthcareConsentStoreIamUpdaterProducer, HealthcareConsentStoreIdParseFunc),
12541262
"google_healthcare_consent_store_iam_policy": ResourceIamPolicy(HealthcareConsentStoreIamSchema, HealthcareConsentStoreIamUpdaterProducer, HealthcareConsentStoreIdParseFunc),
1263+
"google_iam_access_boundary_policy": resourceIAM2AccessBoundaryPolicy(),
12551264
"google_iam_workload_identity_pool": resourceIAMBetaWorkloadIdentityPool(),
12561265
"google_iam_workload_identity_pool_provider": resourceIAMBetaWorkloadIdentityPoolProvider(),
12571266
"google_iam_workforce_pool": resourceIAMWorkforcePoolWorkforcePool(),
@@ -1669,6 +1678,7 @@ func providerConfigure(ctx context.Context, d *schema.ResourceData, p *schema.Pr
16691678
config.GKEBackupBasePath = d.Get("gke_backup_custom_endpoint").(string)
16701679
config.GKEHubBasePath = d.Get("gke_hub_custom_endpoint").(string)
16711680
config.HealthcareBasePath = d.Get("healthcare_custom_endpoint").(string)
1681+
config.IAM2BasePath = d.Get("iam2_custom_endpoint").(string)
16721682
config.IAMBetaBasePath = d.Get("iam_beta_custom_endpoint").(string)
16731683
config.IAMWorkforcePoolBasePath = d.Get("iam_workforce_pool_custom_endpoint").(string)
16741684
config.IapBasePath = d.Get("iap_custom_endpoint").(string)

0 commit comments

Comments
 (0)