From e2eead9177102272159890f3d89023c41bc4db6e Mon Sep 17 00:00:00 2001 From: Anais Date: Fri, 19 Jan 2024 18:49:08 +0100 Subject: [PATCH] update terraform provider from local to backend azure --- deployement/README.md | 17 ++++++++++++++++- deployement/aks-deployment/providers.tf | 8 ++++++++ deployement/datastore-deployment/providers.tf | 6 ++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/deployement/README.md b/deployement/README.md index fee0ffe..cbf85ff 100644 --- a/deployement/README.md +++ b/deployement/README.md @@ -9,10 +9,18 @@ jq - export $(grep -v '^#' .env | xargs) # ENABLE AN AZURE STORAGE TFSTATE - +- RESOURCE_GROUP_NAME=rg-rtw-tfstate +- CONTAINER_NAME=rtw-tfstate +- STORAGE_ACCOUNT_NAME=rtwtfstate18005 +- az group create --name $RESOURCE_GROUP_NAME --location westus3 +- az storage account create --resource-group $RESOURCE_GROUP_NAME --name $STORAGE_ACCOUNT_NAME --sku Standard_LRS --encryption-services blob +- az storage container create --name $CONTAINER_NAME --account-name $STORAGE_ACCOUNT_NAME +- ACCOUNT_KEY=$(az storage account keys list --resource-group $RESOURCE_GROUP_NAME --account-name $STORAGE_ACCOUNT_NAME --query '[0].value' -o tsv) +- export ARM_ACCESS_KEY=$ACCOUNT_KEY # FOR DEPLOYING DATASTORE Already actions secret: + - ARM_ACCESS_KEY (necessary for terraform) - ACCESS_TOKEN - ORG_NAME - REPO_NAME @@ -66,6 +74,9 @@ Already actions secret: # FOR DEPLOYING AKS +Already actions secret: + - ARM_ACCESS_KEY (necessary for terraform) + - az login - echo -n $ACR_ID > ./acr_id.txt @@ -109,6 +120,7 @@ Already actions secret: - FUSIONAUTH_DATABASE_USERNAME - FUSIONAUTH_DATABASE_PASSWORD +- az login - az aks get-credentials --resource-group $AKS_RESOURCE_GROUP_NAME --name $KUBERNETES_CLUSTER_NAME - kubectl get nodes - DATABASE_URL=jdbc:postgresql://${POSTGRESQL_FQDN}:5432/fusionauth @@ -126,6 +138,7 @@ Already actions secret: Already actions secret: - default_clientSecret +- az login - az aks get-credentials --resource-group $AKS_RESOURCE_GROUP_NAME --name $KUBERNETES_CLUSTER_NAME - kubectl get nodes @@ -158,6 +171,7 @@ Already actions secret: - kubectl apply -f ingress.yaml # K8S services update after image only (execpt ingress and fusionauth) +- az login - az aks get-credentials --resource-group $AKS_RESOURCE_GROUP_NAME --name $KUBERNETES_CLUSTER_NAME - kubectl get nodes @@ -175,6 +189,7 @@ Already actions secret: - kubectl rollout restart deploy servicename # K8S services update after K8S yaml file update (execpt ingress and fusionauth) +- az login - az aks get-credentials --resource-group $AKS_RESOURCE_GROUP_NAME --name $KUBERNETES_CLUSTER_NAME - kubectl get nodes diff --git a/deployement/aks-deployment/providers.tf b/deployement/aks-deployment/providers.tf index 7eff017..90e21d9 100644 --- a/deployement/aks-deployment/providers.tf +++ b/deployement/aks-deployment/providers.tf @@ -19,6 +19,14 @@ terraform { version = "0.9.1" } } + + backend "azurerm" { + resource_group_name = "rg-rtw-tfstate" + storage_account_name = "rtwtfstate18005" + container_name = "rtw-tfstate" + key = "terraform.tfstate" + } + } provider "azurerm" { diff --git a/deployement/datastore-deployment/providers.tf b/deployement/datastore-deployment/providers.tf index 7eff017..8180b03 100644 --- a/deployement/datastore-deployment/providers.tf +++ b/deployement/datastore-deployment/providers.tf @@ -19,6 +19,12 @@ terraform { version = "0.9.1" } } + backend "azurerm" { + resource_group_name = "rg-rtw-tfstate" + storage_account_name = "rtwtfstate18005" + container_name = "rtw-tfstate" + key = "datastore.tfstate" + } } provider "azurerm" {