Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add web security scanner ScanConfig resource to terraform #641

Merged
merged 1 commit into from
May 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions google-beta/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ func ResourceMapWithErrors() (map[string]*schema.Resource, error) {
// start beta-only products
GeneratedBinaryAuthorizationResourcesMap,
GeneratedContainerAnalysisResourcesMap,
GeneratedSecurityScannerResourcesMap,
// end beta-only products
GeneratedAccessContextManagerResourcesMap,
GeneratedAppEngineResourcesMap,
Expand Down
21 changes: 21 additions & 0 deletions google-beta/provider_security_scanner_gen.go
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 google-beta/resource_google_security_scanner_scan_config_test.go
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)
}
Loading