File tree Expand file tree Collapse file tree 4 files changed +99
-0
lines changed Expand file tree Collapse file tree 4 files changed +99
-0
lines changed Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 1+ output "webapp_url" {
2+ description = " URL pública da aplicação"
3+ value = " https://${ azurerm_linux_web_app . webapp . default_hostname } "
4+ }
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments