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

azurerm_automation_runbook - allow invalid publish_content_links #7824

Merged
merged 1 commit into from
Jul 24, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,11 @@ func resourceArmAutomationRunbookRead(d *schema.ResourceData, meta interface{})

response, err := client.GetContent(ctx, resGroup, accName, name)
if err != nil {
return fmt.Errorf("Error retrieving content for Automation Runbook %q (Account %q / Resource Group %q): %+v", name, accName, resGroup, err)
if utils.ResponseWasNotFound(response.Response) {
d.Set("content", "")
} else {
return fmt.Errorf("retrieving content for Automation Runbook %q (Account %q / Resource Group %q): %+v", name, accName, resGroup, err)
}
}

if v := response.Value; v != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,25 @@ func TestAccAzureRMAutomationRunbook_PSWithContent(t *testing.T) {
})
}

func TestAccAzureRMAutomationRunbook_PSWorkflowWithoutUri(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_automation_runbook", "test")

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acceptance.PreCheck(t) },
Providers: acceptance.SupportedProviders,
CheckDestroy: testCheckAzureRMAutomationRunbookDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMAutomationRunbook_PSWorkflowWithoutUri(data),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMAutomationRunbookExists(data.ResourceName),
),
},
data.ImportStep("publish_content_link"),
},
})
}

func testCheckAzureRMAutomationRunbookDestroy(s *terraform.State) error {
conn := acceptance.AzureProvider.Meta().(*clients.Client).Automation.RunbookClient
ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext
Expand Down Expand Up @@ -300,3 +319,39 @@ CONTENT
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger)
}

func testAccAzureRMAutomationRunbook_PSWorkflowWithoutUri(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}

resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "%s"
}

resource "azurerm_automation_account" "test" {
name = "acctest-%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
sku_name = "Basic"
}

resource "azurerm_automation_runbook" "test" {
name = "Get-AzureVMTutorial"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
automation_account_name = azurerm_automation_account.test.name

log_verbose = "true"
log_progress = "true"
description = "This is a test runbook for terraform acceptance test"
runbook_type = "PowerShell"

publish_content_link {
uri = ""
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger)
}