-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
Initial commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# ignored files | ||
*.tfstate | ||
*.tfstate.backup | ||
.terraform | ||
.idea | ||
*.iml | ||
.terraform.tfstate.lock.info | ||
.terraform.lock.hcl |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--- | ||
# | ||
# This is the canonical configuration for the `README.md` | ||
# Run `make readme` to rebuild the `README.md` | ||
# | ||
|
||
|
||
# Name of this project | ||
name: Terraform AZURE STORAGE | ||
|
||
# License of this project | ||
license: "APACHE" | ||
|
||
# Canonical GitHub repo | ||
github_repo: clouddrove/terraform-azure-storage | ||
|
||
# Badges to display | ||
badges: | ||
- name: "Terraform" | ||
image: "https://img.shields.io/badge/Terraform-v1.1.7-green" | ||
url: "https://www.terraform.io" | ||
- name: "Licence" | ||
image: "https://img.shields.io/badge/License-APACHE-blue.svg" | ||
url: "LICENSE.md" | ||
|
||
# description of this project | ||
description: |- | ||
Terraform module to create STORAGE resource on AZURE. | ||
# extra content | ||
include: | ||
- "terraform.md" | ||
|
||
# How to use this project | ||
# yamllint disable rule:line-length | ||
usage: |- | ||
### Simple Example | ||
Here is an example of how you can use this module in your inventory structure: | ||
```hcl | ||
module "storage" { | ||
source = "clouddrove/storage/azure" | ||
resource_group_name = module.resource_group.resource_group_name | ||
storage_account_name = "mystorage" | ||
enable_advanced_threat_protection = true | ||
containers_list = [ | ||
{ name = "mystore250", access_type = "private" }, | ||
] | ||
} | ||
|
||
``` |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Azure Provider configuration | ||
provider "azurerm" { | ||
features {} | ||
} | ||
|
||
module "resource_group" { | ||
source = "clouddrove/resource-group/azure" | ||
|
||
label_order = ["name", "environment", ] | ||
name = "trustspherstoraget" | ||
environment = "staging" | ||
location = "North Europe" | ||
} | ||
|
||
module "storage" { | ||
depends_on = [module.resource_group] | ||
source = "./.././" | ||
resource_group_name = module.resource_group.resource_group_name | ||
storage_account_name = "storagestartac" | ||
account_kind = "BlobStorage" | ||
account_tier = "Standard" | ||
account_replication_type = "GRS" | ||
|
||
containers_list = [ | ||
{ name = "mystore250", access_type = "private" }, | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
output "storage_account_id" { | ||
value = module.storage.storage_account_id | ||
description = "The ID of the storage account." | ||
} | ||
|
||
output "storage_account_name" { | ||
value = module.storage.storage_account_name | ||
description = "The name of the storage account." | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Terraform version | ||
terraform { | ||
required_version = ">= 1.0.0" | ||
} | ||
|
||
terraform { | ||
required_providers { | ||
azurerm = { | ||
source = "hashicorp/azurerm" | ||
version = ">=2.90.0" | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,63 @@ | ||
locals {} | ||
data "azurerm_resource_group" "default" { | ||
name = var.resource_group_name | ||
} | ||
|
||
locals { | ||
resource_group_name = data.azurerm_resource_group.default.name | ||
location = data.azurerm_resource_group.default.location | ||
} | ||
|
||
module "labels" { | ||
source = "clouddrove/labels/azure" | ||
version = "1.0.0" | ||
name = var.name | ||
environment = var.environment | ||
managedby = var.managedby | ||
label_order = var.label_order | ||
repository = var.repository | ||
} | ||
|
||
resource "azurerm_storage_account" "storage" { | ||
count = var.enabled ? 1 : 0 | ||
name = var.storage_account_name | ||
resource_group_name = local.resource_group_name | ||
location = local.location | ||
account_kind = var.account_kind | ||
account_tier = var.account_tier | ||
access_tier = var.access_tier | ||
account_replication_type = var.account_replication_type | ||
enable_https_traffic_only = var.enable_https_traffic_only | ||
min_tls_version = var.min_tls_version | ||
tags = module.labels.tags | ||
|
||
blob_properties { | ||
delete_retention_policy { | ||
days = var.soft_delete_retention | ||
} | ||
} | ||
|
||
dynamic "network_rules" { | ||
for_each = var.network_rules != null ? ["true"] : [] | ||
content { | ||
default_action = "Deny" | ||
bypass = var.network_rules.bypass | ||
ip_rules = var.network_rules.ip_rules | ||
virtual_network_subnet_ids = var.network_rules.subnet_ids | ||
} | ||
} | ||
} | ||
|
||
## Storage Container Creation | ||
resource "azurerm_storage_container" "container" { | ||
count = length(var.containers_list) | ||
name = var.containers_list[count.index].name | ||
storage_account_name = join("", azurerm_storage_account.storage.*.name) | ||
container_access_type = var.containers_list[count.index].access_type | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
output "storage_account_id" { | ||
value = join("", azurerm_storage_account.storage.*.id) | ||
description = "The ID of the storage account." | ||
} | ||
|
||
output "storage_account_name" { | ||
value = join("", azurerm_storage_account.storage.*.name) | ||
description = "The name of the storage account." | ||
} | ||
|
||
output "storage_account_primary_location" { | ||
value = join("", azurerm_storage_account.storage.*.primary_location) | ||
description = "The primary location of the storage account" | ||
} | ||
|
||
output "storage_account_primary_web_endpoint" { | ||
value = join("", azurerm_storage_account.storage.*.primary_web_endpoint) | ||
description = "The endpoint URL for web storage in the primary location." | ||
} | ||
|
||
output "storage_account_primary_web_host" { | ||
value = join("", azurerm_storage_account.storage.*.primary_web_host) | ||
description = "The hostname with port if applicable for web storage in the primary location." | ||
} | ||
|
||
output "storage_primary_connection_string" { | ||
value = join("", azurerm_storage_account.storage.*.primary_connection_string) | ||
sensitive = true | ||
description = "The primary connection string for the storage account" | ||
} | ||
|
||
output "storage_primary_access_key" { | ||
value = join("", azurerm_storage_account.storage.*.primary_access_key) | ||
sensitive = true | ||
description = "The primary access key for the storage account" | ||
} | ||
|
||
output "storage_secondary_access_key" { | ||
value = join("", azurerm_storage_account.storage.*.secondary_access_key) | ||
sensitive = true | ||
description = "The primary access key for the storage account." | ||
} | ||
|
||
output "containers" { | ||
value = { for c in azurerm_storage_container.container : c.name => c.id } | ||
description = "Map of containers." | ||
} |