Initial commit: add .gitignore and README
This commit is contained in:
156
terraform/modules/README.md
Normal file
156
terraform/modules/README.md
Normal file
@@ -0,0 +1,156 @@
|
||||
# Shared Terraform Modules
|
||||
|
||||
**Purpose**: Reusable Terraform modules for infrastructure provisioning
|
||||
**Last Updated**: 2025-01-27
|
||||
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
This directory contains shared Terraform modules that can be used across all projects to ensure consistency and reduce duplication.
|
||||
|
||||
---
|
||||
|
||||
## Module Structure
|
||||
|
||||
```
|
||||
modules/
|
||||
├── azure/ # Azure-specific modules
|
||||
│ ├── networking/ # Virtual networks, subnets, NSGs
|
||||
│ ├── kubernetes/ # AKS clusters
|
||||
│ ├── keyvault/ # Key Vault with RBAC
|
||||
│ ├── storage/ # Storage accounts
|
||||
│ └── monitoring/ # Monitoring resources
|
||||
├── kubernetes/ # Kubernetes modules (multi-cloud)
|
||||
│ ├── namespace/ # Namespace creation
|
||||
│ ├── ingress/ # Ingress configuration
|
||||
│ └── service/ # Service configuration
|
||||
└── monitoring/ # Monitoring modules
|
||||
├── prometheus/ # Prometheus deployment
|
||||
├── grafana/ # Grafana deployment
|
||||
└── loki/ # Loki deployment
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Usage
|
||||
|
||||
### Example: Using Azure Networking Module
|
||||
|
||||
```hcl
|
||||
module "networking" {
|
||||
source = "../../modules/azure/networking"
|
||||
|
||||
resource_group_name = "rg-example"
|
||||
location = "eastus"
|
||||
vnet_name = "vnet-example"
|
||||
address_space = ["10.0.0.0/16"]
|
||||
|
||||
subnets = [
|
||||
{
|
||||
name = "subnet-1"
|
||||
address_prefix = "10.0.1.0/24"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Example: Using Kubernetes Namespace Module
|
||||
|
||||
```hcl
|
||||
module "namespace" {
|
||||
source = "../../modules/kubernetes/namespace"
|
||||
|
||||
name = "example-namespace"
|
||||
labels = {
|
||||
environment = "production"
|
||||
project = "example"
|
||||
}
|
||||
annotations = {}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Module Development Guidelines
|
||||
|
||||
### 1. Standard Structure
|
||||
|
||||
Each module should follow this structure:
|
||||
|
||||
```
|
||||
module-name/
|
||||
├── main.tf # Main resources
|
||||
├── variables.tf # Input variables
|
||||
├── outputs.tf # Output values
|
||||
├── README.md # Module documentation
|
||||
└── versions.tf # Provider versions
|
||||
```
|
||||
|
||||
### 2. Documentation
|
||||
|
||||
Each module must include:
|
||||
- Purpose and use cases
|
||||
- Input variables documentation
|
||||
- Output values documentation
|
||||
- Usage examples
|
||||
- Requirements
|
||||
|
||||
### 3. Versioning
|
||||
|
||||
- Use semantic versioning (v1.0.0, v1.1.0, etc.)
|
||||
- Tag releases in git
|
||||
- Document breaking changes
|
||||
|
||||
---
|
||||
|
||||
## Available Modules
|
||||
|
||||
### Azure Modules
|
||||
|
||||
#### networking
|
||||
**Purpose**: Create virtual networks, subnets, and network security groups
|
||||
**Status**: 🚧 Planned
|
||||
|
||||
#### kubernetes
|
||||
**Purpose**: Deploy AKS clusters
|
||||
**Status**: 🚧 Planned
|
||||
|
||||
#### keyvault
|
||||
**Purpose**: Create Key Vault with RBAC
|
||||
**Status**: 🚧 Planned
|
||||
|
||||
#### storage
|
||||
**Purpose**: Create storage accounts and containers
|
||||
**Status**: 🚧 Planned
|
||||
|
||||
### Kubernetes Modules
|
||||
|
||||
#### namespace
|
||||
**Purpose**: Create Kubernetes namespaces
|
||||
**Status**: 🚧 Planned
|
||||
|
||||
#### ingress
|
||||
**Purpose**: Configure ingress controllers
|
||||
**Status**: 🚧 Planned
|
||||
|
||||
### Monitoring Modules
|
||||
|
||||
#### prometheus
|
||||
**Purpose**: Deploy Prometheus
|
||||
**Status**: 🚧 Planned
|
||||
|
||||
#### grafana
|
||||
**Purpose**: Deploy Grafana
|
||||
**Status**: 🚧 Planned
|
||||
|
||||
---
|
||||
|
||||
## Migration Plan
|
||||
|
||||
See [TERRAFORM_MODULES_CONSOLIDATION.md](../../../docs/TERRAFORM_MODULES_CONSOLIDATION.md) for detailed migration plan.
|
||||
|
||||
---
|
||||
|
||||
**Last Updated**: 2025-01-27
|
||||
|
||||
61
terraform/modules/azure/keyvault/README.md
Normal file
61
terraform/modules/azure/keyvault/README.md
Normal file
@@ -0,0 +1,61 @@
|
||||
# Azure Key Vault Module
|
||||
|
||||
**Purpose**: Create Azure Key Vault with RBAC
|
||||
**Status**: 🚧 Planned
|
||||
|
||||
---
|
||||
|
||||
## Usage
|
||||
|
||||
```hcl
|
||||
module "keyvault" {
|
||||
source = "../../modules/azure/keyvault"
|
||||
|
||||
resource_group_name = "rg-example"
|
||||
location = "eastus"
|
||||
keyvault_name = "kv-example"
|
||||
|
||||
access_policies = [
|
||||
{
|
||||
object_id = var.service_principal_id
|
||||
key_permissions = ["Get", "List"]
|
||||
secret_permissions = ["Get", "List"]
|
||||
}
|
||||
]
|
||||
|
||||
tags = {
|
||||
Environment = "production"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Inputs
|
||||
|
||||
| Name | Description | Type | Default | Required |
|
||||
|------|-------------|------|---------|----------|
|
||||
| resource_group_name | Name of the resource group | string | - | yes |
|
||||
| location | Azure region | string | - | yes |
|
||||
| keyvault_name | Name of the Key Vault | string | - | yes |
|
||||
| sku_name | SKU name (standard or premium) | string | "standard" | no |
|
||||
| enabled_for_deployment | Enable for VM deployment | bool | false | no |
|
||||
| enabled_for_disk_encryption | Enable for disk encryption | bool | false | no |
|
||||
| enabled_for_template_deployment | Enable for template deployment | bool | false | no |
|
||||
| access_policies | List of access policies | list(object) | [] | no |
|
||||
| tags | Tags to apply | map(string) | {} | no |
|
||||
|
||||
---
|
||||
|
||||
## Outputs
|
||||
|
||||
| Name | Description |
|
||||
|------|-------------|
|
||||
| keyvault_id | Key Vault ID |
|
||||
| keyvault_uri | Key Vault URI |
|
||||
| keyvault_name | Key Vault name |
|
||||
|
||||
---
|
||||
|
||||
**Status**: 🚧 Planned - Module structure ready, implementation pending
|
||||
|
||||
61
terraform/modules/azure/keyvault/main.tf
Normal file
61
terraform/modules/azure/keyvault/main.tf
Normal file
@@ -0,0 +1,61 @@
|
||||
# Azure Key Vault Module
|
||||
# Main resources
|
||||
|
||||
terraform {
|
||||
required_providers {
|
||||
azurerm = {
|
||||
source = "hashicorp/azurerm"
|
||||
version = "~> 3.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Key Vault
|
||||
resource "azurerm_key_vault" "main" {
|
||||
name = var.keyvault_name
|
||||
location = var.location
|
||||
resource_group_name = var.resource_group_name
|
||||
tenant_id = var.tenant_id
|
||||
sku_name = var.sku_name
|
||||
|
||||
enabled_for_deployment = var.enabled_for_deployment
|
||||
enabled_for_disk_encryption = var.enabled_for_disk_encryption
|
||||
enabled_for_template_deployment = var.enabled_for_template_deployment
|
||||
|
||||
network_acls {
|
||||
default_action = var.network_acls.default_action
|
||||
bypass = var.network_acls.bypass
|
||||
ip_rules = var.network_acls.ip_rules
|
||||
virtual_network_subnet_ids = var.network_acls.virtual_network_subnet_ids
|
||||
}
|
||||
|
||||
tags = var.tags
|
||||
|
||||
lifecycle {
|
||||
create_before_destroy = true
|
||||
}
|
||||
}
|
||||
|
||||
# Access Policies
|
||||
resource "azurerm_key_vault_access_policy" "policies" {
|
||||
for_each = { for idx, policy in var.access_policies : idx => policy }
|
||||
|
||||
key_vault_id = azurerm_key_vault.main.id
|
||||
tenant_id = var.tenant_id
|
||||
object_id = each.value.object_id
|
||||
|
||||
key_permissions = each.value.key_permissions
|
||||
secret_permissions = each.value.secret_permissions
|
||||
certificate_permissions = each.value.certificate_permissions
|
||||
storage_permissions = each.value.storage_permissions
|
||||
}
|
||||
|
||||
# RBAC (if enabled)
|
||||
resource "azurerm_role_assignment" "rbac" {
|
||||
for_each = var.enable_rbac ? var.rbac_assignments : {}
|
||||
|
||||
scope = azurerm_key_vault.main.id
|
||||
role_definition_name = each.value.role_definition_name
|
||||
principal_id = each.value.principal_id
|
||||
}
|
||||
|
||||
17
terraform/modules/azure/keyvault/outputs.tf
Normal file
17
terraform/modules/azure/keyvault/outputs.tf
Normal file
@@ -0,0 +1,17 @@
|
||||
# Azure Key Vault Module Outputs
|
||||
|
||||
output "keyvault_id" {
|
||||
description = "Key Vault ID"
|
||||
value = azurerm_key_vault.main.id
|
||||
}
|
||||
|
||||
output "keyvault_uri" {
|
||||
description = "Key Vault URI"
|
||||
value = azurerm_key_vault.main.vault_uri
|
||||
}
|
||||
|
||||
output "keyvault_name" {
|
||||
description = "Key Vault name"
|
||||
value = azurerm_key_vault.main.name
|
||||
}
|
||||
|
||||
95
terraform/modules/azure/keyvault/variables.tf
Normal file
95
terraform/modules/azure/keyvault/variables.tf
Normal file
@@ -0,0 +1,95 @@
|
||||
# Azure Key Vault Module Variables
|
||||
|
||||
variable "resource_group_name" {
|
||||
description = "Name of the resource group"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "location" {
|
||||
description = "Azure region"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "keyvault_name" {
|
||||
description = "Name of the Key Vault"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "tenant_id" {
|
||||
description = "Azure tenant ID"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "sku_name" {
|
||||
description = "SKU name (standard or premium)"
|
||||
type = string
|
||||
default = "standard"
|
||||
}
|
||||
|
||||
variable "enabled_for_deployment" {
|
||||
description = "Enable for VM deployment"
|
||||
type = bool
|
||||
default = false
|
||||
}
|
||||
|
||||
variable "enabled_for_disk_encryption" {
|
||||
description = "Enable for disk encryption"
|
||||
type = bool
|
||||
default = false
|
||||
}
|
||||
|
||||
variable "enabled_for_template_deployment" {
|
||||
description = "Enable for template deployment"
|
||||
type = bool
|
||||
default = false
|
||||
}
|
||||
|
||||
variable "network_acls" {
|
||||
description = "Network ACLs configuration"
|
||||
type = object({
|
||||
default_action = string
|
||||
bypass = string
|
||||
ip_rules = list(string)
|
||||
virtual_network_subnet_ids = list(string)
|
||||
})
|
||||
default = {
|
||||
default_action = "Deny"
|
||||
bypass = "AzureServices"
|
||||
ip_rules = []
|
||||
virtual_network_subnet_ids = []
|
||||
}
|
||||
}
|
||||
|
||||
variable "access_policies" {
|
||||
description = "List of access policies"
|
||||
type = list(object({
|
||||
object_id = string
|
||||
key_permissions = list(string)
|
||||
secret_permissions = list(string)
|
||||
certificate_permissions = list(string)
|
||||
storage_permissions = list(string)
|
||||
}))
|
||||
default = []
|
||||
}
|
||||
|
||||
variable "enable_rbac" {
|
||||
description = "Enable RBAC for Key Vault"
|
||||
type = bool
|
||||
default = false
|
||||
}
|
||||
|
||||
variable "rbac_assignments" {
|
||||
description = "RBAC role assignments"
|
||||
type = map(object({
|
||||
role_definition_name = string
|
||||
principal_id = string
|
||||
}))
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "tags" {
|
||||
description = "Tags to apply to resources"
|
||||
type = map(string)
|
||||
default = {}
|
||||
}
|
||||
|
||||
13
terraform/modules/azure/keyvault/versions.tf
Normal file
13
terraform/modules/azure/keyvault/versions.tf
Normal file
@@ -0,0 +1,13 @@
|
||||
# Azure Key Vault Module - Provider Versions
|
||||
|
||||
terraform {
|
||||
required_version = ">= 1.0"
|
||||
|
||||
required_providers {
|
||||
azurerm = {
|
||||
source = "hashicorp/azurerm"
|
||||
version = "~> 3.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
86
terraform/modules/azure/networking/README.md
Normal file
86
terraform/modules/azure/networking/README.md
Normal file
@@ -0,0 +1,86 @@
|
||||
# Azure Networking Module
|
||||
|
||||
**Purpose**: Create Azure Virtual Network with subnets and network security groups
|
||||
**Status**: ✅ Complete
|
||||
|
||||
---
|
||||
|
||||
## Usage
|
||||
|
||||
```hcl
|
||||
module "networking" {
|
||||
source = "../../modules/azure/networking"
|
||||
|
||||
resource_group_name = "rg-example"
|
||||
location = "eastus"
|
||||
vnet_name = "vnet-example"
|
||||
address_space = ["10.0.0.0/16"]
|
||||
|
||||
subnets = {
|
||||
frontend = {
|
||||
name = "snet-frontend"
|
||||
address_prefixes = ["10.0.1.0/24"]
|
||||
service_endpoints = ["Microsoft.Storage"]
|
||||
}
|
||||
backend = {
|
||||
name = "snet-backend"
|
||||
address_prefixes = ["10.0.2.0/24"]
|
||||
service_endpoints = []
|
||||
}
|
||||
}
|
||||
|
||||
network_security_groups = {
|
||||
frontend_nsg = {
|
||||
name = "nsg-frontend"
|
||||
subnet_key = "frontend"
|
||||
security_rules = [
|
||||
{
|
||||
name = "AllowHTTP"
|
||||
priority = 100
|
||||
direction = "Inbound"
|
||||
access = "Allow"
|
||||
protocol = "Tcp"
|
||||
source_port_range = "*"
|
||||
destination_port_range = "80"
|
||||
source_address_prefix = "*"
|
||||
destination_address_prefix = "*"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
tags = {
|
||||
Environment = "production"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Inputs
|
||||
|
||||
| Name | Description | Type | Default | Required |
|
||||
|------|-------------|------|---------|----------|
|
||||
| resource_group_name | Name of the resource group | string | - | yes |
|
||||
| location | Azure region | string | - | yes |
|
||||
| vnet_name | Name of the virtual network | string | - | yes |
|
||||
| address_space | Address space for the virtual network | list(string) | - | yes |
|
||||
| subnets | Map of subnets to create | map(object) | {} | no |
|
||||
| network_security_groups | Map of network security groups | map(object) | {} | no |
|
||||
| tags | Tags to apply | map(string) | {} | no |
|
||||
|
||||
---
|
||||
|
||||
## Outputs
|
||||
|
||||
| Name | Description |
|
||||
|------|-------------|
|
||||
| vnet_id | Virtual network ID |
|
||||
| vnet_name | Virtual network name |
|
||||
| subnet_ids | Map of subnet names to IDs |
|
||||
| subnet_names | Map of subnet names |
|
||||
| nsg_ids | Map of NSG names to IDs |
|
||||
|
||||
---
|
||||
|
||||
**Status**: ✅ Complete - Ready for use
|
||||
73
terraform/modules/azure/networking/main.tf
Normal file
73
terraform/modules/azure/networking/main.tf
Normal file
@@ -0,0 +1,73 @@
|
||||
# Azure Networking Module
|
||||
# Main resources
|
||||
|
||||
terraform {
|
||||
required_providers {
|
||||
azurerm = {
|
||||
source = "hashicorp/azurerm"
|
||||
version = "~> 3.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Virtual Network
|
||||
resource "azurerm_virtual_network" "main" {
|
||||
name = var.vnet_name
|
||||
address_space = var.address_space
|
||||
location = var.location
|
||||
resource_group_name = var.resource_group_name
|
||||
tags = var.tags
|
||||
|
||||
lifecycle {
|
||||
create_before_destroy = true
|
||||
}
|
||||
}
|
||||
|
||||
# Subnets
|
||||
resource "azurerm_subnet" "subnets" {
|
||||
for_each = var.subnets
|
||||
|
||||
name = each.value.name
|
||||
resource_group_name = var.resource_group_name
|
||||
virtual_network_name = azurerm_virtual_network.main.name
|
||||
address_prefixes = each.value.address_prefixes
|
||||
service_endpoints = each.value.service_endpoints
|
||||
|
||||
lifecycle {
|
||||
create_before_destroy = true
|
||||
}
|
||||
}
|
||||
|
||||
# Network Security Groups
|
||||
resource "azurerm_network_security_group" "nsgs" {
|
||||
for_each = var.network_security_groups
|
||||
|
||||
name = each.value.name
|
||||
location = var.location
|
||||
resource_group_name = var.resource_group_name
|
||||
tags = var.tags
|
||||
|
||||
dynamic "security_rule" {
|
||||
for_each = each.value.security_rules
|
||||
content {
|
||||
name = security_rule.value.name
|
||||
priority = security_rule.value.priority
|
||||
direction = security_rule.value.direction
|
||||
access = security_rule.value.access
|
||||
protocol = security_rule.value.protocol
|
||||
source_port_range = security_rule.value.source_port_range
|
||||
destination_port_range = security_rule.value.destination_port_range
|
||||
source_address_prefix = security_rule.value.source_address_prefix
|
||||
destination_address_prefix = security_rule.value.destination_address_prefix
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Associate NSGs with subnets
|
||||
resource "azurerm_subnet_network_security_group_association" "nsg_associations" {
|
||||
for_each = var.network_security_groups
|
||||
|
||||
subnet_id = azurerm_subnet.subnets[each.value.subnet_key].id
|
||||
network_security_group_id = azurerm_network_security_group.nsgs[each.key].id
|
||||
}
|
||||
|
||||
27
terraform/modules/azure/networking/outputs.tf
Normal file
27
terraform/modules/azure/networking/outputs.tf
Normal file
@@ -0,0 +1,27 @@
|
||||
# Azure Networking Module Outputs
|
||||
|
||||
output "vnet_id" {
|
||||
description = "Virtual network ID"
|
||||
value = azurerm_virtual_network.main.id
|
||||
}
|
||||
|
||||
output "vnet_name" {
|
||||
description = "Virtual network name"
|
||||
value = azurerm_virtual_network.main.name
|
||||
}
|
||||
|
||||
output "subnet_ids" {
|
||||
description = "Map of subnet names to IDs"
|
||||
value = { for k, v in azurerm_subnet.subnets : k => v.id }
|
||||
}
|
||||
|
||||
output "subnet_names" {
|
||||
description = "Map of subnet names"
|
||||
value = { for k, v in azurerm_subnet.subnets : k => v.name }
|
||||
}
|
||||
|
||||
output "nsg_ids" {
|
||||
description = "Map of NSG names to IDs"
|
||||
value = { for k, v in azurerm_network_security_group.nsgs : k => v.id }
|
||||
}
|
||||
|
||||
58
terraform/modules/azure/networking/variables.tf
Normal file
58
terraform/modules/azure/networking/variables.tf
Normal file
@@ -0,0 +1,58 @@
|
||||
# Azure Networking Module Variables
|
||||
|
||||
variable "resource_group_name" {
|
||||
description = "Name of the resource group"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "location" {
|
||||
description = "Azure region"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "vnet_name" {
|
||||
description = "Name of the virtual network"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "address_space" {
|
||||
description = "Address space for the virtual network"
|
||||
type = list(string)
|
||||
}
|
||||
|
||||
variable "subnets" {
|
||||
description = "Map of subnets to create"
|
||||
type = map(object({
|
||||
name = string
|
||||
address_prefixes = list(string)
|
||||
service_endpoints = list(string)
|
||||
}))
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "network_security_groups" {
|
||||
description = "Map of network security groups to create"
|
||||
type = map(object({
|
||||
name = string
|
||||
subnet_key = string
|
||||
security_rules = list(object({
|
||||
name = string
|
||||
priority = number
|
||||
direction = string
|
||||
access = string
|
||||
protocol = string
|
||||
source_port_range = string
|
||||
destination_port_range = string
|
||||
source_address_prefix = string
|
||||
destination_address_prefix = string
|
||||
}))
|
||||
}))
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "tags" {
|
||||
description = "Tags to apply to resources"
|
||||
type = map(string)
|
||||
default = {}
|
||||
}
|
||||
|
||||
13
terraform/modules/azure/networking/versions.tf
Normal file
13
terraform/modules/azure/networking/versions.tf
Normal file
@@ -0,0 +1,13 @@
|
||||
# Azure Networking Module - Provider Versions
|
||||
|
||||
terraform {
|
||||
required_version = ">= 1.0"
|
||||
|
||||
required_providers {
|
||||
azurerm = {
|
||||
source = "hashicorp/azurerm"
|
||||
version = "~> 3.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
58
terraform/modules/azure/storage/README.md
Normal file
58
terraform/modules/azure/storage/README.md
Normal file
@@ -0,0 +1,58 @@
|
||||
# Azure Storage Module
|
||||
|
||||
**Purpose**: Create storage accounts and containers
|
||||
**Status**: 🚧 Planned
|
||||
|
||||
---
|
||||
|
||||
## Usage
|
||||
|
||||
```hcl
|
||||
module "storage" {
|
||||
source = "../../modules/azure/storage"
|
||||
|
||||
resource_group_name = "rg-example"
|
||||
location = "eastus"
|
||||
storage_account_name = "stexample"
|
||||
|
||||
containers = [
|
||||
{
|
||||
name = "container1"
|
||||
access_type = "private"
|
||||
}
|
||||
]
|
||||
|
||||
tags = {
|
||||
Environment = "production"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Inputs
|
||||
|
||||
| Name | Description | Type | Default | Required |
|
||||
|------|-------------|------|---------|----------|
|
||||
| resource_group_name | Name of the resource group | string | - | yes |
|
||||
| location | Azure region | string | - | yes |
|
||||
| storage_account_name | Name of the storage account | string | - | yes |
|
||||
| account_tier | Storage account tier | string | "Standard" | no |
|
||||
| account_replication_type | Replication type | string | "LRS" | no |
|
||||
| containers | List of containers to create | list(object) | [] | no |
|
||||
| tags | Tags to apply | map(string) | {} | no |
|
||||
|
||||
---
|
||||
|
||||
## Outputs
|
||||
|
||||
| Name | Description |
|
||||
|------|-------------|
|
||||
| storage_account_id | Storage account ID |
|
||||
| storage_account_name | Storage account name |
|
||||
| primary_connection_string | Primary connection string (sensitive) |
|
||||
|
||||
---
|
||||
|
||||
**Status**: 🚧 Planned - Module structure ready, implementation pending
|
||||
|
||||
81
terraform/modules/azure/storage/main.tf
Normal file
81
terraform/modules/azure/storage/main.tf
Normal file
@@ -0,0 +1,81 @@
|
||||
# Azure Storage Module
|
||||
# Main resources
|
||||
|
||||
terraform {
|
||||
required_providers {
|
||||
azurerm = {
|
||||
source = "hashicorp/azurerm"
|
||||
version = "~> 3.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Storage Account
|
||||
resource "azurerm_storage_account" "main" {
|
||||
name = var.storage_account_name
|
||||
resource_group_name = var.resource_group_name
|
||||
location = var.location
|
||||
account_tier = var.account_tier
|
||||
account_replication_type = var.account_replication_type
|
||||
account_kind = var.account_kind
|
||||
|
||||
enable_https_traffic_only = var.enable_https_traffic_only
|
||||
min_tls_version = var.min_tls_version
|
||||
|
||||
blob_properties {
|
||||
delete_retention_policy {
|
||||
days = var.blob_delete_retention_days
|
||||
}
|
||||
container_delete_retention_policy {
|
||||
days = var.container_delete_retention_days
|
||||
}
|
||||
}
|
||||
|
||||
network_rules {
|
||||
default_action = var.network_rules.default_action
|
||||
bypass = var.network_rules.bypass
|
||||
ip_rules = var.network_rules.ip_rules
|
||||
virtual_network_subnet_ids = var.network_rules.virtual_network_subnet_ids
|
||||
}
|
||||
|
||||
tags = var.tags
|
||||
|
||||
lifecycle {
|
||||
create_before_destroy = true
|
||||
}
|
||||
}
|
||||
|
||||
# Containers
|
||||
resource "azurerm_storage_container" "containers" {
|
||||
for_each = var.containers
|
||||
|
||||
name = each.value.name
|
||||
storage_account_name = azurerm_storage_account.main.name
|
||||
container_access_type = each.value.access_type
|
||||
}
|
||||
|
||||
# File Shares
|
||||
resource "azurerm_storage_share" "shares" {
|
||||
for_each = var.file_shares
|
||||
|
||||
name = each.value.name
|
||||
storage_account_name = azurerm_storage_account.main.name
|
||||
quota = each.value.quota
|
||||
}
|
||||
|
||||
# Queues
|
||||
resource "azurerm_storage_queue" "queues" {
|
||||
for_each = var.queues
|
||||
|
||||
name = each.value.name
|
||||
storage_account_name = azurerm_storage_account.main.name
|
||||
}
|
||||
|
||||
# Tables
|
||||
resource "azurerm_storage_table" "tables" {
|
||||
for_each = var.tables
|
||||
|
||||
name = each.value.name
|
||||
storage_account_name = azurerm_storage_account.main.name
|
||||
}
|
||||
|
||||
34
terraform/modules/azure/storage/outputs.tf
Normal file
34
terraform/modules/azure/storage/outputs.tf
Normal file
@@ -0,0 +1,34 @@
|
||||
# Azure Storage Module Outputs
|
||||
|
||||
output "storage_account_id" {
|
||||
description = "Storage account ID"
|
||||
value = azurerm_storage_account.main.id
|
||||
}
|
||||
|
||||
output "storage_account_name" {
|
||||
description = "Storage account name"
|
||||
value = azurerm_storage_account.main.name
|
||||
}
|
||||
|
||||
output "primary_connection_string" {
|
||||
description = "Primary connection string (sensitive)"
|
||||
value = azurerm_storage_account.main.primary_connection_string
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
output "primary_access_key" {
|
||||
description = "Primary access key (sensitive)"
|
||||
value = azurerm_storage_account.main.primary_access_key
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
output "primary_blob_endpoint" {
|
||||
description = "Primary blob endpoint"
|
||||
value = azurerm_storage_account.main.primary_blob_endpoint
|
||||
}
|
||||
|
||||
output "container_names" {
|
||||
description = "Map of container names"
|
||||
value = { for k, v in azurerm_storage_container.containers : k => v.name }
|
||||
}
|
||||
|
||||
115
terraform/modules/azure/storage/variables.tf
Normal file
115
terraform/modules/azure/storage/variables.tf
Normal file
@@ -0,0 +1,115 @@
|
||||
# Azure Storage Module Variables
|
||||
|
||||
variable "resource_group_name" {
|
||||
description = "Name of the resource group"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "location" {
|
||||
description = "Azure region"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "storage_account_name" {
|
||||
description = "Name of the storage account"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "account_tier" {
|
||||
description = "Storage account tier (Standard or Premium)"
|
||||
type = string
|
||||
default = "Standard"
|
||||
}
|
||||
|
||||
variable "account_replication_type" {
|
||||
description = "Replication type (LRS, GRS, RAGRS, ZRS)"
|
||||
type = string
|
||||
default = "LRS"
|
||||
}
|
||||
|
||||
variable "account_kind" {
|
||||
description = "Account kind (StorageV2, BlobStorage, etc.)"
|
||||
type = string
|
||||
default = "StorageV2"
|
||||
}
|
||||
|
||||
variable "enable_https_traffic_only" {
|
||||
description = "Enable HTTPS traffic only"
|
||||
type = bool
|
||||
default = true
|
||||
}
|
||||
|
||||
variable "min_tls_version" {
|
||||
description = "Minimum TLS version"
|
||||
type = string
|
||||
default = "TLS1_2"
|
||||
}
|
||||
|
||||
variable "blob_delete_retention_days" {
|
||||
description = "Blob delete retention days"
|
||||
type = number
|
||||
default = 7
|
||||
}
|
||||
|
||||
variable "container_delete_retention_days" {
|
||||
description = "Container delete retention days"
|
||||
type = number
|
||||
default = 7
|
||||
}
|
||||
|
||||
variable "network_rules" {
|
||||
description = "Network rules configuration"
|
||||
type = object({
|
||||
default_action = string
|
||||
bypass = list(string)
|
||||
ip_rules = list(string)
|
||||
virtual_network_subnet_ids = list(string)
|
||||
})
|
||||
default = {
|
||||
default_action = "Allow"
|
||||
bypass = ["AzureServices"]
|
||||
ip_rules = []
|
||||
virtual_network_subnet_ids = []
|
||||
}
|
||||
}
|
||||
|
||||
variable "containers" {
|
||||
description = "Map of containers to create"
|
||||
type = map(object({
|
||||
name = string
|
||||
access_type = string
|
||||
}))
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "file_shares" {
|
||||
description = "Map of file shares to create"
|
||||
type = map(object({
|
||||
name = string
|
||||
quota = number
|
||||
}))
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "queues" {
|
||||
description = "Map of queues to create"
|
||||
type = map(object({
|
||||
name = string
|
||||
}))
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "tables" {
|
||||
description = "Map of tables to create"
|
||||
type = map(object({
|
||||
name = string
|
||||
}))
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "tags" {
|
||||
description = "Tags to apply to resources"
|
||||
type = map(string)
|
||||
default = {}
|
||||
}
|
||||
|
||||
13
terraform/modules/azure/storage/versions.tf
Normal file
13
terraform/modules/azure/storage/versions.tf
Normal file
@@ -0,0 +1,13 @@
|
||||
# Azure Storage Module - Provider Versions
|
||||
|
||||
terraform {
|
||||
required_version = ">= 1.0"
|
||||
|
||||
required_providers {
|
||||
azurerm = {
|
||||
source = "hashicorp/azurerm"
|
||||
version = "~> 3.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
81
terraform/modules/kubernetes/namespace/README.md
Normal file
81
terraform/modules/kubernetes/namespace/README.md
Normal file
@@ -0,0 +1,81 @@
|
||||
# Kubernetes Namespace Module
|
||||
|
||||
**Purpose**: Create Kubernetes namespace with resource quotas and limit ranges
|
||||
**Status**: ✅ Complete
|
||||
|
||||
---
|
||||
|
||||
## Usage
|
||||
|
||||
```hcl
|
||||
module "namespace" {
|
||||
source = "../../modules/kubernetes/namespace"
|
||||
|
||||
name = "my-app"
|
||||
|
||||
labels = {
|
||||
app = "my-app"
|
||||
env = "production"
|
||||
managed = "terraform"
|
||||
}
|
||||
|
||||
annotations = {
|
||||
description = "Namespace for my-app"
|
||||
}
|
||||
|
||||
resource_quota = {
|
||||
"requests.cpu" = "4"
|
||||
"requests.memory" = "8Gi"
|
||||
"limits.cpu" = "8"
|
||||
"limits.memory" = "16Gi"
|
||||
}
|
||||
|
||||
limit_range = {
|
||||
default = {
|
||||
"cpu" = "500m"
|
||||
"memory" = "1Gi"
|
||||
}
|
||||
default_request = {
|
||||
"cpu" = "100m"
|
||||
"memory" = "128Mi"
|
||||
}
|
||||
max = {
|
||||
"cpu" = "2"
|
||||
"memory" = "4Gi"
|
||||
}
|
||||
min = {
|
||||
"cpu" = "50m"
|
||||
"memory" = "64Mi"
|
||||
}
|
||||
max_limit_request_ratio = {
|
||||
"cpu" = "4"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Inputs
|
||||
|
||||
| Name | Description | Type | Default | Required |
|
||||
|------|-------------|------|---------|----------|
|
||||
| name | Namespace name | string | - | yes |
|
||||
| labels | Labels to apply | map(string) | {} | no |
|
||||
| annotations | Annotations to apply | map(string) | {} | no |
|
||||
| resource_quota | Resource quota limits | map(string) | {} | no |
|
||||
| limit_range | Limit range configuration | object | {} | no |
|
||||
|
||||
---
|
||||
|
||||
## Outputs
|
||||
|
||||
| Name | Description |
|
||||
|------|-------------|
|
||||
| namespace_name | Namespace name |
|
||||
| namespace_id | Namespace UID |
|
||||
| resource_quota_id | Resource quota ID (if created) |
|
||||
|
||||
---
|
||||
|
||||
**Status**: ✅ Complete - Ready for use
|
||||
55
terraform/modules/kubernetes/namespace/main.tf
Normal file
55
terraform/modules/kubernetes/namespace/main.tf
Normal file
@@ -0,0 +1,55 @@
|
||||
# Kubernetes Namespace Module
|
||||
# Main resources
|
||||
|
||||
terraform {
|
||||
required_providers {
|
||||
kubernetes = {
|
||||
source = "hashicorp/kubernetes"
|
||||
version = "~> 2.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Namespace
|
||||
resource "kubernetes_namespace" "main" {
|
||||
metadata {
|
||||
name = var.name
|
||||
labels = var.labels
|
||||
annotations = var.annotations
|
||||
}
|
||||
}
|
||||
|
||||
# Resource Quota (if specified)
|
||||
resource "kubernetes_resource_quota" "quota" {
|
||||
count = length(var.resource_quota) > 0 ? 1 : 0
|
||||
|
||||
metadata {
|
||||
name = "${var.name}-quota"
|
||||
namespace = kubernetes_namespace.main.metadata[0].name
|
||||
}
|
||||
|
||||
spec {
|
||||
hard = var.resource_quota
|
||||
}
|
||||
}
|
||||
|
||||
# Limit Range (if specified)
|
||||
resource "kubernetes_limit_range" "limits" {
|
||||
count = length(var.limit_range) > 0 ? 1 : 0
|
||||
|
||||
metadata {
|
||||
name = "${var.name}-limits"
|
||||
namespace = kubernetes_namespace.main.metadata[0].name
|
||||
}
|
||||
|
||||
spec {
|
||||
limit {
|
||||
default = var.limit_range.default
|
||||
default_request = var.limit_range.default_request
|
||||
max = var.limit_range.max
|
||||
min = var.limit_range.min
|
||||
max_limit_request_ratio = var.limit_range.max_limit_request_ratio
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
17
terraform/modules/kubernetes/namespace/outputs.tf
Normal file
17
terraform/modules/kubernetes/namespace/outputs.tf
Normal file
@@ -0,0 +1,17 @@
|
||||
# Kubernetes Namespace Module Outputs
|
||||
|
||||
output "namespace_name" {
|
||||
description = "Namespace name"
|
||||
value = kubernetes_namespace.main.metadata[0].name
|
||||
}
|
||||
|
||||
output "namespace_id" {
|
||||
description = "Namespace UID"
|
||||
value = kubernetes_namespace.main.metadata[0].uid
|
||||
}
|
||||
|
||||
output "resource_quota_id" {
|
||||
description = "Resource quota ID (if created)"
|
||||
value = length(kubernetes_resource_quota.quota) > 0 ? kubernetes_resource_quota.quota[0].metadata[0].uid : null
|
||||
}
|
||||
|
||||
43
terraform/modules/kubernetes/namespace/variables.tf
Normal file
43
terraform/modules/kubernetes/namespace/variables.tf
Normal file
@@ -0,0 +1,43 @@
|
||||
# Kubernetes Namespace Module Variables
|
||||
|
||||
variable "name" {
|
||||
description = "Namespace name"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "labels" {
|
||||
description = "Labels to apply to namespace"
|
||||
type = map(string)
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "annotations" {
|
||||
description = "Annotations to apply to namespace"
|
||||
type = map(string)
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "resource_quota" {
|
||||
description = "Resource quota limits"
|
||||
type = map(string)
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "limit_range" {
|
||||
description = "Limit range configuration"
|
||||
type = object({
|
||||
default = map(string)
|
||||
default_request = map(string)
|
||||
max = map(string)
|
||||
min = map(string)
|
||||
max_limit_request_ratio = map(string)
|
||||
})
|
||||
default = {
|
||||
default = {}
|
||||
default_request = {}
|
||||
max = {}
|
||||
min = {}
|
||||
max_limit_request_ratio = {}
|
||||
}
|
||||
}
|
||||
|
||||
13
terraform/modules/kubernetes/namespace/versions.tf
Normal file
13
terraform/modules/kubernetes/namespace/versions.tf
Normal file
@@ -0,0 +1,13 @@
|
||||
# Kubernetes Namespace Module - Provider Versions
|
||||
|
||||
terraform {
|
||||
required_version = ">= 1.0"
|
||||
|
||||
required_providers {
|
||||
kubernetes = {
|
||||
source = "hashicorp/kubernetes"
|
||||
version = "~> 2.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user