githubEdit

Resolving "Service already exists in DB" errors in DuploCloud Terraform deployments

When deploying services through Terraform, you may encounter errors indicating that a service "already exists in DB". This typically happens when there's a mismatch between your Terraform state and the actual resources in DuploCloud. Common causes Multiple deployments to the same branch Manual deletion of services from the DuploCloud portal without updating Terraform state Services created directly in the DuploCloud portal instead of through Terraform Resolution options Option 1: Delete the service from DuploCloud portal If the service exists in DuploCloud but is causing conflicts: Navigate to K8S → Services in the DuploCloud portal Locate the service in question Click the three dots (⋯) in the left column of the service Select Delete to remove the service Re-run your Terraform deployment Option 2: Import existing service into Terraform If you want to keep the existing service and align it with Terraform: Use the Terraform import command to add the existing service to your Terraform state Follow the import syntax documented in the DuploCloud provider documentation Option 3: Remove service from Terraform state If the service exists in Terraform state but was deleted from DuploCloud: Use terraform state rm to remove the service from your Terraform state Re-run your Terraform deployment For CI/CD environments, it's recommended to establish a consistent approach across your team for handling these situations to prevent deployment pipeline disruptions.

Last updated

Was this helpful?