Skip to content

Commit

Permalink
creating solution example
Browse files Browse the repository at this point in the history
  • Loading branch information
cshea-msft committed Feb 25, 2024
1 parent 1833732 commit 96cb2dc
Show file tree
Hide file tree
Showing 8 changed files with 232 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,10 @@ Description: The Resource ID of the Log Analytics Workspace.

Description: The Name of the Log Analytics Workspace.

### <a name="output_workspace_id"></a> [workspace\_id](#output\_workspace\_id)

Description: The Resource ID of the Log Analytics Workspace.

## Modules

No modules.
Expand Down
136 changes: 136 additions & 0 deletions examples/solution/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
<!-- BEGIN_TF_DOCS -->
# Solutions example

This example deploys Log Analytics Solution

```hcl
terraform {
required_version = ">= 1.3.0"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = ">= 3.7.0, < 4.0.0"
}
random = {
source = "hashicorp/random"
version = ">= 3.5.0, < 4.0.0"
}
}
}
provider "azurerm" {
features {}
}
# This ensures we have unique CAF compliant names for our resources.
module "naming" {
source = "Azure/naming/azurerm"
version = "0.3.0"
}
# This picks a random region from the list of regions.
resource "random_integer" "region_index" {
min = 0
max = length(local.azure_regions) - 1
}
# This is required for resource modules
resource "azurerm_resource_group" "rg" {
name = module.naming.resource_group.name_unique
location = local.azure_regions[random_integer.region_index.result]
}
# This is the module call
module "log_analytics_workspace" {
source = "../../"
# source = "Azure/avm-res-operationalinsights-workspace/azurerm"
enable_telemetry = var.enable_telemetry
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name
name = "log-analytics-workspace"
}
resource "azurerm_log_analytics_solution" "solution" {
solution_name = "ContainerInsights"
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name
workspace_resource_id = module.log_analytics_workspace.workspace_id.id
workspace_name = module.log_analytics_workspace.name
plan {
publisher = "Microsoft"
product = "OMSGallery/ContainerInsights"
}
}
```

<!-- markdownlint-disable MD033 -->
## Requirements

The following requirements are needed by this module:

- <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) (>= 1.3.0)

- <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) (>= 3.7.0, < 4.0.0)

- <a name="requirement_random"></a> [random](#requirement\_random) (>= 3.5.0, < 4.0.0)

## Providers

The following providers are used by this module:

- <a name="provider_azurerm"></a> [azurerm](#provider\_azurerm) (>= 3.7.0, < 4.0.0)

- <a name="provider_random"></a> [random](#provider\_random) (>= 3.5.0, < 4.0.0)

## Resources

The following resources are used by this module:

- [azurerm_log_analytics_solution.solution](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/log_analytics_solution) (resource)
- [azurerm_resource_group.rg](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group) (resource)
- [random_integer.region_index](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/integer) (resource)

<!-- markdownlint-disable MD013 -->
## Required Inputs

No required inputs.

## Optional Inputs

The following input variables are optional (have default values):

### <a name="input_enable_telemetry"></a> [enable\_telemetry](#input\_enable\_telemetry)

Description: This variable controls whether or not telemetry is enabled for the module.
For more information see https://aka.ms/avm/telemetryinfo.
If it is set to false, then no telemetry will be collected.

Type: `bool`

Default: `true`

## Outputs

No outputs.

## Modules

The following Modules are called:

### <a name="module_log_analytics_workspace"></a> [log\_analytics\_workspace](#module\_log\_analytics\_workspace)

Source: ../../

Version:

### <a name="module_naming"></a> [naming](#module\_naming)

Source: Azure/naming/azurerm

Version: 0.3.0

<!-- markdownlint-disable-next-line MD041 -->
## Data Collection

The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry as described in the repository. There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsoft’s privacy statement. Our privacy statement is located at <https://go.microsoft.com/fwlink/?LinkID=824704>. You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices.
<!-- END_TF_DOCS -->
4 changes: 4 additions & 0 deletions examples/solution/_footer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<!-- markdownlint-disable-next-line MD041 -->
## Data Collection

The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry as described in the repository. There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsoft’s privacy statement. Our privacy statement is located at <https://go.microsoft.com/fwlink/?LinkID=824704>. You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices.
3 changes: 3 additions & 0 deletions examples/solution/_header.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Solutions example

This example deploys Log Analytics Solution
15 changes: 15 additions & 0 deletions examples/solution/locals.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
locals {
azure_regions = [
"westeurope",
"northeurope",
"eastus",
"eastus2",
"westus",
"westus2",
"southcentralus",
"northcentralus",
"centralus",
"eastasia",
"southeastasia",
]
}
57 changes: 57 additions & 0 deletions examples/solution/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
terraform {
required_version = ">= 1.3.0"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = ">= 3.7.0, < 4.0.0"
}
random = {
source = "hashicorp/random"
version = ">= 3.5.0, < 4.0.0"
}
}
}

provider "azurerm" {
features {}
}

# This ensures we have unique CAF compliant names for our resources.
module "naming" {
source = "Azure/naming/azurerm"
version = "0.3.0"
}

# This picks a random region from the list of regions.
resource "random_integer" "region_index" {
min = 0
max = length(local.azure_regions) - 1
}

# This is required for resource modules
resource "azurerm_resource_group" "rg" {
name = module.naming.resource_group.name_unique
location = local.azure_regions[random_integer.region_index.result]
}

# This is the module call
module "log_analytics_workspace" {
source = "../../"
# source = "Azure/avm-res-operationalinsights-workspace/azurerm"
enable_telemetry = var.enable_telemetry
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name
name = "log-analytics-workspace"
}

resource "azurerm_log_analytics_solution" "solution" {
solution_name = "ContainerInsights"
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name
workspace_resource_id = module.log_analytics_workspace.workspace_id.id
workspace_name = module.log_analytics_workspace.name
plan {
publisher = "Microsoft"
product = "OMSGallery/ContainerInsights"
}
}
9 changes: 9 additions & 0 deletions examples/solution/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
variable "enable_telemetry" {
type = bool
default = true
description = <<DESCRIPTION
This variable controls whether or not telemetry is enabled for the module.
For more information see https://aka.ms/avm/telemetryinfo.
If it is set to false, then no telemetry will be collected.
DESCRIPTION
}
4 changes: 4 additions & 0 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ output "name" {
value = azurerm_log_analytics_workspace.this.name
}

output "workspace_id" {
description = "The Resource ID of the Log Analytics Workspace."
value = azurerm_log_analytics_workspace.this
}

0 comments on commit 96cb2dc

Please sign in to comment.