mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-10-05 02:01:05 +00:00
094b1bc673
<!-- This change is generated by MagicModules. --> /cc @rileykarson
98 lines
2.6 KiB
Go
98 lines
2.6 KiB
Go
// ----------------------------------------------------------------------------
|
|
//
|
|
// *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
|
|
//
|
|
// ----------------------------------------------------------------------------
|
|
//
|
|
// This file is automatically generated by Magic Modules and manual
|
|
// changes will be clobbered when the file is regenerated.
|
|
//
|
|
// Please read more about how to change this file in
|
|
// .github/CONTRIBUTING.md.
|
|
//
|
|
// ----------------------------------------------------------------------------
|
|
|
|
package google
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/hashicorp/terraform/helper/acctest"
|
|
"github.com/hashicorp/terraform/helper/resource"
|
|
"github.com/hashicorp/terraform/terraform"
|
|
)
|
|
|
|
func TestAccAppEngineFirewallRule_appEngineFirewallRuleBasicExample(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
context := map[string]interface{}{
|
|
"org_id": getTestOrgFromEnv(t),
|
|
"random_suffix": acctest.RandString(10),
|
|
}
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
Providers: testAccProviders,
|
|
CheckDestroy: testAccCheckAppEngineFirewallRuleDestroy,
|
|
Steps: []resource.TestStep{
|
|
{
|
|
Config: testAccAppEngineFirewallRule_appEngineFirewallRuleBasicExample(context),
|
|
},
|
|
{
|
|
ResourceName: "google_app_engine_firewall_rule.rule",
|
|
ImportState: true,
|
|
ImportStateVerify: true,
|
|
},
|
|
},
|
|
})
|
|
}
|
|
|
|
func testAccAppEngineFirewallRule_appEngineFirewallRuleBasicExample(context map[string]interface{}) string {
|
|
return Nprintf(`
|
|
resource "google_project" "my_project" {
|
|
name = "tf-test-project"
|
|
project_id = "test-project-%{random_suffix}"
|
|
org_id = "%{org_id}"
|
|
}
|
|
|
|
resource "google_app_engine_application" "app" {
|
|
project = "${google_project.my_project.project_id}"
|
|
location_id = "us-central"
|
|
}
|
|
|
|
resource "google_app_engine_firewall_rule" "rule" {
|
|
project = "${google_app_engine_application.app.project}"
|
|
priority = 1000
|
|
action = "ALLOW"
|
|
source_range = "*"
|
|
}
|
|
`, context)
|
|
}
|
|
|
|
func testAccCheckAppEngineFirewallRuleDestroy(s *terraform.State) error {
|
|
for name, rs := range s.RootModule().Resources {
|
|
if rs.Type != "google_app_engine_firewall_rule" {
|
|
continue
|
|
}
|
|
if strings.HasPrefix(name, "data.") {
|
|
continue
|
|
}
|
|
|
|
config := testAccProvider.Meta().(*Config)
|
|
|
|
url, err := replaceVarsForTest(rs, "https://appengine.googleapis.com/v1/apps/{{project}}/firewall/ingressRules/{{priority}}")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
_, err = sendRequest(config, "GET", url, nil)
|
|
if err == nil {
|
|
return fmt.Errorf("AppEngineFirewallRule still exists at %s", url)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|