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

docs: update readme #225

Merged
merged 4 commits into from
Jan 30, 2025
Merged
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
95 changes: 82 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Azure Web App Terraform module
# Terraform module for Azure Web App

[![SCM Compliance](https://scm-compliance-api.radix.equinor.com/repos/equinor/terraform-azurerm-web-app/badge)](https://scm-compliance-api.radix.equinor.com/repos/equinor/terraform-azurerm-web-app/badge)
[![Equinor Terraform Baseline](https://img.shields.io/badge/Equinor%20Terraform%20Baseline-1.0.0-blueviolet)](https://github.com/equinor/terraform-baseline)
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org)
[![GitHub License](https://img.shields.io/github/license/equinor/terraform-azurerm-web-app)](https://github.com/equinor/terraform-azurerm-web-app/blob/main/LICENSE)
[![GitHub Release](https://img.shields.io/github/v/release/equinor/terraform-azurerm-web-app)](https://github.com/equinor/terraform-azurerm-web-app/releases/latest)
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-%23FE5196?logo=conventionalcommits&logoColor=white)](https://conventionalcommits.org)
[![SCM Compliance](https://scm-compliance-api.radix.equinor.com/repos/equinor/terraform-azurerm-web-app/badge)](https://developer.equinor.com/governance/scm-policy/)

Terraform module which creates an Azure Web App.
Terraform module which creates Azure Web App resources.

## Features

Expand All @@ -15,6 +16,73 @@ Terraform module which creates an Azure Web App.
- Audit logs sent to given Log Analytics workspace by default.
- Changes to app settings `BUILD`, `BUILD_NUMBER` and `BUILD_ID` ignored, allowing them to be configured outside of Terraform (commonly in a CI/CD pipeline).

## Prerequisites

- Install [Terraform](https://developer.hashicorp.com/terraform/install).
- Install [Azure CLI](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli).

## Usage

1. Login to Azure:

```console
az login
```

1. Create a Terraform configuration file `main.tf` and add the following example configuration:

```terraform
provider "azurerm" {
features {}
}

module "web_app" {
source = "equinor/web-app/azurerm"
version = "~> 15.10"

app_name = "example-app"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
app_service_plan_id = module.app_service.plan_id
log_analytics_workspace_id = module.log_analytics.workspace_id
}

resource "azurerm_resource_group" "example" {
name = "example-resources"
location = "northeurope"
}

module "app_service" {
source = "equinor/app-service/azurerm"
version = "~> 2.1"

plan_name = "example-plan"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
}

module "log_analytics" {
source = "equinor/log-analytics/azurerm"
version = "~> 2.3"

workspace_name = "example-workspace"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
}
```

1. Install required provider plugins and modules:

```console
terraform init
```

1. Apply the Terraform configuration:

```console
terraform apply
```

## Notes

### Application logging
Expand All @@ -27,19 +95,20 @@ az webapp log config -n <APP_NAME> -g <RESOURCE_GROUP_NAME> --application-loggin

## Development

1. Read [this document](https://code.visualstudio.com/docs/devcontainers/containers).
1. Login to Azure:

1. Clone this repository.
```bash
az login
```

1. Configure Terraform variables in a file `.devcontainer/devcontainer.env`:
1. Set environment variables:

```env
TF_VAR_resource_group_name=
TF_VAR_location=
```bash
export ARM_SUBSCRIPTION_ID="<SUBSCRIPTION_ID>"
export TF_VAR_resource_group_name="<RESOURCE_GROUP_NAME>"
export TF_VAR_location="<LOCATION>"
```

1. Open repository in dev container.

## Testing

1. Change to the test directory:
Expand Down