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

fix test case, examples and support more event source #10126

Merged
merged 3 commits into from
Jan 13, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,11 @@ func resourceSecurityCenterAutomation() *schema.Resource {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{
"Alerts",
"Assessments",
"SubAssessments",
string(security.Alerts),
string(security.Assessments),
string(security.SecureScoreControls),
string(security.SecureScores),
string(security.SubAssessments),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we update the documentation to include these new values? this should also likely be case-sensitive (by changing the true below)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry for missing. Have done it!

}, true),
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,12 @@ func TestAccSecurityCenterAutomation_sourceMulti(t *testing.T) {
{
Config: r.sourceMulti(data),
Check: resource.ComposeTestCheckFunc(
check.That(data.ResourceName).Key("source.#").HasValue("3"),
check.That(data.ResourceName).Key("source.#").HasValue("5"),
check.That(data.ResourceName).Key("source.0.rule_set.#").HasValue("1"),
check.That(data.ResourceName).Key("source.1.rule_set.#").HasValue("1"),
check.That(data.ResourceName).Key("source.2.rule_set.#").HasValue("1"),
check.That(data.ResourceName).Key("source.3.rule_set.#").HasValue("0"),
check.That(data.ResourceName).Key("source.4.rule_set.#").HasValue("0"),
),
},
data.ImportStep("action.0.trigger_url", "action.1.trigger_url"), // trigger_url needs to be ignored
Expand Down Expand Up @@ -322,6 +324,26 @@ resource "azurerm_eventhub_namespace" "test" {
capacity = 1
}

resource "azurerm_eventhub" "test" {
name = "acctesteventhub-%d"
namespace_name = azurerm_eventhub_namespace.test.name
resource_group_name = azurerm_resource_group.test.name

partition_count = 2
message_retention = 1
}

resource "azurerm_eventhub_authorization_rule" "test" {
name = "acctest-eventhub-auth-rule-%d"
namespace_name = azurerm_eventhub_namespace.test.name
eventhub_name = azurerm_eventhub.test.name
resource_group_name = azurerm_resource_group.test.name

listen = true
send = false
manage = false
}

data "azurerm_client_config" "current" {
}

Expand All @@ -336,15 +358,15 @@ resource "azurerm_security_center_automation" "test" {

action {
type = "EventHub"
resource_id = azurerm_eventhub_namespace.test.id
connection_string = azurerm_eventhub_namespace.test.default_primary_connection_string
resource_id = azurerm_eventhub.test.id
connection_string = azurerm_eventhub_authorization_rule.test.primary_connection_string
}

source {
event_source = "Alerts"
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.Locations.Primary)
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, data.RandomInteger, data.Locations.Primary)
}

func (r SecurityCenterAutomationResource) requiresImport(data acceptance.TestData) string {
Expand Down Expand Up @@ -736,6 +758,14 @@ resource "azurerm_security_center_automation" "test" {
}
}
}

source {
event_source = "SecureScores"
}

source {
event_source = "SecureScoreControls"
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.Locations.Primary)
}
22 changes: 20 additions & 2 deletions website/docs/r/security_center_automation.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,33 @@ resource "azurerm_eventhub_namespace" "example" {
capacity = 2
}

resource "azurerm_eventhub" "example" {
name = "acceptanceTestEventHub"
namespace_name = azurerm_eventhub_namespace.example.name
resource_group_name = azurerm_resource_group.example.name
partition_count = 2
message_retention = 2
}

resource "azurerm_eventhub_authorization_rule" "example" {
name = "example-rule"
namespace_name = azurerm_eventhub_namespace.example.name
eventhub_name = azurerm_eventhub.example.name
resource_group_name = azurerm_resource_group.example.name
listen = true
send = false
manage = false
}

resource "azurerm_security_center_automation" "example" {
name = "example-automation"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name

action {
type = "EventHub"
resource_id = azurerm_eventhub_namespace.example.id
connection_string = azurerm_eventhub_namespace.example.default_primary_connection_string
resource_id = azurerm_eventhub.example.id
connection_string = azurerm_eventhub_authorization_rule.example.primary_connection_string
}

source {
Expand Down