Skip to content

Commit 9d382fd

Browse files
Add basic deny policy support (#5854) (#4194)
* Add basic deny policy support Add etag to update Add folder test * Fix format for SA principal * IAM deny test is only beta * Make deny policies in new projects to avoid conflicts * Dates * PR feedback Signed-off-by: Modular Magician <[email protected]>
1 parent 0be2639 commit 9d382fd

File tree

10 files changed

+1379
-2
lines changed

10 files changed

+1379
-2
lines changed

.changelog/5854.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:new-resource
2+
google_iam_deny_policy
3+
```

google-beta/config.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ type Config struct {
203203
GameServicesBasePath string
204204
GKEHubBasePath string
205205
HealthcareBasePath string
206+
IAM2BasePath string
206207
IAMBetaBasePath string
207208
IapBasePath string
208209
IdentityPlatformBasePath string
@@ -312,6 +313,7 @@ const FirestoreBasePathKey = "Firestore"
312313
const GameServicesBasePathKey = "GameServices"
313314
const GKEHubBasePathKey = "GKEHub"
314315
const HealthcareBasePathKey = "Healthcare"
316+
const IAM2BasePathKey = "IAM2"
315317
const IAMBetaBasePathKey = "IAMBeta"
316318
const IapBasePathKey = "Iap"
317319
const IdentityPlatformBasePathKey = "IdentityPlatform"
@@ -404,6 +406,7 @@ var DefaultBasePaths = map[string]string{
404406
GameServicesBasePathKey: "https://gameservices.googleapis.com/v1beta/",
405407
GKEHubBasePathKey: "https://gkehub.googleapis.com/v1beta1/",
406408
HealthcareBasePathKey: "https://healthcare.googleapis.com/v1beta1/",
409+
IAM2BasePathKey: "https://iam.googleapis.com/v2beta/",
407410
IAMBetaBasePathKey: "https://iam.googleapis.com/v1beta/",
408411
IapBasePathKey: "https://iap.googleapis.com/v1/",
409412
IdentityPlatformBasePathKey: "https://identitytoolkit.googleapis.com/v2/",
@@ -1272,6 +1275,7 @@ func ConfigureBasePaths(c *Config) {
12721275
c.GameServicesBasePath = DefaultBasePaths[GameServicesBasePathKey]
12731276
c.GKEHubBasePath = DefaultBasePaths[GKEHubBasePathKey]
12741277
c.HealthcareBasePath = DefaultBasePaths[HealthcareBasePathKey]
1278+
c.IAM2BasePath = DefaultBasePaths[IAM2BasePathKey]
12751279
c.IAMBetaBasePath = DefaultBasePaths[IAMBetaBasePathKey]
12761280
c.IapBasePath = DefaultBasePaths[IapBasePathKey]
12771281
c.IdentityPlatformBasePath = DefaultBasePaths[IdentityPlatformBasePathKey]

google-beta/iam2_operation.go

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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+
package google
15+
16+
import (
17+
"fmt"
18+
"time"
19+
)
20+
21+
type IAM2OperationWaiter struct {
22+
Config *Config
23+
UserAgent string
24+
CommonOperationWaiter
25+
}
26+
27+
func (w *IAM2OperationWaiter) QueryOp() (interface{}, error) {
28+
if w == nil {
29+
return nil, fmt.Errorf("Cannot query operation, it's unset or nil.")
30+
}
31+
// Returns the proper get.
32+
url := fmt.Sprintf("%s%s", w.Config.IAM2BasePath, w.CommonOperationWaiter.Op.Name)
33+
34+
return sendRequest(w.Config, "GET", "", url, w.UserAgent, nil)
35+
}
36+
37+
func createIAM2Waiter(config *Config, op map[string]interface{}, activity, userAgent string) (*IAM2OperationWaiter, error) {
38+
w := &IAM2OperationWaiter{
39+
Config: config,
40+
UserAgent: userAgent,
41+
}
42+
if err := w.CommonOperationWaiter.SetOp(op); err != nil {
43+
return nil, err
44+
}
45+
return w, nil
46+
}
47+
48+
func iAM2OperationWaitTime(config *Config, op map[string]interface{}, activity, userAgent string, timeout time.Duration) error {
49+
if val, ok := op["name"]; !ok || val == "" {
50+
// This was a synchronous call - there is no operation to wait for.
51+
return nil
52+
}
53+
w, err := createIAM2Waiter(config, op, activity, userAgent)
54+
if err != nil {
55+
// If w is nil, the op was synchronous.
56+
return err
57+
}
58+
return OperationWait(w, activity, timeout, config.PollInterval)
59+
}

google-beta/provider.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,14 @@ func Provider() *schema.Provider {
485485
"GOOGLE_HEALTHCARE_CUSTOM_ENDPOINT",
486486
}, DefaultBasePaths[HealthcareBasePathKey]),
487487
},
488+
"iam2_custom_endpoint": {
489+
Type: schema.TypeString,
490+
Optional: true,
491+
ValidateFunc: validateCustomEndpoint,
492+
DefaultFunc: schema.MultiEnvDefaultFunc([]string{
493+
"GOOGLE_IAM2_CUSTOM_ENDPOINT",
494+
}, DefaultBasePaths[IAM2BasePathKey]),
495+
},
488496
"iam_beta_custom_endpoint": {
489497
Type: schema.TypeString,
490498
Optional: true,
@@ -918,9 +926,9 @@ func Provider() *schema.Provider {
918926
return provider
919927
}
920928

921-
// Generated resources: 246
929+
// Generated resources: 247
922930
// Generated IAM resources: 135
923-
// Total generated resources: 381
931+
// Total generated resources: 382
924932
func ResourceMap() map[string]*schema.Resource {
925933
resourceMap, _ := ResourceMapWithErrors()
926934
return resourceMap
@@ -1169,6 +1177,7 @@ func ResourceMapWithErrors() (map[string]*schema.Resource, error) {
11691177
"google_healthcare_consent_store_iam_binding": ResourceIamBinding(HealthcareConsentStoreIamSchema, HealthcareConsentStoreIamUpdaterProducer, HealthcareConsentStoreIdParseFunc),
11701178
"google_healthcare_consent_store_iam_member": ResourceIamMember(HealthcareConsentStoreIamSchema, HealthcareConsentStoreIamUpdaterProducer, HealthcareConsentStoreIdParseFunc),
11711179
"google_healthcare_consent_store_iam_policy": ResourceIamPolicy(HealthcareConsentStoreIamSchema, HealthcareConsentStoreIamUpdaterProducer, HealthcareConsentStoreIdParseFunc),
1180+
"google_iam_deny_policy": resourceIAM2DenyPolicy(),
11721181
"google_iam_workload_identity_pool": resourceIAMBetaWorkloadIdentityPool(),
11731182
"google_iam_workload_identity_pool_provider": resourceIAMBetaWorkloadIdentityPoolProvider(),
11741183
"google_iap_web_iam_binding": ResourceIamBinding(IapWebIamSchema, IapWebIamUpdaterProducer, IapWebIdParseFunc),
@@ -1609,6 +1618,7 @@ func providerConfigure(ctx context.Context, d *schema.ResourceData, p *schema.Pr
16091618
config.GameServicesBasePath = d.Get("game_services_custom_endpoint").(string)
16101619
config.GKEHubBasePath = d.Get("gke_hub_custom_endpoint").(string)
16111620
config.HealthcareBasePath = d.Get("healthcare_custom_endpoint").(string)
1621+
config.IAM2BasePath = d.Get("iam2_custom_endpoint").(string)
16121622
config.IAMBetaBasePath = d.Get("iam_beta_custom_endpoint").(string)
16131623
config.IapBasePath = d.Get("iap_custom_endpoint").(string)
16141624
config.IdentityPlatformBasePath = d.Get("identity_platform_custom_endpoint").(string)

0 commit comments

Comments
 (0)