-
Notifications
You must be signed in to change notification settings - Fork 264
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add web security scanner ScanConfig resource to terraform
Signed-off-by: Modular Magician <[email protected]>
- Loading branch information
1 parent
e261332
commit 584f320
Showing
7 changed files
with
1,145 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// ---------------------------------------------------------------------------- | ||
// | ||
// *** 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 "github.com/hashicorp/terraform/helper/schema" | ||
|
||
var GeneratedSecurityScannerResourcesMap = map[string]*schema.Resource{ | ||
"google_security_scanner_scan_config": resourceSecurityScannerScanConfig(), | ||
} |
71 changes: 71 additions & 0 deletions
71
google-beta/resource_google_security_scanner_scan_config_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package google | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform/helper/acctest" | ||
"github.com/hashicorp/terraform/helper/resource" | ||
) | ||
|
||
func TestAccSecurityScannerScanConfig_scanConfigUpdate(t *testing.T) { | ||
t.Parallel() | ||
|
||
firstAddressSuffix := acctest.RandString(10) | ||
secondAddressSuffix := acctest.RandString(10) | ||
context := map[string]interface{}{ | ||
"random_suffix": firstAddressSuffix, | ||
"random_suffix2": secondAddressSuffix, | ||
"static_address_name": "scanner_static_ip", | ||
"user_agent": "CHROME_LINUX", | ||
"export": "ENABLED", | ||
"max_qps": 10, | ||
} | ||
updateContext := map[string]interface{}{ | ||
"random_suffix": firstAddressSuffix, | ||
"random_suffix2": secondAddressSuffix, | ||
"static_address_name": "scanner_static_ip_update", | ||
"user_agent": "CHROME_ANDROID", | ||
"export": "DISABLED", | ||
"max_qps": 20, | ||
} | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckSecurityScannerScanConfigDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccSecurityScannerScanConfig(context), | ||
}, | ||
{ | ||
ResourceName: "google_security_scanner_scan_config.terraform-scan-config", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
}, | ||
{ | ||
Config: testAccSecurityScannerScanConfig(updateContext), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccSecurityScannerScanConfig(context map[string]interface{}) string { | ||
return Nprintf(` | ||
resource "google_compute_address" "scanner_static_ip" { | ||
name = "scan-static-ip-%{random_suffix}" | ||
} | ||
resource "google_compute_address" "scanner_static_ip_update" { | ||
name = "scan-static-ip-%{random_suffix2}" | ||
} | ||
resource "google_security_scanner_scan_config" "terraform-scan-config" { | ||
display_name = "terraform-scan-config-%{random_suffix}" | ||
max_qps = %{max_qps} | ||
starting_urls = ["http://${google_compute_address.%{static_address_name}.address}"] | ||
target_platforms = ["COMPUTE"] | ||
user_agent = "%{user_agent}" | ||
export_to_security_command_center = "%{export}" | ||
} | ||
`, context) | ||
} |
Oops, something went wrong.