From 4d3ba1690cfe9e92ccc9e5a60a5c4c11bab092f0 Mon Sep 17 00:00:00 2001 From: Joseph Kanzaveli Date: Tue, 25 Jul 2023 17:10:58 +0300 Subject: [PATCH] README --- README.md | 9 +- terraform/tf-ex1/IaC/instances.tf | 5 +- terraform/tf-ex1/IaC/main.tf | 15 +- terraform/tf-ex1/README.md | 28 ++-- terraform/tf-ex1/diagram.drawio.svg | 231 ++++++++++------------------ 5 files changed, 119 insertions(+), 169 deletions(-) diff --git a/README.md b/README.md index cc1768b..e9d2f66 100644 --- a/README.md +++ b/README.md @@ -93,13 +93,14 @@ 4. [Simple Terraform lab](https://github.com/Joska99/joska/blob/main/terraform/tf-ex1) +

- +

## Terraform-Modules - + 1. [Azure AKS with LogAnalytics and ACR module](https://github.com/Joska99/joska/blob/main/terraform/modules/tf-aks-la) - + 2. [Azure Linux VM module](https://github.com/Joska99/joska/blob/main/terraform/modules/tf-linux-vm) - + 3. [Azure WAN Hub module](https://github.com/Joska99/joska/blob/main/terraform/modules/tf-wan-hub) \ No newline at end of file diff --git a/terraform/tf-ex1/IaC/instances.tf b/terraform/tf-ex1/IaC/instances.tf index 24b1e41..775cb2f 100644 --- a/terraform/tf-ex1/IaC/instances.tf +++ b/terraform/tf-ex1/IaC/instances.tf @@ -1,7 +1,6 @@ -############################################################################################################################################################################################################################################ +###################################################################################################################### ### INSTANCES -############################################################################################################################################################################################################################################ - +###################################################################################################################### ###################################################################################################################### ### VMS FOR PUBLIC SUBNET AND ANOTHER ###################################################################################################################### diff --git a/terraform/tf-ex1/IaC/main.tf b/terraform/tf-ex1/IaC/main.tf index 025546b..4602be6 100644 --- a/terraform/tf-ex1/IaC/main.tf +++ b/terraform/tf-ex1/IaC/main.tf @@ -6,6 +6,15 @@ terraform { version = "3.45.0" } } + ######################################### + # BACKEND FOR .TFSTATE AND LINUXKEY.PEM + ######################################### + # backend "azurerm" { + # resource_group_name = var.rg_name + # storage_account_name = var.sa_name + # container_name = var.con_name + # key = "terraform.tfstate" + # } } ## config provider @@ -25,9 +34,9 @@ resource "azurerm_postgresql_server" "serv" { location = azurerm_resource_group.rg.location resource_group_name = azurerm_resource_group.rg.name - sku_name = "B_Gen5_2" - storage_mb = 5120 - backup_retention_days = 7 + sku_name = "B_Gen5_2" + storage_mb = 5120 + backup_retention_days = 7 administrator_login = var.login-passwd-for-vm[0] diff --git a/terraform/tf-ex1/README.md b/terraform/tf-ex1/README.md index 5b498e7..bcf79de 100644 --- a/terraform/tf-ex1/README.md +++ b/terraform/tf-ex1/README.md @@ -1,4 +1,4 @@ -

Simple Terraform lab

+

Terraform lab, simple network

@@ -11,6 +11,9 @@ az login ``` 2. Move to "IaC" folder and init Terraform: ```bash +cd IaC +``` +```bash terraform init ``` 3. Check terraform module and output plan: @@ -22,39 +25,38 @@ terraform plan -out main.tfplan terraform apply main.tfplan ``` -

Create Storage Account in azure by CLI to store .tfstate

+

Create Storage Account in Azure by CLI to store .tfstate

1. Create variables ```bash -RG_NAME=aks-rg -SA_NAME=sa4tstfstate -CONTAINER_NAME=tf-state +RG_NAME="resource-groups-name" +SA_NAME="storage-account-name" +CONTAINER_NAME="sa-container-name" ``` - -2. Create Storage Account +2. Create Storage Account, in Azure CLI run those commands: ```bash az storage account create --resource-group $RG_NAME --name $SA_NAME --sku Standard_LRS --encryption-services blob ``` -3. Create BLOB Container +3. Create BLOB Container: ```bash az storage container create --name $CONTAINER_NAME --account-name $SA_NAME ``` -4. Get key +4. Get key: ```bash ACCOUNT_KEY=$(az storage account keys list --resource-group aks-rg --account-name $SA_NAME --query '[0].value' -o tsv) ``` -5. Add it to ARM +5. Add it to ARM: ```bash $env:ARM_ACCESS_KEY=$ACCOUNT_KEY ``` -6. Init changes and say yes +6. Init changes and say yes : ```bash terraform init ```

To delete

-1. Run this command to destroy and add yes +1. Run this command to destroy ```bash -terraform destroy +terraform destroy --auto-approve ``` \ No newline at end of file diff --git a/terraform/tf-ex1/diagram.drawio.svg b/terraform/tf-ex1/diagram.drawio.svg index aa7bfff..1d20a3c 100644 --- a/terraform/tf-ex1/diagram.drawio.svg +++ b/terraform/tf-ex1/diagram.drawio.svg @@ -1,96 +1,61 @@ - - - - - - - + + - - - - - - - - - - - - - - + + + + + + -
+
-
- - 8080 - -
-
-
- - - 8080 - - - - - - -
-
-
- - 8080 +
+ + + Peering +
- - 8080 + + Peering + + + + -
+
- 8080 + + NSG +
- - 8080 + + NSG - - - - - - - - - - - - - + -
+
@@ -102,7 +67,7 @@
- + VNet @@ -110,112 +75,87 @@ -
+
-
- - NSG - -
-
-
- - - NSG - - - - - - -
-
- Public Load-Balancer - - -
-
-
-
- - Public Load-Balancer - -
-
- - - -
-
-
- - - public subnet + subnet
- - public subnet + + subnet
+ + + + + -
+
-
- - - private subnet - +
+ + NSG
- - private subnet + + NSG + + + + + + -
+
- + NSG
- + NSG - - - - - - - - - + + + + + + + + + + + + + -
+
@@ -227,7 +167,7 @@
- + VNet @@ -235,65 +175,64 @@ -
-
+
+
- - subnet + + Public Load-Balancer
- - subnet + + Public Load-Balancer -
+
- NSG + public subnet
- - NSG + + public subnet - - -
+
- - - Peering + + + private subnet
- - Peering + + private subnet +