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 resource azurerm_log_analytics_workspace_linked_service #2139

Merged

Conversation

draggeta
Copy link
Contributor

@draggeta draggeta commented Oct 23, 2018

This resource adds the ability to link OMS Workspaces and Azure Automation Accounts (and possibly others in future) together.

Closes #2080

To do:

  • Write resource
  • Write acceptance tests
  • Write documentation

Example

resource "azurerm_resource_group" "test" {
  name     = "resourceGroup1"
  location = "West Europe"
}

resource "azurerm_automation_account" "test" {
  name                = "automationAccount1"
  location            = "${azurerm_resource_group.test.location}"
  resource_group_name = "${azurerm_resource_group.test.name}"

  sku {
    name = "Basic"
  }

  tags {
    environment = "development"
  }
}

resource "azurerm_log_analytics_workspace" "test" {
  name                = "acctest-01"
  location            = "${azurerm_resource_group.test.location}"
  resource_group_name = "${azurerm_resource_group.test.name}"
  sku                 = "PerGB2018"
  retention_in_days   = 30
}

resource "azurerm_log_analytics_workspace_linked_service" "test" {
  resource_group_name = "${azurerm_resource_group.test.name}"
  workspace_name      = "${azurerm_log_analytics_workspace.test.name}"
  linked_service_name = "automation"

  linked_service_properties {
    resource_id = "${azurerm_automation_account.test.id}"
  }
}

Exports

The following items are also exported

  • id: The ID of the resource. This is generated by Azure itself.
  • name: The name of the resource. This is generated by Azure itself.

Acceptance tests

PS > go test -timeout 180m -v -ldflags="-X=github.com/terraform-providers/terraform-provider-azurerm/version.ProviderVersion=acc" `
>> github.com\terraform-providers\terraform-provider-azurerm\azurerm `
>> -run "^TestAccAzureRMLogAnalyticsWorkspaceLinkedService"
=== RUN   TestAccAzureRMLogAnalyticsWorkspaceLinkedService_requiredOnly
--- PASS: TestAccAzureRMLogAnalyticsWorkspaceLinkedService_requiredOnly (85.34s)
=== RUN   TestAccAzureRMLogAnalyticsWorkspaceLinkedService_optionalArguments
--- PASS: TestAccAzureRMLogAnalyticsWorkspaceLinkedService_optionalArguments (83.33s)
=== RUN   TestAccAzureRMLogAnalyticsWorkspaceLinkedService_importRequiredOnly
--- PASS: TestAccAzureRMLogAnalyticsWorkspaceLinkedService_importRequiredOnly (85.92s)
=== RUN   TestAccAzureRMLogAnalyticsWorkspaceLinkedService_importOptionalArguments
--- PASS: TestAccAzureRMLogAnalyticsWorkspaceLinkedService_importOptionalArguments (88.06s)
PASS
ok      github.com/terraform-providers/terraform-provider-azurerm/azurerm       344.430s

@ghost ghost added the size/XL label Oct 23, 2018
@draggeta draggeta changed the title WIP: Add resource azurerm_log_analytics_linked_service Add resource azurerm_log_analytics_linked_service Oct 23, 2018
@draggeta
Copy link
Contributor Author

I am now wondering if it should be renamed to azurerm_log_analytics_workspace_linked_service.

I can't seem to find a clear preference in the resources mentioned in the docs. Some child resources use only their names (e.g.: subnets) and others use the parent resource in the name as well (network interfaces, storage).

Let me know if this should be done. I have this change ready in another branch that I can merge into this.

Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

Hi @draggeta,

Thank you for the new resource, it mostly LGTM aside from some minor comments I have left inline. The only major issue for me is removing the separate import tests and appending them to the regular ones.

Look forward to getting this merged once those comments are addressed 🙂 thanks!

azurerm/import_arm_log_analytics_linked_service_test.go Outdated Show resolved Hide resolved
@@ -206,6 +206,7 @@ func Provider() terraform.ResourceProvider {
"azurerm_lb_probe": resourceArmLoadBalancerProbe(),
"azurerm_lb_rule": resourceArmLoadBalancerRule(),
"azurerm_local_network_gateway": resourceArmLocalNetworkGateway(),
"azurerm_log_analytics_linked_service": resourceArmLogAnalyticsLinkedService(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree the name should probably be azurerm_log_analytics_workspace_linked_service, thoughts @tombuildsstuff?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've renamed the resource. Will also change the description up above.

azurerm/resource_arm_log_analytics_linked_service.go Outdated Show resolved Hide resolved
azurerm/resource_arm_log_analytics_linked_service.go Outdated Show resolved Hide resolved
azurerm/resource_arm_log_analytics_linked_service.go Outdated Show resolved Hide resolved
azurerm/resource_arm_log_analytics_linked_service.go Outdated Show resolved Hide resolved
azurerm/resource_arm_log_analytics_linked_service.go Outdated Show resolved Hide resolved
azurerm/resource_arm_log_analytics_linked_service_test.go Outdated Show resolved Hide resolved
@draggeta draggeta changed the title Add resource azurerm_log_analytics_linked_service Add resource azurerm_log_analytics_workspace_linked_service Oct 27, 2018
Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

@draggeta,

Thanks for the quick updates! LGTM now 👍

@katbyte katbyte merged commit b149da2 into hashicorp:master Oct 27, 2018
@katbyte katbyte modified the milestones: 1.19.0, 1.18.0 Oct 27, 2018
@katbyte
Copy link
Collaborator

katbyte commented Oct 27, 2018

tests pass:
screen shot 2018-10-27 at 10 07 58

katbyte added a commit that referenced this pull request Oct 27, 2018
@draggeta draggeta deleted the add-resource-arm-log-analytics-linked-services branch October 27, 2018 20:07
@tombuildsstuff
Copy link
Contributor

hi @draggeta

Just to let you know that this has been released as a part of v1.18 of the AzureRM Provider (the full changelog is available here). You can upgrade to this by specifying the version in the provider block (as shown below) and then running terraform init -upgrade

provider "azurerm" {
  version = "=1.18.0"
}

Thanks!

@ghost
Copy link

ghost commented Mar 6, 2019

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants