Skip to content

Commit

Permalink
feat: First release
Browse files Browse the repository at this point in the history
  • Loading branch information
dploeger committed May 4, 2021
1 parent 45d9141 commit c0a4668
Show file tree
Hide file tree
Showing 4 changed files with 145 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .terraform-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
formatter: markdown document
output:
file: "README.md"
settings:
anchor: false
90 changes: 90 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Terraform state management (for Azure)

## Introduction

This module manages storage for Terraform states and is usually used in the Terraform "state" module as a base
for other modules' backend configuration.

## Usage

Instantiate the module by calling it from Terraform like this:

```hcl
module "state" {
source = "dodevops/state/azure"
version = "<version>"
}
```

<!-- BEGIN_TF_DOCS -->
## Requirements

No requirements.

## Providers

The following providers are used by this module:

- azurerm

## Modules

No modules.

## Resources

The following resources are used by this module:

- [azurerm_storage_account.storage-account](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_account) (resource)
- [azurerm_storage_blob.storage-blob](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_blob) (resource)
- [azurerm_storage_container.storage-container](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_container) (resource)

## Required Inputs

The following input variables are required:

### location

Description: The azure location used for azure

Type: `string`

### project

Description: Three letter project key

Type: `string`

### resource\_group

Description: Name of the resource group to use

Type: `string`

### size

Description: Size of state blob in bytes

Type: `string`

### stage

Description: Name of the stage for this state

Type: `string`

## Optional Inputs

No optional inputs.

## Outputs

No outputs.
<!-- END_TF_DOCS -->

## Development

Use [terraform-docs](https://terraform-docs.io/) to generate the API documentation by running

terraform fmt .
terraform-docs .
26 changes: 26 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Azure Storage blob for state storage

resource "azurerm_storage_account" "storage-account" {
name = "${lower(var.project)}${lower(var.stage)}stateacc"
resource_group_name = var.resource_group
location = var.location
account_tier = "Standard"
account_replication_type = "ZRS"
enable_https_traffic_only = false
}

resource "azurerm_storage_container" "storage-container" {
name = "${lower(var.project)}${lower(var.stage)}statecont"
storage_account_name = azurerm_storage_account.storage-account.name
container_access_type = "private"
}

resource "azurerm_storage_blob" "storage-blob" {
name = "${lower(var.project)}${lower(var.stage)}stateblob"

storage_account_name = azurerm_storage_account.storage-account.name
storage_container_name = azurerm_storage_container.storage-container.name

type = "Block"
size = var.size
}
24 changes: 24 additions & 0 deletions vars.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
variable "project" {
type = string
description = "Three letter project key"
}

variable "stage" {
type = string
description = "Name of the stage for this state"
}

variable "location" {
type = string
description = "The azure location used for azure"
}

variable "resource_group" {
type = string
description = "Name of the resource group to use"
}

variable "size" {
type = string
description = "Size of state blob in bytes"
}

0 comments on commit c0a4668

Please sign in to comment.