Skip to content

Commit 6d61452

Browse files
modular-magicianSarahFrench
authored andcommitted
Fix test for Ingress Policy (#7762) (#5513)
Signed-off-by: Modular Magician <[email protected]>
1 parent a05b7d0 commit 6d61452

File tree

4 files changed

+11
-19
lines changed

4 files changed

+11
-19
lines changed

.changelog/7762.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
accesscontextmanager: fixed test for `google_access_context_manager_ingress_policy`
3+
```

google-beta/resource_access_context_manager_ingress_policy.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func resourceAccessContextManagerIngressPolicyCreate(d *schema.ResourceData, met
100100
}
101101

102102
// Store the ID now
103-
id, err := ReplaceVars(d, config, "{{ingress_policy_name}}{{resource}}")
103+
id, err := ReplaceVars(d, config, "{{ingress_policy_name}}/{{resource}}")
104104
if err != nil {
105105
return fmt.Errorf("Error constructing id: %s", err)
106106
}
@@ -134,7 +134,7 @@ func resourceAccessContextManagerIngressPolicyCreate(d *schema.ResourceData, met
134134
}
135135

136136
// This may have caused the ID to update - update it if so.
137-
id, err = ReplaceVars(d, config, "{{ingress_policy_name}}{{resource}}")
137+
id, err = ReplaceVars(d, config, "{{ingress_policy_name}}/{{resource}}")
138138
if err != nil {
139139
return fmt.Errorf("Error constructing id: %s", err)
140140
}

google-beta/resource_access_context_manager_ingress_policy_test.go

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,22 @@ func testAccAccessContextManagerIngressPolicy_basicTest(t *testing.T) {
1515
// Multiple fine-grained resources
1616
SkipIfVcr(t)
1717
org := GetTestOrgFromEnv(t)
18-
projects := BootstrapServicePerimeterProjects(t, 2)
18+
projects := BootstrapServicePerimeterProjects(t, 1)
1919
policyTitle := RandString(t, 10)
20-
perimeterTitle := RandString(t, 10)
20+
perimeterTitle := "perimeter"
2121

2222
VcrTest(t, resource.TestCase{
2323
PreCheck: func() { AccTestPreCheck(t) },
2424
ProtoV5ProviderFactories: ProtoV5ProviderFactories(t),
2525
Steps: []resource.TestStep{
2626
{
27-
Config: testAccAccessContextManagerIngressPolicy_basic(org, policyTitle, perimeterTitle, projects[0].ProjectNumber, projects[1].ProjectNumber),
27+
Config: testAccAccessContextManagerIngressPolicy_basic(org, policyTitle, perimeterTitle, projects[0].ProjectNumber),
2828
},
2929
{
3030
ResourceName: "google_access_context_manager_ingress_policy.test-access1",
3131
ImportState: true,
3232
ImportStateVerify: true,
3333
},
34-
{
35-
ResourceName: "google_access_context_manager_ingress_policy.test-access2",
36-
ImportState: true,
37-
ImportStateVerify: true,
38-
},
3934
{
4035
Config: testAccAccessContextManagerIngressPolicy_destroy(org, policyTitle, perimeterTitle),
4136
Check: testAccCheckAccessContextManagerIngressPolicyDestroyProducer(t),
@@ -86,7 +81,7 @@ func testAccCheckAccessContextManagerIngressPolicyDestroyProducer(t *testing.T)
8681
}
8782
}
8883

89-
func testAccAccessContextManagerIngressPolicy_basic(org, policyTitle, perimeterTitleName string, projectNumber1, projectNumber2 int64) string {
84+
func testAccAccessContextManagerIngressPolicy_basic(org, policyTitle, perimeterTitleName string, projectNumber1 int64) string {
9085
return fmt.Sprintf(`
9186
%s
9287
@@ -95,12 +90,7 @@ resource "google_access_context_manager_ingress_policy" "test-access1" {
9590
resource = "projects/%d"
9691
}
9792
98-
resource "google_access_context_manager_ingress_policy" "test-access2" {
99-
ingress_policy_name = google_access_context_manager_service_perimeter.test-access.name
100-
resource = "projects/%d"
101-
}
102-
103-
`, testAccAccessContextManagerIngressPolicy_destroy(org, policyTitle, perimeterTitleName), projectNumber1, projectNumber2)
93+
`, testAccAccessContextManagerIngressPolicy_destroy(org, policyTitle, perimeterTitleName), projectNumber1)
10494
}
10595

10696
func testAccAccessContextManagerIngressPolicy_destroy(org, policyTitle, perimeterTitleName string) string {

website/docs/r/access_context_manager_ingress_policy.html.markdown

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ The following arguments are supported:
5555

5656
In addition to the arguments listed above, the following computed attributes are exported:
5757

58-
* `id` - an identifier for the resource with format `{{ingress_policy_name}}{{resource}}`
58+
* `id` - an identifier for the resource with format `{{ingress_policy_name}}/{{resource}}`
5959

6060

6161
## Timeouts
@@ -73,5 +73,4 @@ IngressPolicy can be imported using any of these accepted formats:
7373

7474
```
7575
$ terraform import google_access_context_manager_ingress_policy.default {{ingress_policy_name}}/{{resource}}
76-
$ terraform import google_access_context_manager_ingress_policy.default {{ingress_policy_name}}{{resource}}
7776
```

0 commit comments

Comments
 (0)