Skip to content

Commit c643903

Browse files
inclusao do terraform
1 parent 4d63dfe commit c643903

File tree

4 files changed

+99
-0
lines changed

4 files changed

+99
-0
lines changed

terraform/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
#### Como usar o Terraform: [Documentação](https://www.terraform.io/cli)
3+
4+
## Inicialize o Terraform:
5+
6+
'''
7+
terraform init
8+
'''
9+
10+
## Verifique se o código é Valido:
11+
12+
'''
13+
terraform plan
14+
'''
15+
16+
## Aplique:
17+
18+
terraform apply -auto-approve

terraform/main.tf

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
terraform {
2+
required_version = ">= 1.5.0"
3+
4+
required_providers {
5+
azurerm = {
6+
source = "hashicorp/azurerm"
7+
version = "~> 4.0"
8+
}
9+
}
10+
}
11+
12+
provider "azurerm" {
13+
features {}
14+
}
15+
16+
# -------------------------
17+
# Resource Group
18+
# -------------------------
19+
resource "azurerm_resource_group" "rg" {
20+
name = var.resource_group_name
21+
location = var.location
22+
}
23+
24+
# -------------------------
25+
# App Service Plan (Linux)
26+
# -------------------------
27+
resource "azurerm_service_plan" "plan" {
28+
name = "${var.app_name}-plan"
29+
resource_group_name = azurerm_resource_group.rg.name
30+
location = azurerm_resource_group.rg.location
31+
os_type = "Linux"
32+
sku_name = "B1" # Básico e barato
33+
}
34+
35+
# -------------------------
36+
# Web App (Python)
37+
# -------------------------
38+
resource "azurerm_linux_web_app" "webapp" {
39+
name = var.app_name
40+
resource_group_name = azurerm_resource_group.rg.name
41+
location = azurerm_resource_group.rg.location
42+
service_plan_id = azurerm_service_plan.plan.id
43+
44+
site_config {
45+
application_stack {
46+
python_version = "3.11"
47+
}
48+
}
49+
50+
app_settings = {
51+
"WEBSITE_RUN_FROM_PACKAGE" = "1"
52+
}
53+
}
54+
55+
# -------------------------
56+
# Output
57+
# -------------------------
58+
output "webapp_url" {
59+
value = azurerm_linux_web_app.webapp.default_hostname
60+
}

terraform/outputs.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
output "webapp_url" {
2+
description = "URL pública da aplicação"
3+
value = "https://${azurerm_linux_web_app.webapp.default_hostname}"
4+
}

terraform/variables.tf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
variable "resource_group_name" {
2+
description = "Nome do Resource Group"
3+
type = string
4+
default = "rg-python-app"
5+
}
6+
7+
variable "location" {
8+
description = "Região do Azure"
9+
type = string
10+
default = "eastus"
11+
}
12+
13+
variable "app_name" {
14+
description = "Nome do Web App"
15+
type = string
16+
default = "python-webapp-demo"
17+
}

0 commit comments

Comments
 (0)