Skip to content

Commit

Permalink
docs: reusable modules usage examples (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
hknutsen authored Oct 19, 2023
1 parent 6c06916 commit 0f01baf
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/reusable-modules/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Reusable modules
72 changes: 72 additions & 0 deletions docs/reusable-modules/usage-examples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Usage examples

## Prerequisites

- Must be assigned role `Contributor` at the subscription scope.

- Create a file `main.tf` with the following contents:

```terraform
provider "azurerm" {
features {}
}
resource "random_id" "example" {
byte_length = 8
}
resource "azurerm_resource_group" "example" {
name = "rg-${random_id.example.hex}"
location = "northeurope"
}
```
It will:
- Configure the Azure provider.
- Create a random identifier to generate random resource names.
- Create an Azure resource group to contain resources.
## Setup Azure Log Analytics
```terraform
module "log_analytics" {
source = "github.com/equinor/terraform-azurerm-log-analytics?ref=v2.1.1"
workspace_name = "log-${random_id.example.hex}"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
}
```

## Setup Azure Key Vault

```terraform
module "key_vault" {
source = "github.com/equinor/terraform-azurerm-key-vault?ref=v11.2.0"
vault_name = "kv-${random_id.example.hex}"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
log_analytics_workspace_id = module.log_analytics.workspace_id
# List of IP addresses or IP ranges in CIDR format
network_acls_ip_rules = []
}
```

## Setup Azure Storage

```terraform
module "storage" {
source = "github.com/equinor/terraform-azurerm-storage?ref=v12.1.1"
account_name = "st${random_id.example.hex}"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
log_analytics_workspace_id = module.log_analytics.workspace_id
# List of IP addresses or IP ranges in CIDR format
network_rules_ip_rules = []
}
```
3 changes: 3 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@ nav:
- get-started/update-resources.md
- get-started/destroy-resources.md
- get-started/summary.md
- Reusable modules:
- reusable-modules/index.md
- reusable-modules/usage-examples.md

0 comments on commit 0f01baf

Please sign in to comment.