Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

organize codes directory sturcture #5

Merged
merged 1 commit into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
}