Skip to content

Commit

Permalink
Merge pull request #1 from clouddrove/ticket
Browse files Browse the repository at this point in the history
Initial commit
  • Loading branch information
Om Sharma authored Dec 8, 2022
2 parents 0f96426 + 61f08a8 commit 11430f2
Show file tree
Hide file tree
Showing 21 changed files with 375 additions and 31 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/static-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- ${{ needs.versionExtract.outputs.minVersion }}
- ${{ needs.versionExtract.outputs.maxVersion }}
directory:
- _example/complete
- _example/

steps:
- name: Checkout
Expand All @@ -46,14 +46,14 @@ jobs:
cd ${{ matrix.directory }}
terraform init
terraform validate
- name: tflint
uses: reviewdog/action-tflint@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
working_directory: ${{ matrix.directory }}
fail_on_error: 'true'
filter_mode: 'nofilter'
flags: '--module'
# - name: tflint
# uses: reviewdog/action-tflint@master
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# working_directory: ${{ matrix.directory }}
# fail_on_error: 'true'
# filter_mode: 'nofilter'
# flags: '--module'

format:
name: Check code format
Expand Down
8 changes: 8 additions & 0 deletions .gitignore
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
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/terraform-azure-storage.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 52 additions & 0 deletions README.yaml
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" },
]
}

```
Empty file removed _example/complete/README.md
Empty file.
1 change: 0 additions & 1 deletion _example/complete/main.tf

This file was deleted.

Empty file removed _example/complete/outputs.tf
Empty file.
Empty file.
Empty file removed _example/complete/variables.tf
Empty file.
10 changes: 0 additions & 10 deletions _example/complete/versions.tf

This file was deleted.

27 changes: 27 additions & 0 deletions _example/example.tf
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" },
]
}
9 changes: 9 additions & 0 deletions _example/outputs.tf
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."
}
13 changes: 13 additions & 0 deletions _example/versions.tf
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"
}
}
}
64 changes: 63 additions & 1 deletion main.tf
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
}







47 changes: 47 additions & 0 deletions outputs.tf
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."
}
Loading

0 comments on commit 11430f2

Please sign in to comment.