I’m Running Terraform inside azure container instance with MSI attached.
here my configuration:
terraform {
required_providers {
azurerm = {
source = “hashicorp/azurerm”
version = “=3.0.2”
}
}
required_version = “>= 1.1.0”
backend “azurerm” {
storage_account_name = “STORAGE_ACCOUNT_NAME”
container_name = “CONTAINER_NAME”
key = “STATE_FILE_NAME”
use_msi = true
resource_group_name = “POD_RESOURCE_GROUP”
subscription_id = “SUBSCRIPTION_ID”
tenant_id = “TENANT_ID”
}
}
I’m running
echo “Running init command\n”
terraform init -reconfigure
if [ ? -ne 0 ];then
echo "terraform init command failed, will try after 15 seconds"
sleep 15
terraform init -reconfigure
if [ ? -ne 0 ];then
echo “terraform init command failed again”
exit 1
fi
fi
echo “Running plan commnand\n”
terraform plan
if [ ? -ne 0 ];then
echo "terraform plan command failed"
exit 1
fi
echo "runninh apply command\n"
terraform apply -auto-approve
if [ ? -ne 0 ];then
echo “terraform apply command failed”
exit 1
fi