I am working as a senior software engineer in Delta Dental Of California and we recently migrated to Azure Cloud. We are planning to use Terraform as Infrastructure as a code and started learning the terraform .
We are publishing the API’s in Azure APi manager using the terrform code and we are able to do that. If we are deploying another set of api’s , the terraform is deleting the previously created API’s.
is there any chance in terraform to maintain the previous states of the API’s with out destroying every deployment.
We are currently blocked and i need your support on this.
Below is the issue I am facing:
- Published our first API (demo-api) using resource . - Successful
- We are able to test this API from API Manager
- Publishing our second API (demo2-api) - Second API is published and it dot destroyed the First API
We have created a Pipeline which using Terrafrom and creating the resources based on our tf files. We are using a single pipeline for deploying all the API’s but we are passing the API details at RunTime.
Is there any chance to maintain all the previous version with out deleting it. Appreciate your help on this.
name: Azure Pipelines vmImage: windows-latest workspace: clean: all
displayName: ‘SBOX Hub ITS Demo API’
name: Azure Pipelines vmImage: windows-2019
group: Azure Platform Non-Prod Secrets
displayName: ‘Copy Non-Prod main.tf’
displayName: ‘Install Terraform 0.13.3’
script: ‘terraform init -backend-config=“access_key=$(tfstateaccesskey)” -backend-config=“key=tfstatehubnonprdapimdemoapi”’
displayName: ‘terraform init’
script: ‘terraform validate’
displayName: ‘terraform validate’
script: terraform plan -var-file ./terraform.tfvars -var=“environment=dev” -var=“subscription_id=(hubnonprodid)" -var="tenant_id=(tenantid)” -var=“client_id=(dd-ado-automation-spn-id)" -var="client_secret=(dd-ado-automation-spn-secret)” -var=“backend_subscr_id=$(informationtechnologynonprodid)” -out tf.plan
displayName: ‘terraform plan’
script: terraform apply -auto-approve -input=false ./tf.plan
displayName: ‘terraform apply’
displayName: ‘Delete files from $(Build.SourcesDirectory)’