Skip to content

Commit

Permalink
Organize codes sturcture and enable services
Browse files Browse the repository at this point in the history
Signed-off-by: karim mdmirajul <karim.mdmirajul@unikie.com>
  • Loading branch information
karim20230 committed Nov 2, 2023
1 parent d55ed4b commit 31b01ce
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 34 deletions.
67 changes: 33 additions & 34 deletions terraform/azure-ghaf-infra.tf
Original file line number Diff line number Diff line change
@@ -1,47 +1,46 @@
# SPDX-FileCopyrightText: 2023 Technology Innovation Institute (TII)
#
# SPDX-License-Identifier: Apache-2.0
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
}
sops = {
source = "carlpett/sops"
}
}
}

data "sops_file" "ghaf-infra" {
source_file = "secrets.yaml"
# Resource group
resource "azurerm_resource_group" "rg" {
name = "ghaf-infra-terraform-dev"
location = var.resource_group_location
}

provider "azurerm" {
features {}
# Create VN
resource "azurerm_virtual_network" "ghaf-infra-vnet" {
name = "ghaf-infra-terraform-dev-vnet"
address_space = ["10.3.0.0/24"]
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name
}


# Backend for storing tfstate

terraform {
backend "azurerm" {
resource_group_name = "ghaf-infra-storage"
storage_account_name = "ghafinfrastatestorage"
container_name = "ghaf-infra-tfstate-container"
key = "ghaf-infra.tfstate"
}
# Create public IPs
resource "azurerm_public_ip" "ghafhydra_terraform_public_ip" {
name = "ghaf-infra-terraform-dev-ip"
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name
allocation_method = "Dynamic"
}


# Resource group

variable "resource_group_location" {
type = string
default = "northeurope"
description = "Location of the resource group."
# Create Network SG and rule
resource "azurerm_network_security_group" "ghafhydra_terraform_nsg" {
name = "ghaf-infra-terraform-dev-nsg"
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name

security_rule {
name = "SSH"
priority = 300
direction = "Inbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "22"
source_address_prefix = "*"
destination_address_prefix = "*"
}
}

resource "azurerm_resource_group" "rg" {
name = "ghaf-infra-terraform-dev"
location = var.resource_group_location
}
13 changes: 13 additions & 0 deletions terraform/backend.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# SPDX-FileCopyrightText: 2023 Technology Innovation Institute (TII)
#
# SPDX-License-Identifier: Apache-2.0


terraform {
backend "azurerm" {
resource_group_name = "ghaf-infra-storage"
storage_account_name = "ghafinfrastatestorage"
container_name = "ghaf-infra-tfstate-container"
key = "ghaf-infra.tfstate"
}
}
7 changes: 7 additions & 0 deletions terraform/data.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# SPDX-FileCopyrightText: 2023 Technology Innovation Institute (TII)
#
# SPDX-License-Identifier: Apache-2.0

data "sops_file" "ghaf-infra" {
source_file = "secrets.yaml"
}
11 changes: 11 additions & 0 deletions terraform/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# SPDX-FileCopyrightText: 2023 Technology Innovation Institute (TII)
#
# SPDX-License-Identifier: Apache-2.0

output "resource_group_name" {
value = azurerm_resource_group.rg.name
}

output "resource_group_location" {
value = azurerm_resource_group.rg.location
}
19 changes: 19 additions & 0 deletions terraform/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# SPDX-FileCopyrightText: 2023 Technology Innovation Institute (TII)
#
# SPDX-License-Identifier: Apache-2.0

provider "azurerm" {
features {}
}

terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
}
sops = {
source = "carlpett/sops"
}
}
}

31 changes: 31 additions & 0 deletions terraform/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# SPDX-FileCopyrightText: 2023 Technology Innovation Institute (TII)
#
# SPDX-License-Identifier: Apache-2.0

variable "resource_group_location" {
type = string
default = "swedencentral"
description = "Location of the resource group."
}


variable "resourcegroup" {
description = "The Azure Resource Group Name within your Subscription in which this resource will be created."
default = "ghaf-infra-swe"
}

variable "resource_group_name_prefix" {
type = string
default = "rg"
description = "Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription."
}

variable "location" {
description = "Location for resources"
default = "eastus"
}

variable "subnet_address_prefix" {
description = "Address prefix for subnet"
default = "10.0.1.0/24"
}

0 comments on commit 31b01ce

Please sign in to comment.