Publicar Terraform modelos
Publique o. Terraform modelo definido pela aplicação em GitHub para habilitar o controle de versão, a colaboração e o armazenamento centralizado.
Antes de Iniciar
Função necessária: administrador do Terraform
Procedimento
- Crie um GitHub repositório dedicado ao seu Terraform modelos.
-
Salve os seguintes códigos em um arquivo separado.
- Nome do arquivo: Awsaccount.tf
terraform { required_providers { aws = { source = "hashicorp/aws" version = "~>5.0" } } } provider "aws" { region = var.region } resource "aws_organizations_account" "account" { email = var.root_email name = var.account_name tags = var.tags parent_id = var.parent_id close_on_deletion=var.close_delete create_govcloud=var.gov_cloud } resource "aws_budgets_budget" "cost" { name = join("-", ["SN-CAM-Monthly-Budget", aws_organizations_account.account.id]) count = var.monthly_budget > 0 ? 1 : 0 budget_type = "COST" limit_amount = var.monthly_budget limit_unit = "USD" time_unit = "MONTHLY" cost_filter { name = "LinkedAccount" values = [ aws_organizations_account.account.id ] } notification { comparison_operator = "GREATER_THAN" threshold = 100 threshold_type = "PERCENTAGE" notification_type = "FORECASTED" subscriber_email_addresses = [var.root_email, var.notification_email] } notification { comparison_operator = "GREATER_THAN" threshold = 85 threshold_type = "PERCENTAGE" notification_type = "ACTUAL" subscriber_email_addresses = [var.root_email, var.notification_email] } notification { comparison_operator = "GREATER_THAN" threshold = 100 threshold_type = "PERCENTAGE" notification_type = "ACTUAL" subscriber_email_addresses = [var.root_email, var.notification_email] } } - Nome do arquivo: Variables.tf
variable "region" { type = string default = "us-east-1" } variable "account_name" { type = string description = "(Required) Account Name" } variable "root_email" { type = string description = "(Required) Account Email" } variable tags{ type = map(string) description = "(Required) Tags for the resource" } variable "close_delete" { type = bool description = "Close Account on deletion" default = true } variable "gov_cloud" { type = bool description = "Gov Cloud Account" default = false } variable "parent_id" { type = string description = "(Required) Account Parent Organizational Unit" } variable monthly_budget { type = number default = 0 } variable notification_email { type = string description = "Additional email where Budget Notifications are to be sent" }
- Nome do arquivo: Awsaccount.tf
- Pressione Terraform arquivos para o repositório remoto.
-
Anote o local ou o URL depois que o modelo for armazenado no GitHub.
Este modelo é referenciado em Terraform Cloud e o. ServiceNow instância para automatizar a criação de uma conta de assinatura.
Importante:Não modifique o modelo, pois as variáveis estão intimamente conectadas à aplicação.