diff --git a/may-2025-testing/terraform/.gitignore b/may-2025-testing/terraform/.gitignore new file mode 100644 index 0000000..05b2a76 --- /dev/null +++ b/may-2025-testing/terraform/.gitignore @@ -0,0 +1,32 @@ +# Source: https://github.com/github/gitignore/blob/main/Terraform.gitignore +# Local .terraform directories +**/.terraform/* + +# .tfstate files +*.tfstate +*.tfstate.* + +# Crash log files +crash.log +crash.*.log + +# Ignore override files as they are usually used to override resources locally and so +# are not checked in +override.tf +override.tf.json +*_override.tf +*_override.tf.json + +# Ignore transient lock info files created by terraform apply +.terraform.tfstate.lock.info + +# Include override files you do wish to add to version control using negated pattern +# !example_override.tf + +# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan +# example: *tfplan* + +# Ignore CLI configuration files +.terraformrc +terraform.rc + diff --git a/may-2025-testing/terraform/.metadata b/may-2025-testing/terraform/.metadata new file mode 100644 index 0000000..4e48db5 --- /dev/null +++ b/may-2025-testing/terraform/.metadata @@ -0,0 +1,7 @@ +{ + "app_stack_name": "azure-may-2025-release", + "iac_type": "Terraform", + "provider": "azure", + "multi_env": false, + "exporter": "terraform" +} \ No newline at end of file diff --git a/may-2025-testing/terraform/README.md b/may-2025-testing/terraform/README.md new file mode 100644 index 0000000..0b221cf --- /dev/null +++ b/may-2025-testing/terraform/README.md @@ -0,0 +1,3 @@ +# README +This is a readme file for IaC generated with StackGen. +You can modify your appStack -> [here](http://stage.dev.stackgen.com/appstacks/a85caf2f-04ac-465d-a900-381088edbc23) diff --git a/may-2025-testing/terraform/main.tf b/may-2025-testing/terraform/main.tf new file mode 100644 index 0000000..05f9bb4 --- /dev/null +++ b/may-2025-testing/terraform/main.tf @@ -0,0 +1,41 @@ +module "stackgen_5f506321-272e-414e-99f6-fd4a254c0bb7" { + source = "./modules/azurerm_subnet_composite" + address_prefixes = [] + default_outbound_access_enabled = null + delegations = [] + location = var.location + name = "sg-az-subnet-1" + network_security_group_id = "" + resource_group_name = local.resource_group_name + service_endpoint_policy_ids = [] + service_endpoints = [] + virtual_network_name = module.stackgen_fd99e64e-3b93-4921-a0a3-0f145a636d34.name +} + +module "stackgen_d1e95b01-4f45-4753-9e48-dc6be963e22f" { + source = "./modules/azurerm_subnet_composite" + address_prefixes = [] + default_outbound_access_enabled = null + delegations = [] + location = var.location + name = "sg-az-subnet-2" + network_security_group_id = "" + resource_group_name = local.resource_group_name + service_endpoint_policy_ids = [] + service_endpoints = [] + virtual_network_name = module.stackgen_fd99e64e-3b93-4921-a0a3-0f145a636d34.name +} + +module "stackgen_fd99e64e-3b93-4921-a0a3-0f145a636d34" { + source = "./modules/azurerm_vn" + address_space = [] + ddos_protection_name = "" + dns_servers = [] + edge_zone = null + flow_timeout_in_minutes = null + location = var.location + name = "sg-az-vnet-1" + resource_group_name = local.resource_group_name + tags = {} +} + diff --git a/may-2025-testing/terraform/modules/azurerm_subnet_composite/azurerm_subnet_composite.tf b/may-2025-testing/terraform/modules/azurerm_subnet_composite/azurerm_subnet_composite.tf new file mode 100644 index 0000000..bd9be55 --- /dev/null +++ b/may-2025-testing/terraform/modules/azurerm_subnet_composite/azurerm_subnet_composite.tf @@ -0,0 +1,31 @@ +resource "azurerm_subnet" "this" { + address_prefixes = var.address_prefixes + name = var.name + resource_group_name = var.resource_group_name + virtual_network_name = var.virtual_network_name + + dynamic "delegation" { + for_each = var.delegations != null ? var.delegations : [] + + content { + name = delegation.value.delegation_name + service_delegation { + name = delegation.value.service_name + actions = length(delegation.value.service_actions) == 0 ? null : delegation.value.service_actions + } + } + } + + default_outbound_access_enabled = var.default_outbound_access_enabled + service_endpoint_policy_ids = var.service_endpoint_policy_ids + service_endpoints = var.service_endpoints +} + +resource "azurerm_subnet_network_security_group_association" "secgroup_association" { + count = var.network_security_group_id != "" ? 1 : 0 + + depends_on = [azurerm_subnet.this] + + subnet_id = azurerm_subnet.this.id + network_security_group_id = var.network_security_group_id +} diff --git a/may-2025-testing/terraform/modules/azurerm_subnet_composite/outputs.tf.json b/may-2025-testing/terraform/modules/azurerm_subnet_composite/outputs.tf.json new file mode 100644 index 0000000..800503d --- /dev/null +++ b/may-2025-testing/terraform/modules/azurerm_subnet_composite/outputs.tf.json @@ -0,0 +1,9 @@ +{ + "output": { + "id": { + "description": "The unique identifier of the subnet.", + "sensitive": false, + "value": "${azurerm_subnet.this.id}" + } + } +} \ No newline at end of file diff --git a/may-2025-testing/terraform/modules/azurerm_subnet_composite/variables.tf b/may-2025-testing/terraform/modules/azurerm_subnet_composite/variables.tf new file mode 100644 index 0000000..e5cf574 --- /dev/null +++ b/may-2025-testing/terraform/modules/azurerm_subnet_composite/variables.tf @@ -0,0 +1,8 @@ +variable "location" { + type = string + description = "The Azure region." +} +variable "resource_group_name" { + type = string + description = "The name of the resource group." +} \ No newline at end of file diff --git a/may-2025-testing/terraform/modules/azurerm_subnet_composite/variables.tf.json b/may-2025-testing/terraform/modules/azurerm_subnet_composite/variables.tf.json new file mode 100644 index 0000000..7b6b096 --- /dev/null +++ b/may-2025-testing/terraform/modules/azurerm_subnet_composite/variables.tf.json @@ -0,0 +1,61 @@ +{ + "variable": { + "address_prefixes": [ + { + "description": "List of address prefixes for the subnet.", + "nullable": false, + "type": "list(string)" + } + ], + "default_outbound_access_enabled": [ + { + "description": "Indicates if default outbound access is enabled.", + "nullable": true, + "type": "bool" + } + ], + "name": [ + { + "description": "Name of the subnet.", + "nullable": false, + "type": "string" + } + ], + "service_endpoint_policy_ids": [ + { + "description": "Set of service endpoint policy IDs.", + "nullable": true, + "type": "list(string)" + } + ], + "service_endpoints": [ + { + "description": "Set of service endpoints for the subnet.", + "nullable": true, + "type": "list(string)" + } + ], + "virtual_network_name": [ + { + "description": "Name of the virtual network.", + "nullable": false, + "type": "string" + } + ], + "network_security_group_id": [ + { + "type": "string", + "description": "The ID of the Network Security Group which should be associated with the Subnet.", + "nullable": true, + "default": "" + } + ], + "delegations": [ + { + "type": "list(object({delegation_name: string, service_name: string, service_actions: list(string)}))", + "description": "Delegate actions to services.", + "nullable": true + } + ] + } +} \ No newline at end of file diff --git a/may-2025-testing/terraform/modules/azurerm_vn/azurerm_vn.tf b/may-2025-testing/terraform/modules/azurerm_vn/azurerm_vn.tf new file mode 100644 index 0000000..2efa995 --- /dev/null +++ b/may-2025-testing/terraform/modules/azurerm_vn/azurerm_vn.tf @@ -0,0 +1,31 @@ +locals { + use_ddos_protection = var.ddos_protection_name != "" +} + +resource "azurerm_network_ddos_protection_plan" "ddos_protection" { + count = local.use_ddos_protection ? 1 : 0 + + name = var.ddos_protection_name + location = var.location + resource_group_name = var.resource_group_name +} + +resource "azurerm_virtual_network" "this" { + address_space = var.address_space + location = var.location + name = var.name + resource_group_name = var.resource_group_name + edge_zone = var.edge_zone + flow_timeout_in_minutes = var.flow_timeout_in_minutes + tags = var.tags + dns_servers = var.dns_servers + + dynamic "ddos_protection_plan" { + for_each = local.use_ddos_protection ? [1] : [] + + content { + id = azurerm_network_ddos_protection_plan.ddos_protection.id + enable = true + } + } +} diff --git a/may-2025-testing/terraform/modules/azurerm_vn/outputs.tf.json b/may-2025-testing/terraform/modules/azurerm_vn/outputs.tf.json new file mode 100644 index 0000000..3aee815 --- /dev/null +++ b/may-2025-testing/terraform/modules/azurerm_vn/outputs.tf.json @@ -0,0 +1,19 @@ +{ + "output": { + "guid": { + "description": "Unique GUID of the virtual network.", + "sensitive": false, + "value": "${azurerm_virtual_network.this.guid}" + }, + "id": { + "description": "Resource ID of the virtual network.", + "sensitive": false, + "value": "${azurerm_virtual_network.this.id}" + }, + "name": { + "description": "Name of the virtual network.", + "sensitive": false, + "value": "${azurerm_virtual_network.this.name}" + } + } +} \ No newline at end of file diff --git a/may-2025-testing/terraform/modules/azurerm_vn/variables.tf b/may-2025-testing/terraform/modules/azurerm_vn/variables.tf new file mode 100644 index 0000000..e5cf574 --- /dev/null +++ b/may-2025-testing/terraform/modules/azurerm_vn/variables.tf @@ -0,0 +1,8 @@ +variable "location" { + type = string + description = "The Azure region." +} +variable "resource_group_name" { + type = string + description = "The name of the resource group." +} \ No newline at end of file diff --git a/may-2025-testing/terraform/modules/azurerm_vn/variables.tf.json b/may-2025-testing/terraform/modules/azurerm_vn/variables.tf.json new file mode 100644 index 0000000..94af50c --- /dev/null +++ b/may-2025-testing/terraform/modules/azurerm_vn/variables.tf.json @@ -0,0 +1,54 @@ +{ + "variable": { + "address_space": [ + { + "description": "The address space that is used by the virtual network.", + "nullable": false, + "type": "list(string)" + } + ], + "edge_zone": [ + { + "description": "The edge zone where the virtual network is located.", + "nullable": true, + "type": "string" + } + ], + "flow_timeout_in_minutes": [ + { + "description": "The flow timeout duration in minutes for the network.", + "nullable": true, + "type": "number" + } + ], + "name": [ + { + "description": "The name of the virtual network.", + "nullable": false, + "type": "string" + } + ], + "tags": [ + { + "description": "A map of tags to assign to the virtual network.", + "nullable": true, + "type": "map(string)" + } + ], + "dns_servers": [ + { + "type": "list(string)", + "description": "List of IP addresses of DNS servers", + "nullable": true + } + ], + "ddos_protection_name": [ + { + "type": "string", + "description": "Specifies the name of the Network DDoS Protection Plan. If no name is given, DDoS Protection Plan is not used", + "nullable": true, + "default": "" + } + ] + } +} \ No newline at end of file diff --git a/may-2025-testing/terraform/outputs.tf b/may-2025-testing/terraform/outputs.tf new file mode 100644 index 0000000..c005c0f --- /dev/null +++ b/may-2025-testing/terraform/outputs.tf @@ -0,0 +1,25 @@ +output "azurerm_subnet_composite_stackgen_5f506321-272e-414e-99f6-fd4a254c0bb7_id" { + value = module.stackgen_5f506321-272e-414e-99f6-fd4a254c0bb7.id + sensitive = false +} + +output "azurerm_subnet_composite_stackgen_d1e95b01-4f45-4753-9e48-dc6be963e22f_id" { + value = module.stackgen_d1e95b01-4f45-4753-9e48-dc6be963e22f.id + sensitive = false +} + +output "azurerm_vn_stackgen_fd99e64e-3b93-4921-a0a3-0f145a636d34_guid" { + value = module.stackgen_fd99e64e-3b93-4921-a0a3-0f145a636d34.guid + sensitive = false +} + +output "azurerm_vn_stackgen_fd99e64e-3b93-4921-a0a3-0f145a636d34_id" { + value = module.stackgen_fd99e64e-3b93-4921-a0a3-0f145a636d34.id + sensitive = false +} + +output "azurerm_vn_stackgen_fd99e64e-3b93-4921-a0a3-0f145a636d34_name" { + value = module.stackgen_fd99e64e-3b93-4921-a0a3-0f145a636d34.name + sensitive = false +} + diff --git a/may-2025-testing/terraform/provider.tf b/may-2025-testing/terraform/provider.tf new file mode 100644 index 0000000..d79e2b9 --- /dev/null +++ b/may-2025-testing/terraform/provider.tf @@ -0,0 +1,42 @@ +terraform { + required_version = ">= 1.0.0, < 2.0.0" + + required_providers { + azurerm = { + source = "hashicorp/azurerm" + version = "~> 3.9" // 3.9.0+ required for synapse workspace bugfix + } + + azuread = { // Azure Active Directory + source = "hashicorp/azuread" + version = "~> 3.1.0" + } + + azurestack = { // Azure Stack + source = "hashicorp/azurestack" + version = ">= 0.10.0" + } + } +} + +provider "azurerm" { + features {} + subscription_id = var.subscription_id +} + +resource "azurerm_resource_group" "this" { + count = var.create_resource_group ? 1 : 0 + location = var.location + name = var.resource_group_name +} + +locals { + resource_group_name = var.create_resource_group ? azurerm_resource_group.this[0].name : var.resource_group_name +} + +provider "azuread" {} + +provider "azurestack" { + features {} + subscription_id = var.subscription_id +} diff --git a/may-2025-testing/terraform/variables.tf b/may-2025-testing/terraform/variables.tf new file mode 100644 index 0000000..097cc6e --- /dev/null +++ b/may-2025-testing/terraform/variables.tf @@ -0,0 +1,16 @@ +variable "subscription_id" { + type = string + description = "The Azure subscription ID." +} +variable "create_resource_group" { + type = bool + description = "Specify if you want to create a resource group. Accepted values are true or false." +} +variable "location" { + type = string + description = "The Azure region where the resource group should get created. e.g. East US, West US 2, Central US, etc." +} +variable "resource_group_name" { + type = string + description = "The name of the resource group that would be used, it will be created if 'create_resource_group' is set as true." +}