Genesys Cloud Bot Skill API 409 Conflict on Terraform Apply

Ran into a weird issue today with the AI Bot skill assignment via Terraform. The deployment pipeline fails consistently when attempting to update an existing bot’s skill set.

module.bot.genesyscloud_ai_bot_skill.ai_bot_skill[0]: Creating...
module.bot.genesyscloud_ai_bot_skill.ai_bot_skill[0]: Creation complete after 2s [id=12345]
module.bot.genesyscloud_ai_bot_skill.ai_bot_skill[1]: Creating...
╷
│ Error: API returned 409 Conflict
│ 
│ with module.bot.genesyscloud_ai_bot_skill.ai_bot_skill[1],
│ on main.tf line 45, in resource "genesyscloud_ai_bot_skill" "ai_bot_skill":
│ 45: resource "genesyscloud_ai_bot_skill" "ai_bot_skill" {
│ 
│ POST /api/v2/ai/bots/67890/skills returned 409 Conflict: The bot already has a skill associated with this intent group.
╵

Provider version: 1.34.2
Terraform: 1.7.5
Environment: Production org

The state file shows both resources exist with distinct IDs, but the API rejects the second skill addition. Manual verification via Postman confirms the bot only has one skill attached. The first apply works, subsequent applies fail on the second skill resource. No drift detected in state. Is this a known race condition in the provider or an API limitation requiring explicit ordering? The documentation does not mention dependency management for multiple skills on a single bot resource.

TL;DR: Use depends_on to force sequential skill updates and avoid concurrent API calls on the same bot entity.

This is caused by the Genesys Cloud API enforcing strict resource locking on AI Bot entities during concurrent modification attempts. When Terraform attempts to create or update multiple skills for the same bot ID in parallel, the underlying Platform API returns a 409 Conflict because the bot’s configuration state is locked by the first request. The Terraform provider does not automatically serialize these dependent resources unless explicitly instructed to do so.

From an AppFoundry integration perspective, we see this frequently when bulk-updating bot configurations via the REST API. The solution is to enforce a dependency chain in your Terraform configuration. You must ensure that each subsequent skill creation waits for the previous one to complete.

Update your Terraform module to include explicit depends_on metadata for each skill resource, linking them sequentially. Alternatively, if you are managing a dynamic list of skills, consider using a for_each loop with a custom dependency graph that serializes the operations.

resource "genesyscloud_ai_bot_skill" "bot_skill_1" {
 bot_id = genesyscloud_ai_bot.main.id
 skill_id = data.genesyscloud_skill.primary.id
 # Explicit dependency if part of a larger chain
}

resource "genesyscloud_ai_bot_skill" "bot_skill_2" {
 bot_id = genesyscloud_ai_bot.main.id
 skill_id = data.genesyscloud_skill.secondary.id
 
 depends_on = [
 genesyscloud_ai_bot_skill.bot_skill_1
 ]
}

This forces Terraform to wait for the first skill assignment to fully commit before initiating the second. This pattern prevents the 409 error by ensuring only one write operation targets the bot resource at any given time. Verify that no other automation is simultaneously modifying the bot’s skill set, as external changes can also trigger conflicts.