@@ -77,7 +77,7 @@ func TestAccOrgPolicyPolicy_OrganizationPolicy(t *testing.T) {
7777 t .Parallel ()
7878
7979 context := map [string ]interface {}{
80- "org_id" : envvar .GetTestOrgFromEnv (t ),
80+ "org_id" : envvar .GetTestOrgTargetFromEnv (t ),
8181 "random_suffix" : acctest .RandString (t , 10 ),
8282 }
8383
@@ -104,6 +104,15 @@ func TestAccOrgPolicyPolicy_OrganizationPolicy(t *testing.T) {
104104 ImportStateVerify : true ,
105105 ImportStateVerifyIgnore : []string {"name" , "spec.0.rules.0.condition.0.expression" },
106106 },
107+ {
108+ Config : testAccOrgPolicyPolicy_DryRunSpecHandWritten (context ),
109+ },
110+ {
111+ ResourceName : "google_org_policy_policy.primary" ,
112+ ImportState : true ,
113+ ImportStateVerify : true ,
114+ ImportStateVerifyIgnore : []string {"name" , "spec.0.rules.0.condition.0.expression" },
115+ },
107116 },
108117 })
109118}
@@ -150,31 +159,6 @@ func TestAccOrgPolicyPolicy_ProjectPolicy(t *testing.T) {
150159 },
151160 })
152161}
153- func TestAccOrgPolicyPolicy_DryRunSpecHandWritten (t * testing.T ) {
154- t .Parallel ()
155-
156- context := map [string ]interface {}{
157- "org_id" : envvar .GetTestOrgFromEnv (t ),
158- "random_suffix" : acctest .RandString (t , 10 ),
159- }
160-
161- acctest .VcrTest (t , resource.TestCase {
162- PreCheck : func () { acctest .AccTestPreCheck (t ) },
163- ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories (t ),
164- CheckDestroy : testAccCheckOrgPolicyPolicyDestroyProducer (t ),
165- Steps : []resource.TestStep {
166- {
167- Config : testAccOrgPolicyPolicy_DryRunSpecHandWritten (context ),
168- },
169- {
170- ResourceName : "google_org_policy_policy.primary" ,
171- ImportState : true ,
172- ImportStateVerify : true ,
173- ImportStateVerifyIgnore : []string {"name" , "spec.0.rules.0.condition.0.expression" },
174- },
175- },
176- })
177- }
178162
179163func testAccOrgPolicyPolicy_EnforcePolicy (context map [string ]interface {}) string {
180164 return acctest .Nprintf (`
@@ -266,7 +250,7 @@ resource "google_folder" "basic" {
266250func testAccOrgPolicyPolicy_OrganizationPolicy (context map [string ]interface {}) string {
267251 return acctest .Nprintf (`
268252resource "google_org_policy_custom_constraint" "constraint" {
269- name = "custom.tfTest %{random_suffix}"
253+ name = "custom.tfTestdisableGkeAutoUpgrade %{random_suffix}"
270254 parent = "organizations/%{org_id}"
271255 display_name = "Disable GKE auto upgrade"
272256 description = "Only allow GKE NodePool resource to be created or updated if AutoUpgrade is not enabled where this custom constraint is enforced."
@@ -291,7 +275,7 @@ resource "google_org_policy_policy" "primary" {
291275func testAccOrgPolicyPolicy_OrganizationPolicyUpdate0 (context map [string ]interface {}) string {
292276 return acctest .Nprintf (`
293277resource "google_org_policy_custom_constraint" "constraint" {
294- name = "custom.tfTest %{random_suffix}"
278+ name = "custom.tfTestdisableGkeAutoUpgrade %{random_suffix}"
295279 parent = "organizations/%{org_id}"
296280 display_name = "Disable GKE auto upgrade"
297281 description = "Only allow GKE NodePool resource to be created or updated if AutoUpgrade is not enabled where this custom constraint is enforced."
@@ -429,14 +413,14 @@ resource "google_project" "basic" {
429413func testAccOrgPolicyPolicy_DryRunSpecHandWritten (context map [string ]interface {}) string {
430414 return acctest .Nprintf (`
431415resource "google_org_policy_custom_constraint" "constraint" {
432- name = "custom.disableGkeAutoUpgrade %{random_suffix}"
416+ name = "custom.tfTestdisableGkeAutoUpgrade %{random_suffix}"
433417 parent = "organizations/%{org_id}"
434418 display_name = "Disable GKE auto upgrade"
435419 description = "Only allow GKE NodePool resource to be created or updated if AutoUpgrade is not enabled where this custom constraint is enforced."
436420
437421 action_type = "ALLOW"
438422 condition = "resource.management.autoUpgrade == false"
439- method_types = ["CREATE"]
423+ method_types = ["CREATE", "UPDATE" ]
440424 resource_types = ["container.googleapis.com/NodePool"]
441425}
442426
0 commit comments