Here’s how to resolve this comprehensively. First, address the deployment pipeline configuration issue. Export your region mappings from the on-premise database:
SELECT region_id, region_name, territory_mapping
FROM territory_regions
WHERE active = 1;
Then create or update your territory.config.xml in the cloud deployment package with these mappings. The file should be in your /config/territory/ directory.
For territory-region mapping persistence, you need to modify your cloud environment configuration. Add these properties to your AEM Cloud Manager environment variables:
territory.sync.validation.enabled=true
territory.region.mapping.source=config
territory.sync.error.mode=strict
The mapping.source=config tells the cloud environment to use the XML configuration instead of trying to load dynamically from database, which isn’t available during initial sync.
For sync job error handling, update your sync job configuration to include proper null checks and fallback behavior. Modify the TerritorySync class to validate region data before processing:
public void validateRegions() {
if (regionMapping == null || regionMapping.isEmpty()) {
logger.error("Region mapping not loaded - check deployment config");
throw new ConfigurationException("Missing region mappings");
}
}
In your deployment pipeline, add a pre-deployment validation step that checks for territory configuration completeness. This prevents deployments from succeeding when critical territory data is missing.
Finally, verify IAM permissions in Cloud Manager. The sync service account needs these roles:
- Territory Data Reader
- Region Configuration Reader
- Sync Job Executor
After making these changes, redeploy through the pipeline. The sync job should now properly load region mappings from configuration, handle errors gracefully, and complete territory assignments successfully. Monitor the first few sync cycles to ensure the mappings are persisting correctly between job executions.