# 资源 'projects/my-project/global/images/my-image' 被策略禁止。策略：'constraints/compute.restrictNonCompliantResource'。原因：资源位置 'eastus2' 不允许用于此项目。

- **ID:** `policy/gcp-resource-location-restriction-violation`
- **领域:** policy
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

Google Cloud 组织策略约束限制了资源创建到特定位置（例如仅 us-central1），但资源正在非合规区域（如 eastus2）创建。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Google Cloud SDK 450.0.0 | active | — | — |
| Google Cloud Console 2024-03 | active | — | — |

## 解决方案

1. ```
   检查项目允许的位置：gcloud resource-manager org-policies describe constraints/compute.restrictNonCompliantResource --project=my-project，然后在允许的区域创建资源。
   ```
2. ```
   更新组织策略以添加所需位置：gcloud resource-manager org-policies set-policy --project=my-project policy.yaml，其中 policy.yaml 包含允许的位置。
   ```
3. ```
   如果策略从组织继承，请向 GCP 管理员请求异常以允许特定位置。
   ```

## 无效尝试

- **** — The policy applies to all resources in the project; only allowed locations will succeed. (90% 失败率)
- **** — The same policy will block the creation again. (95% 失败率)
- **** — The policy may be inherited from the organization level and apply to all projects. (70% 失败率)
