Skip to content

Commit f4439cc

Browse files
authored
Merge pull request #1 from data-platform-hq/add-module
feat: add module
2 parents 34253f2 + ed9e1fb commit f4439cc

File tree

6 files changed

+181
-3
lines changed

6 files changed

+181
-3
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright 2022 EPAM Systems, Inc.
189+
Copyright 2023 EPAM Systems, Inc.
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

README.md

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,61 @@
11
# Azure <> Terraform module
2-
Terraform module for creation Azure <>
2+
Terraform module for creation Azure Static Web Apps
33

44
## Usage
55

66
<!-- BEGIN_TF_DOCS -->
7+
## Requirements
78

9+
| Name | Version |
10+
|------|---------|
11+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0.0 |
12+
| <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) | >= 3.23.0 |
13+
14+
## Providers
15+
16+
| Name | Version |
17+
|------|---------|
18+
| <a name="provider_azurerm"></a> [azurerm](#provider\_azurerm) | >= 3.23.0 |
19+
20+
## Modules
21+
22+
No modules.
23+
24+
## Resources
25+
26+
| Name | Type |
27+
|------|------|
28+
| [azurerm_static_site.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/static_site) | resource |
29+
| [azurerm_static_site_custom_domain.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/static_site_custom_domain) | resource |
30+
31+
## Inputs
32+
33+
| Name | Description | Type | Default | Required |
34+
|------|-------------|------|---------|:--------:|
35+
| <a name="input_domain_name"></a> [domain\_name](#input\_domain\_name) | Domain name | `string` | `null` | no |
36+
| <a name="input_env"></a> [env](#input\_env) | Environment | `string` | n/a | yes |
37+
| <a name="input_identity_ids"></a> [identity\_ids](#input\_identity\_ids) | List of user assigned identity IDs | `list(string)` | `null` | no |
38+
| <a name="input_location"></a> [location](#input\_location) | Location | `string` | n/a | yes |
39+
| <a name="input_name"></a> [name](#input\_name) | Static site name | `string` | n/a | yes |
40+
| <a name="input_project"></a> [project](#input\_project) | Project name | `string` | n/a | yes |
41+
| <a name="input_resource_group"></a> [resource\_group](#input\_resource\_group) | Resource group name | `string` | n/a | yes |
42+
| <a name="input_sku_size"></a> [sku\_size](#input\_sku\_size) | SKU size | `string` | `"Free"` | no |
43+
| <a name="input_sku_tier"></a> [sku\_tier](#input\_sku\_tier) | SKU tier | `string` | `"Free"` | no |
44+
| <a name="input_tags"></a> [tags](#input\_tags) | Tags | `map(string)` | n/a | yes |
45+
| <a name="input_validation_type"></a> [validation\_type](#input\_validation\_type) | Validation type | `string` | `"dns-txt-token"` | no |
46+
47+
## Outputs
48+
49+
| Name | Description |
50+
|------|-------------|
51+
| <a name="output_api_key"></a> [api\_key](#output\_api\_key) | The API Key of the Static Site. |
52+
| <a name="output_custom_domain_id"></a> [custom\_domain\_id](#output\_custom\_domain\_id) | The ID of the Custom Domain. |
53+
| <a name="output_default_host_name"></a> [default\_host\_name](#output\_default\_host\_name) | The Default Host Name of the Static Site. |
54+
| <a name="output_id"></a> [id](#output\_id) | The ID of the Static Site. |
55+
| <a name="output_identity"></a> [identity](#output\_identity) | The Managed Identity of the Static Site. |
56+
| <a name="output_validation_token"></a> [validation\_token](#output\_validation\_token) | The Validation Token of the Custom Domain. |
857
<!-- END_TF_DOCS -->
958

1059
## License
1160

12-
Apache 2 Licensed. For more information please see [LICENSE](https://github.com/data-platform-hq/terraform-azurerm<>/tree/master/LICENSE)
61+
Apache 2 Licensed. For more information please see [LICENSE](https://github.com/data-platform-hq/terraform-azurerm-static-site/blob/main/LICENSE)

main.tf

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
resource "azurerm_static_site" "this" {
2+
name = "swa-${var.project}-${var.env}-${var.location}-${var.name}"
3+
location = var.location
4+
resource_group_name = var.resource_group
5+
sku_tier = var.sku_tier
6+
sku_size = var.sku_size
7+
tags = var.tags
8+
identity {
9+
type = var.identity_ids == null ? "SystemAssigned" : "SystemAssigned, UserAssigned"
10+
identity_ids = var.identity_ids
11+
}
12+
}
13+
14+
resource "azurerm_static_site_custom_domain" "this" {
15+
count = var.domain_name == null ? 0 : 1
16+
static_site_id = azurerm_static_site.this.id
17+
domain_name = var.domain_name
18+
validation_type = var.validation_type
19+
}

outputs.tf

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
output "id" {
2+
value = azurerm_static_site.this.id
3+
description = "The ID of the Static Site."
4+
}
5+
6+
output "api_key" {
7+
value = azurerm_static_site.this.api_key
8+
description = "The API Key of the Static Site."
9+
}
10+
11+
output "default_host_name" {
12+
value = azurerm_static_site.this.default_host_name
13+
description = "The Default Host Name of the Static Site."
14+
}
15+
16+
output "identity" {
17+
value = azurerm_static_site.this.identity[*]
18+
description = "The Managed Identity of the Static Site."
19+
}
20+
21+
output "custom_domain_id" {
22+
value = azurerm_static_site_custom_domain.this[*].id
23+
description = "The ID of the Custom Domain."
24+
}
25+
26+
output "validation_token" {
27+
value = var.validation_type == "dns-txt-token" ? azurerm_static_site_custom_domain.this[*].validation_token : null
28+
description = "The Validation Token of the Custom Domain."
29+
}

variables.tf

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
variable "project" {
2+
type = string
3+
description = "Project name"
4+
}
5+
6+
variable "env" {
7+
type = string
8+
description = "Environment"
9+
}
10+
11+
variable "location" {
12+
type = string
13+
description = "Location"
14+
}
15+
16+
variable "tags" {
17+
type = map(string)
18+
description = "Tags"
19+
}
20+
21+
variable "resource_group" {
22+
type = string
23+
description = "Resource group name"
24+
}
25+
26+
variable "name" {
27+
type = string
28+
description = "Static site name"
29+
}
30+
31+
variable "identity_ids" {
32+
type = list(string)
33+
description = "List of user assigned identity IDs"
34+
default = null
35+
}
36+
37+
variable "sku_tier" {
38+
type = string
39+
description = "SKU tier"
40+
default = "Free"
41+
validation {
42+
condition = contains(["Free", "Standard"], var.sku_tier)
43+
error_message = "SKU tier must be either Free or Standard"
44+
}
45+
}
46+
47+
variable "sku_size" {
48+
type = string
49+
description = "SKU size"
50+
default = "Free"
51+
validation {
52+
condition = contains(["Free", "Standard"], var.sku_size)
53+
error_message = "SKU size must be either Free or Standard"
54+
}
55+
}
56+
57+
variable "domain_name" {
58+
type = string
59+
description = "Domain name"
60+
default = null
61+
}
62+
63+
variable "validation_type" {
64+
type = string
65+
description = "Validation type"
66+
default = "dns-txt-token"
67+
validation {
68+
condition = contains(["dns-txt-token", "cname-delegation"], var.validation_type)
69+
error_message = "Validation type must be either cname-delegation or dns-txt-token"
70+
}
71+
}

versions.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
terraform {
2+
required_version = ">= 1.0.0"
3+
4+
required_providers {
5+
azurerm = {
6+
source = "hashicorp/azurerm"
7+
version = ">= 3.23.0"
8+
}
9+
}
10+
}

0 commit comments

Comments
 (0)