How should I properly to handle SIP Trunk 409 Conflict in Terraform?
Applying genesyscloud_sip_trunk resource fails with HTTP 409 Conflict. Provider is genesyscloud v1.22.0 on AU-1 BYOC environment.
Terraform attempts to create the trunk, but API returns duplicate resource error. The trunk exists in the platform but is not tracked in state file. This happens after a failed deployment or manual deletion in UI without corresponding state removal.
Current configuration:
resource "genesyscloud_sip_trunk" "main" {
name = "Prod-SIP-Trunk-01"
description = "Primary SIP Trunk for Australia"
auth_mode = "none"
domain = "sip.carrier.com"
enabled = true
sip_uri = "sip:sip.carrier.com"
endpoints {
host = "10.20.30.40"
}
inbound {
enabled = true
dialplan {
name = "Global-Dialplan"
description = "Default Inbound"
}
}
outbound {
enabled = true
dialplan {
name = "Global-Dialplan"
description = "Default Outbound"
}
}
}
Error output:
Error: API returned an error: 409 Conflict
Body: {
"errors": [
{
"code": "duplicate_resource",
"message": "SIP Trunk with name 'Prod-SIP-Trunk-01' already exists"
}
]
}
Manual workaround is to import the resource into state. However, this breaks CI/CD pipeline automation. Need a way to force import or handle this conflict automatically during terraform apply.
Is there a lifecycle hook or provider flag to ignore existing resources and update instead? Or should we rely on terraform import script in GitHub Actions?
Environment details:
- Genesys Cloud Platform: AU-1 BYOC
- Terraform Provider: genesyscloud v1.22.0
- Terraform Version: 1.5.7
- GitHub Actions: ubuntu-latest
Looking for best practice to manage this drift between platform state and Terraform state for SIP Trunks.