From a288a5c29cecb67878781d2ab57ec12155063203 Mon Sep 17 00:00:00 2001 From: Noah Spannbauer Date: Tue, 21 May 2024 14:34:14 -0500 Subject: [PATCH] 7-flying-infrastructure - adding terraform --- infrastructure/.gitignore | 4 ++++ infrastructure/.terraform.lock.hcl | 21 +++++++++++++++++++++ infrastructure/main.tf | 9 +++++++++ infrastructure/outputs.tf | 8 ++++++++ infrastructure/providers.tf | 3 +++ infrastructure/resource_group.tf | 3 +++ infrastructure/storage_account.tf | 7 +++++++ infrastructure/terraform.tf | 18 ++++++++++++++++++ infrastructure/variables.tf | 28 ++++++++++++++++++++++++++++ 9 files changed, 101 insertions(+) create mode 100644 infrastructure/.gitignore create mode 100644 infrastructure/.terraform.lock.hcl create mode 100644 infrastructure/main.tf create mode 100644 infrastructure/outputs.tf create mode 100644 infrastructure/providers.tf create mode 100644 infrastructure/resource_group.tf create mode 100644 infrastructure/storage_account.tf create mode 100644 infrastructure/terraform.tf create mode 100644 infrastructure/variables.tf diff --git a/infrastructure/.gitignore b/infrastructure/.gitignore new file mode 100644 index 0000000..007a994 --- /dev/null +++ b/infrastructure/.gitignore @@ -0,0 +1,4 @@ +# Terraform +.terraform/* +*.tfstate +*.tfstate.* \ No newline at end of file diff --git a/infrastructure/.terraform.lock.hcl b/infrastructure/.terraform.lock.hcl new file mode 100644 index 0000000..28e1a7f --- /dev/null +++ b/infrastructure/.terraform.lock.hcl @@ -0,0 +1,21 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/hashicorp/azurerm" { + version = "3.104.2" + hashes = [ + "h1:1J+ajk1s1qfjViKYSOYDb8HLOh2RIn/TAK/2s3orPuE=", + "zh:05b4a3572ce2b881fef5ec64756b060e8ce6c24c260182acf4adec38a6b29204", + "zh:0d5118f6ad64278a52b720cdbf1a6b7ab7ea1ad5bd3d9607cb558d8d25280906", + "zh:2196f49d73bf862a046b24e143f5d658bbb01bfb4e8582a88eb3907ff4f69730", + "zh:285c1a65bf3b70859110c2bbafefa4483d450840282a57f349b81b17367bbb26", + "zh:2efbd00970952761d60043c41e983dc6930678ef179de2b27ed00437fa711703", + "zh:6b7e26e6ba3a639e2a26b2e64f4629e28a44a9572f4203c30cb1c611f37ddb21", + "zh:8149b7aada49cac3ef49d7595d2fc2e3a573f4c01d272a6a4111efa089f2e44f", + "zh:9674f741d7be268778a0f0a59174130800f8977747ef16a1dd6446031c7ae8d4", + "zh:aed0e78df3c5de8eaa8c8cacb4e3c48ec26683f2e35dd42eabc1242592fad247", + "zh:c0c97188d9a5a26c5ce2dbcc1c6b31fb73469bb2e422e64a1dda25c9355c341c", + "zh:e883eca472593e34f2f93282973c148114eab19fceb8348fc82e91293b247118", + "zh:f569b65999264a9416862bca5cd2a6177d94ccb0424f3a4ef424428912b9cb3c", + ] +} diff --git a/infrastructure/main.tf b/infrastructure/main.tf new file mode 100644 index 0000000..1e4b366 --- /dev/null +++ b/infrastructure/main.tf @@ -0,0 +1,9 @@ +module "static_web_app" { + source = "github.com/noahspannbauer/noahspan-root/infrastructure/modules/static_web_app" + region = var.REGION + resource_group_name = data.azurerm_resource_group.resource_group.name + static_web_app_name = var.STATIC_WEB_APP_NAME + custom_domain_name_count = var.CUSTOM_DOMAIN_NAME_COUNT + domain_name = var.DOMAIN_NAME + subdomain_name = var.SUBDOMAIN_NAME +} \ No newline at end of file diff --git a/infrastructure/outputs.tf b/infrastructure/outputs.tf new file mode 100644 index 0000000..c433ec7 --- /dev/null +++ b/infrastructure/outputs.tf @@ -0,0 +1,8 @@ +output "api_key" { + value = module.static_web_app.api_key + sensitive = true +} + +output "default_host_name" { + value = module.static_web_app.default_host_name +} \ No newline at end of file diff --git a/infrastructure/providers.tf b/infrastructure/providers.tf new file mode 100644 index 0000000..615cb43 --- /dev/null +++ b/infrastructure/providers.tf @@ -0,0 +1,3 @@ +provider "azurerm" { + features {} +} \ No newline at end of file diff --git a/infrastructure/resource_group.tf b/infrastructure/resource_group.tf new file mode 100644 index 0000000..cbaf81a --- /dev/null +++ b/infrastructure/resource_group.tf @@ -0,0 +1,3 @@ +data "azurerm_resource_group" "resource_group" { + name = var.RESOURCE_GROUP_NAME +} \ No newline at end of file diff --git a/infrastructure/storage_account.tf b/infrastructure/storage_account.tf new file mode 100644 index 0000000..d526d9f --- /dev/null +++ b/infrastructure/storage_account.tf @@ -0,0 +1,7 @@ +resource "azurerm_storage_account" "storage_account" { + name = var.STORAGE_ACCOUNT_NAME + resource_group_name = data.azurerm_resource_group.resource_group.name + location = data.azurerm_resource_group.resource_group.location + account_tier = "Standard" + account_replication_type = "GRS" +} \ No newline at end of file diff --git a/infrastructure/terraform.tf b/infrastructure/terraform.tf new file mode 100644 index 0000000..280ee79 --- /dev/null +++ b/infrastructure/terraform.tf @@ -0,0 +1,18 @@ +terraform { + required_version = ">= 1.1.0" + + required_providers { + azurerm = { + source = "hashicorp/azurerm" + } + } + + backend "remote" { + hostname = "app.terraform.io" + organization = "noahspan" + + workspaces { + prefix = "noahspan-" + } + } +} \ No newline at end of file diff --git a/infrastructure/variables.tf b/infrastructure/variables.tf new file mode 100644 index 0000000..51039da --- /dev/null +++ b/infrastructure/variables.tf @@ -0,0 +1,28 @@ +variable "REGION" { + type = string +} + +variable "RESOURCE_GROUP_NAME" { + type = string +} + +variable "STATIC_WEB_APP_NAME" { + type = string +} + +variable "DOMAIN_NAME" { + type = string +} + +variable "SUBDOMAIN_NAME" { + type = string +} + +variable "CUSTOM_DOMAIN_NAME_COUNT" { + type = number +} + +variable "STORAGE_ACCOUNT_NAME" { + type = string +} +