Skip to content

Commit

Permalink
feat: Reflects is-state of resource group
Browse files Browse the repository at this point in the history
  • Loading branch information
ViMaSter committed Mar 10, 2024
1 parent 1a805ac commit 5b06ebe
Show file tree
Hide file tree
Showing 13 changed files with 432 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Local .terraform directories
**/.terraform/*

# .tfstate files
*.tfstate
*.tfstate.*

# Crash log files
crash.log
crash.*.log

# Exclude all .tfvars files, which are likely to contain sensitive data, such as
# password, private keys, and other secrets. These should not be part of version
# control as they are data points which are potentially sensitive and subject
# to change depending on the environment.
*.tfvars
*.tfvars.json

# 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

# 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

# rover
.cache
plan.json
plan.out
22 changes: 22 additions & 0 deletions .terraform.lock.hcl

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

17 changes: 17 additions & 0 deletions application_insights/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
resource "azurerm_log_analytics_workspace" "ws_sl_prod" {
name = "ws-sl-prod"
location = var.resource_group.location
resource_group_name = var.resource_group.name
sku = "PerGB2018"
retention_in_days = 30
}

resource "azurerm_application_insights" "ai_sl_prod" {
name = "ai-sl-prod"
location = var.resource_group.location
resource_group_name = var.resource_group.name
application_type = "web"
sampling_percentage = 0
workspace_id = azurerm_log_analytics_workspace.ws_sl_prod.id
}

3 changes: 3 additions & 0 deletions application_insights/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
output "connection_string" {
value = azurerm_application_insights.ai_sl_prod.connection_string
}
6 changes: 6 additions & 0 deletions application_insights/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
variable "resource_group" {
type = object({
name = string
location = string
})
}
58 changes: 58 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "=3.95.0"
}
}
required_version = "1.7.4"
}

provider "azurerm" {
features {}
}

resource "azurerm_resource_group" "rg_sl_prod" {
name = "rg-sl-prod"
location = "West US"
}

locals {
vincent_mahnke = {
full_name = "Vincent Mahnke"
initials = join("", [for x in split(" ", "Vincent Mahnke") : lower(substr(x, 0, 1))])
tenant_id = "41eb501a-f671-4ce0-a5bf-b64168c3705f"
object_id = "7dac8181-b972-4612-8738-094828b1a3ff"
phone_country_code = "49"
phone_number = "1721358162"
email_address = "[email protected]"
}
top_level_domain = "studio-lovelies.com"
}

module "application_insights" {
source = "./application_insights"
resource_group = azurerm_resource_group.rg_sl_prod
}

module "website" {
source = "./website"
top_level_domain = local.top_level_domain
resource_group = azurerm_resource_group.rg_sl_prod
alerted_user = local.vincent_mahnke
application_insights_connection_string = module.application_insights.connection_string
secrets = {
discord_webhook_url = var.discord_webhook_url
smtp_host = var.smtp_host
smtp_port = var.smtp_port
smtp_username = var.smtp_username
smtp_password = var.smtp_password
smtp_from = var.smtp_from
}
}

module "networking" {
source = "./networking"
resource_group = azurerm_resource_group.rg_sl_prod
web_app = module.website.web_app
}
40 changes: 40 additions & 0 deletions networking/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
resource "azurerm_virtual_network" "vnet_sl_prod" {
name = "vnet-sl-prod"
resource_group_name = var.resource_group.name
location = var.resource_group.location
address_space = ["10.0.0.0/16"]
}

resource "azurerm_subnet" "default" {
name = "default"
resource_group_name = var.resource_group.name
virtual_network_name = azurerm_virtual_network.vnet_sl_prod.name
address_prefixes = ["10.0.0.0/24"]
private_endpoint_network_policies_enabled = false
private_link_service_network_policies_enabled = true
}

resource "azurerm_network_interface" "pe_asp_sl_prod_nic" {
name = "pe-asp-sl-prod.nic.a82dcd5a-8c1c-4bbd-b26f-c247c5465560"
location = var.resource_group.location
resource_group_name = var.resource_group.name
ip_configuration {
name = "privateEndpointIpConfig.8ed6cd6c-1552-44e3-a8cc-adfd3138ecb7"
subnet_id = azurerm_subnet.default.id
private_ip_address_allocation = "Dynamic"
}
}

resource "azurerm_private_endpoint" "pe_asp_sl_prod" {
name = "pe-asp-sl-prod"
location = var.resource_group.location
resource_group_name = var.resource_group.name
subnet_id = azurerm_subnet.default.id
private_service_connection {
name = "pe-asp-sl-prod-a995"
private_connection_resource_id = var.web_app.id
subresource_names = ["sites-preview"]
is_manual_connection = false
}
tags = {}
}
Empty file added networking/outputs.tf
Empty file.
12 changes: 12 additions & 0 deletions networking/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
variable "resource_group" {
type = object({
name = string
location = string
})
}

variable "web_app" {
type = object({
id = string
})
}
36 changes: 36 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# DISCORD_WEBHOOK_URL
# SMTP_HOST
# SMTP_PORT
# SMTP_USERNAME
# SMTP_PASSWORD
# SMTP_FROM

variable "discord_webhook_url" {
description = "Discord Webhook URL to call when the contact form is submitted"
type = string
}

variable "smtp_host" {
description = "SMTP host used for contact form entries"
type = string
}

variable "smtp_port" {
description = "SMTP port used for contact form entries"
type = string
}

variable "smtp_username" {
description = "SMTP username used for contact form entries"
type = string
}

variable "smtp_password" {
description = "SMTP password used for contact form entries"
type = string
}

variable "smtp_from" {
description = "SMTP from-address used for contact form entries"
type = string
}
Loading

0 comments on commit 5b06ebe

Please sign in to comment.