Skip to content

Commit 4012198

Browse files
Merge pull request #15 from platzi/amines/14
Infraestructura agregada
2 parents 7700d3d + ff3d8b4 commit 4012198

File tree

6 files changed

+88
-8
lines changed

6 files changed

+88
-8
lines changed

.gitignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ obj/
77

88
# Archivos de comiplación de Terraform
99
*.tfstate
10-
/.terraform
10+
.terraform
1111
*.tfstate.*
12-
*.tfvars
12+
*.tfvars
13+
*.out
14+
*.lock.hcl

docs/clase12.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ variable "container_app_env_name" {
5858
}
5959
```
6060

61-
Y por último:
61+
Y por último **main.tf**.
6262

6363
```terraform
6464
resource "random_pet" "rg_name" {
@@ -70,12 +70,12 @@ resource "azurerm_resource_group" "rg" {
7070
location = var.resource_group_location
7171
}
7272
73-
resource "azurerm_container_registry" "acr" {
74-
name = var.acr_name
75-
resource_group_name = azurerm_resource_group.rg.name
73+
resource "azurerm_application_insights" "app_insights" {
74+
name = "${var.resource_group_name_prefix}-ai"
7675
location = azurerm_resource_group.rg.location
77-
sku = "Standard"
78-
admin_enabled = true
76+
resource_group_name = azurerm_resource_group.rg.name
77+
application_type = "web"
78+
workspace_id = azurerm_log_analytics_workspace.log_analytics.id
7979
}
8080
8181
resource "azurerm_log_analytics_workspace" "log_analytics" {

infra/backend.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
terraform {
2+
backend "azurerm" {
3+
storage_account_name = "generalstorageamin"
4+
container_name = "tfstate"
5+
key = "devops.tfstate"
6+
}
7+
}

infra/main.tf

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
resource "random_pet" "rg_name" {
2+
prefix = var.resource_group_name_prefix
3+
}
4+
5+
resource "azurerm_resource_group" "rg" {
6+
name = random_pet.rg_name.id
7+
location = var.resource_group_location
8+
}
9+
10+
resource "azurerm_application_insights" "app_insights" {
11+
name = "${var.resource_group_name_prefix}-ai"
12+
location = azurerm_resource_group.rg.location
13+
resource_group_name = azurerm_resource_group.rg.name
14+
application_type = "web"
15+
workspace_id = azurerm_log_analytics_workspace.log_analytics.id
16+
}
17+
18+
resource "azurerm_log_analytics_workspace" "log_analytics" {
19+
name = "${var.resource_group_name_prefix}-law"
20+
location = azurerm_resource_group.rg.location
21+
resource_group_name = azurerm_resource_group.rg.name
22+
sku = "PerGB2018"
23+
retention_in_days = 30
24+
25+
identity {
26+
type = "SystemAssigned"
27+
}
28+
}
29+
30+
resource "azurerm_container_app_environment" "apps_environment" {
31+
name = var.container_app_env_name
32+
location = azurerm_resource_group.rg.location
33+
resource_group_name = azurerm_resource_group.rg.name
34+
log_analytics_workspace_id = azurerm_log_analytics_workspace.log_analytics.id
35+
}

infra/provider.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
terraform {
2+
required_version = ">=1.0"
3+
required_providers {
4+
azurerm = {
5+
source = "hashicorp/azurerm"
6+
version = "~>3.0"
7+
}
8+
}
9+
}
10+
provider "azurerm" {
11+
features {}
12+
subscription_id = "30a83aff-7a8b-4ca3-aa48-ab93268b5a8b"
13+
}

infra/variables.tf

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
variable "resource_group_name_prefix" {
2+
description = "Prefix for the resource group name"
3+
type = string
4+
default = "rg-"
5+
}
6+
7+
variable "resource_group_location" {
8+
description = "Location for the resource group"
9+
type = string
10+
default = "East US 2"
11+
}
12+
13+
variable "acr_name" {
14+
description = "Name of the Azure Container Registry"
15+
type = string
16+
default = "acrdevopsamin"
17+
}
18+
19+
variable "container_app_env_name" {
20+
description = "Name of the Azure Container App Environment"
21+
type = string
22+
default = "devops-env"
23+
}

0 commit comments

Comments
 (0)