diff --git a/.gitignore b/.gitignore index 842d58d..2cba585 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,7 @@ # Local configs terraform.tfvars -*.override.tf \ No newline at end of file +*.override.tf + +.env +secrets.sh \ No newline at end of file diff --git a/environments/dev/backend.tf b/environments/dev/backend.tf index 0117784..e69de29 100644 --- a/environments/dev/backend.tf +++ b/environments/dev/backend.tf @@ -1,8 +0,0 @@ -terraform { - backend "azurerm" { - resource_group_name = "terraform" - storage_account_name = "tfstoracccom" - container_name = "tfstate" - key = "dev.terraform.tfstate" - } -} diff --git a/environments/dev/main.tf b/environments/dev/main.tf index 6991732..aa74af6 100644 --- a/environments/dev/main.tf +++ b/environments/dev/main.tf @@ -2,35 +2,32 @@ terraform { required_providers { azurerm = { source = "hashicorp/azurerm" - version = "4.46.0" + version = "4.52.0" } } } provider "azurerm" { features{} - subscription_id = "4b2d6154-f4c5-4854-be82-12dfc82d4d23" + subscription_id = "0c8b6184-985d-4f31-b57e-c91f921241bd" } -module "network" { - source = "../../modules/network" - vnet_name = "dev-vnet" - resource_group_name = "terraform" - location = "UK South" - address_space = ["10.0.0.0/16"] - subnets = { public = "10.0.1.0/24", private = "10.0.2.0/24" } - environment = "dev" - project = "TerraformBootcamp" +resource "azurerm_resource_group" "rg" { + name = "terraform_demo" + location = "uksouth" } -data "azurerm_ssh_public_key" "kp" { - name = "terraform-kp" - resource_group_name = "terraform" +resource "azurerm_storage_account" "storage" { + name = "demoterraformbuildjp" + resource_group_name = azurerm_resource_group.rg.name + location = azurerm_resource_group.rg.location + account_tier = "Standard" + account_replication_type = "LRS" } -data "azurerm_ssh_public_key" "sd" { - name = "sbcomsam-d-01" - resource_group_name = "terraform" +resource "azurerm_storage_container" "terraform_state" { + name = "terraform-state" + storage_account_id = azurerm_storage_account.storage.id } data "http" "my_ip" { @@ -39,15 +36,27 @@ data "http" "my_ip" { locals { my_ip = chomp(data.http.my_ip.response_body) + ssh_public_key = file("~/.ssh/id_rsa.pub") +} + +module "network" { + source = "../../modules/network" + vnet_name = "dev-vnet" + resource_group_name = "terraform_demo" + location = "UK South" + address_space = ["10.0.0.0/16"] + subnets = { public = "10.0.1.0/24", private = "10.0.2.0/24" } + environment = "dev" + project = "TerraformBootcamp" } module "compute" { source = "../../modules/compute" - resource_group_name = "terraform" + resource_group_name = "terraform_demo" location = "UK South" subnet_id = module.network.subnet_ids["public"] vm_size = "Standard_B1s" - admin_username = "azureuser" - ssh_public_key = data.azurerm_ssh_public_key.sd.public_key + admin_username = "demo" + ssh_public_key = local.ssh_public_key ex_ip = local.my_ip -} +} \ No newline at end of file diff --git a/environments/prod/backend.tf b/environments/prod/backend.tf deleted file mode 100644 index e69de29..0000000 diff --git a/environments/prod/main.tf b/environments/prod/main.tf deleted file mode 100644 index e69de29..0000000 diff --git a/environments/prod/outputs.tf b/environments/prod/outputs.tf deleted file mode 100644 index e69de29..0000000 diff --git a/environments/prod/variables.tf b/environments/prod/variables.tf deleted file mode 100644 index e69de29..0000000 diff --git a/modules/compute/main.tf b/modules/compute/main.tf index 52a53f1..a6c34d7 100644 --- a/modules/compute/main.tf +++ b/modules/compute/main.tf @@ -59,9 +59,9 @@ resource "azurerm_linux_virtual_machine" "vm" { storage_account_type = "Standard_LRS" } source_image_reference { + offer = "ubuntu-24_04-lts" publisher = "Canonical" - offer = "0001-com-ubuntu-server-jammy" - sku = "22_04-lts-gen2" + sku = "server" version = "latest" } }