Need some help troubleshooting terraform import for existing security profiles. I am building an audit automation pipeline and need to pull current resources into state.
Running terraform import genesyscloud_securityprofile.my_prof 12345 returns:
Error: Resource not found: 404
The resource exists via /api/v2/security/profiles/12345. The Genesys Docs suggest a direct ID match. Is there a scope issue or a specific import syntax for security automation resources?
Yep, this is a known issue… The Terraform provider often chokes on security profiles if the ID format isn’t strictly numeric or if you are hitting a cached 404. Since you confirmed the API returns data, the resource definitely exists. The provider might be looking for a specific structure in the GET response that doesn’t match what you expect.
Try this approach instead of a blind import:
- First, verify the exact ID format. Ensure
12345 is not a UUID string. The API /api/v2/security/profiles returns standard integers.
- Check for naming conflicts. If you have multiple profiles with similar names, the provider might get confused during state reconciliation.
- Force a refresh of the state before importing. Run
terraform refresh to clear any stale cache.
- If it still fails, try importing via the raw API response. Fetch the profile JSON and manually create a
.tf file with the ID hardcoded, then run terraform plan to see the diff.
Here is a quick check to validate the resource structure before importing:
curl -X GET "https://api.genesys.cloud/v2/security/profiles/12345" \
-H "Authorization: Bearer $GENESYS_TOKEN"
If the response is valid, the issue is likely in the provider’s state mapping logic.