Terraform
Terraform
Terraform est un outil open source d'infrastructure en tant que code (IaC) créé par HashiCorp
Download terraform
- init
- plan
- apply
required_providers {
azuread = {
source = "hashicorp/azuread"
version = "~> 2.44.0"
}
azurerm = {
source = "hashicorp/azurerm"
# Root module should specify the maximum provider version
# The ~> operator is a convenient shorthand for allowing only patch releases within a specific minor release.
version = "~> 3.77"
}
}
}
Mise à jour des providers
Commandes principales
Storage Account
resource "azurerm_storage_account" "app_module_fx_sa" {name = "${var.environment}${var.module_collection_name}fxsa"
resource_group_name = azurerm_resource_group.product_rg.name
location = azurerm_resource_group.product_rg.location
access_tier = "Hot"
account_kind = "StorageV2"
account_tier = "Standard"
account_replication_type = "LRS"
allow_nested_items_to_be_public = false
cross_tenant_replication_enabled = false
queue_encryption_key_type = "Account"
table_encryption_key_type = "Account"
}
Tests en local
En local il est possible de surcharger des valeurs. Si par exemple, votre state sera sauvegardé dans un conteneur du cloud lors du CICD, celui ci n'est pas accessible depuis votre poste.
Créer un fichier main_override.tf, si votre fichier principal s'appelle main, et surcharger la valeur du backend à "local":
terraform {
backend "local" {
path = ".terraform/local.state"
}
}
Mises à jour du State
Import
Removed
To remove a resource from Terraform state without destroying it, replace the resource block with a removed block and then apply the change using the standard Terraform workflow. When you remove a resource from state, Terraform no longer manages that infrastructure's lifecycle.
LifeCycle Meta Data
lifecycle {
ignore_changes = [ state ]
}
Documentation
- https://registry.terraform.io/
- https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/linux_function_app#runtime_version
- https://developer.hashicorp.com/terraform/language/meta-arguments/lifecycle
Commentaires
Enregistrer un commentaire