迁移工作负载

本页面介绍如何在将现有项目迁移到 Assured Workloads 文件夹之前执行合规性分析。此分析会比较源项目和目标 Assured Workloads 文件夹,以确定在启动迁移前后可能需要哪些更改。例如,如果您的项目要移至针对 FedRAMP 中等风险级别配置的 Assured Workloads 文件夹,则可以在移动项目之前主动解决可能出现的合规性违规行为。

移动分析会返回以下类型的发现结果:

  • 源项目使用了不受支持的产品或服务。
  • 源项目包含的资源位于不允许的位置。
  • 源项目配置了与目标 Assured Workloads 文件夹不兼容的组织政策限制条件值。

在尝试迁移之前,先了解这些发现结果非常重要。默认情况下,Assured Workloads 文件夹只能包含该文件夹的控制软件包支持的服务的资源类型。如果您的项目包含该文件夹的控制软件包不支持的服务的资源,您可能需要重新部署或移除这些资源。

虽然您可以通过更改 Assured Workloads 文件夹的资源使用限制组织政策来更改受支持的服务的默认列表,从而允许在文件夹中部署不合规的服务,但背景合规性检查会忽略不合规的服务及其资源。因此,通过启用不受支持的服务,您可以选择接受可能导致工作负载不合规的风险。

准备工作

必需的 IAM 权限

如需执行迁移分析,必须使用包含更多权限的预定义角色或仅限于拥有最少必要权限的自定义角色为调用方授予 IAM 权限。

必须拥有以下权限:

  • 针对目标工作负载assuredworkloads.workload.get 权限
  • 针对源项目的 cloudasset.assets.searchAllResources 权限
  • 针对源项目和目标 Assured Workloads 文件夹的 orgpolicy.policy.get 权限

执行迁移分析

在对源项目和目标 Assured Workloads 文件夹执行分析时,您应先解决所有发现的问题,然后再将项目移至目标。虽然发现结果不会阻止您移动项目,但可能会导致目标 Assured Workloads 文件夹中存在合规性违规行为。

这些发现结果有两种不同的类型:

  • 警告:如果源项目可能与目标不兼容,则会显示警告结果,并可能导致违规。应调查警告,以确认这种不兼容问题是可接受的,还是应在迁移之前得到解决。
  • 阻拦程序:当检测到源项目和目标之间存在违规行为时,会出现阻碍结果。在进行迁移之前,必须解决阻碍因素。

系统会报告以下类型的发现结果:

  • 资源位置:许多控制软件包会强制对资源施加位置限制,以符合合规性要求,例如,您的源项目包含的资源位于禁止的位置。

    如需解决此问题,请将受影响的资源移到允许的位置、删除它们,或者修改目标的 gcp.resourceLocations 组织政策限制条件设置。

  • 不支持的产品/服务:每个控制软件包都支持一系列特定的 Google Cloud 产品和服务。如果您的项目使用的服务不受目标 Assured Workloads 文件夹的控制软件包支持的服务,则该服务将列为发现结果。

  • 组织政策限制条件:为您的源项目配置了组织政策限制条件值,这些值可能与目标 Assured Workloads 文件夹的有效政策不同,或者不符合目标控制软件包。系统仅针对与目标 Assured Workloads 文件夹的控制软件包相关的限制条件执行此分析;系统不会评估项目的所有限制条件值。可能会出现多种结果,例如以下问题:

    • 您的项目与目标位置的有效政策不兼容。
    • 您的项目有一些组织政策限制条件值未在目标位置设置,反之亦然。
    • 您的项目包含不符合目标控制软件包的组织政策限制条件值。

    如果发现组织政策限制条件的阻碍因素,则响应将包含符合目标控制软件包的预期值。在执行迁移之前,您可以使用这些预期值对项目进行更改。

如需解决此问题,请确定需要修改哪个组织政策限制条件,并进行必要的更改

不支持的发现结果类型

迁移分析不支持以下类型的发现结果:

  • gcp.resourceLocations 以外的组织政策限制条件的资源级不兼容性。例如,某些控制软件包配置了全局 gcp.restrictCmekCryptoKeyProjects 限制条件或特定于 Compute Engine 的 compute.disableNestedVirtualization 限制条件;系统不会分析或报告来源和目标之间的这些限制条件之间的不兼容情况。
  • 针对特定控制软件包可能停用的服务专用功能。例如,系统会对 IL4 文件夹停用 Cloud Monitoring 的拨测,并为 ITAR 文件夹停用 BigQuery 的远程函数;如果您的源项目使用此类已停用的功能,则不会分析或报告这些不兼容性。

分析将项目移动到 Assured Workloads 文件夹

analyzeWorkloadMove 方法会对将源项目移动到目标 Assured Workloads 文件夹执行分析。

在下面的请求示例中,将以下参数替换为您自己的参数:

  • ENDPOINT_URI:Assured Workloads 服务端点 URI。此 URI 必须是与目标工作负载的位置匹配的端点,例如,https://us-west1-assuredworkloads.googleapis.com 表示 us-west1 区域中的区域化工作负载,https://us-assuredworkloads.googleapis.com 表示美国的多区域工作负载。
  • DESTINATION_ORGANIZATION_ID:源项目将迁移到的目标工作负载的组织 ID。例如 919698201234
  • DESTINATION_LOCATION_ID:目标工作负载的位置。例如:us-west1us。它对应于工作负载的 data region 值。
  • DESTINATION_WORKLOAD_ID:将迁移源项目的目标 Assured Workloads 文件夹的 ID。例如:00-701ea036-7152-4780-a867-9f5
  • SOURCE_PROJECT_ID:要迁移的源项目的 ID 的查询参数。例如 my-project-123
  • ASSET_TYPES:可选。每个查询参数一个资产类型,用于过滤出指定的类型。例如: cloudresourcemanager.googleapis.com/Project
  • PAGE_SIZE:可选。表示每页返回的结果数量的查询参数。例如 5
  • PAGE_TOKEN:可选。令牌的查询参数,用于继续对结果进行分页。例如 CiAKGjBpNDd2Nmp2Zml2cXRwYjBpOXA

HTTP 方法、网址和查询参数:

GET https://[ENDPOINT_URI]/v1/organizations/[DESTINATION_ORGANIZATION_ID]/locations/[DESTINATION_LOCATION_ID]/workloads/[DESTINATION_WORKLOAD_ID]:analyzeWorkloadMove?project=projects/SOURCE_PROJECT_ID&page_size=PAGE_SIZE&page_token=PAGE_TOKEN

例如:

GET https://us-west1-assuredworkloads.googleapis.com/v1/organizations/919698298765/locations/us-west1/workloads/00-701ea036-7152-4781-a867-9f5:analyzeWorkloadMove?project=projects/my-project-123&page_size=5&page_token=CiAKGjBpNDd2Nmp2Zml2cXRwYjBpOXA

您应该收到类似以下内容的 JSON 响应:

{
  "assetMoveAnalyses": [
    {
      "asset": "//orgpolicy.googleapis.com/projects/130536381852/policies/container.restrictNoncompliantDiagnosticDataAccess",
      "assetType": "orgpolicy.googleapis.com/Policy"
    },
    {
      "asset": "//compute.googleapis.com/projects/my-project-123/global/routes/default-route-9ca6e6b0ab7326f0",
      "assetType": "compute.googleapis.com/Route",
      "analysisGroups": [
        {
          "displayName": "RESOURCE_LOCATIONS",
          "analysisResult": {
            "warnings": [
              {
                "detail": "The asset's location 'global' is incompatible with the gcp.resourceLocations org policy effective at the target. In case of 'global only' assets, this may be ignored."
              }
            ]
          }
        }
      ]
    },
    {
      "asset": "//compute.googleapis.com/projects/my-project-123/regions/europe-west10/subnetworks/default",
      "assetType": "compute.googleapis.com/Subnetwork",
      "analysisGroups": [
        {
          "displayName": "RESOURCE_LOCATIONS",
          "analysisResult": {
            "blockers": [
              {
                "detail": "The asset's location 'europe-west10' is incompatible with the gcp.resourceLocations org policy effective at the target."
              }
            ]
          }
        }
      ]
    },
    {
      "asset": "//serviceusage.googleapis.com/projects/130536381852/services/servicemanagement.googleapis.com",
      "assetType": "serviceusage.googleapis.com/Service"
    },
    {
      "asset": "//serviceusage.googleapis.com/projects/130536381852/services/monitoring.googleapis.com",
      "assetType": "serviceusage.googleapis.com/Service"
    },
    {
      "asset": "//serviceusage.googleapis.com/projects/130536381852/services/bigquerymigration.googleapis.com",
      "assetType": "serviceusage.googleapis.com/Service",
      "analysisGroups": [
        {
          "displayName": "DISALLOWED_SERVICES",
          "analysisResult": {
            "warnings": [
              {
                "detail": "This service is not allowed by the gcp.restrictServiceUsage org policy effective at the target"
              }
            ]
          }
        }
      ]
    },
    {
      "asset": "//cloudresourcemanager.googleapis.com/projects/my-project-123",
      "assetType": "cloudresourcemanager.googleapis.com/Project",
      "analysisGroups": [
        {
          "displayName": "ORG_POLICIES",
          "analysisResult": {
            "warnings": [
              {
                "detail": "constraints/gcp.resourceLocations: Target applies/inherits this custom policy and it is not applied by the source. Upon moving, this policy will get inherited from the target."
              },
              {
                "detail": "constraints/compute.disableInstanceDataAccessApis: Source applies this custom policy and it is not applied by the target."
              },
              {
                "detail": "constraints/cloudkms.allowedProtectionLevels: Source and target set different values for this policy."
              },
              {
                "detail": "constraints/container.restrictNoncompliantDiagnosticDataAccess: Source and target set different values for this policy."
              },
              {
                "detail": "constraints/gcp.restrictServiceUsage: Target applies/inherits this custom policy and it is not applied by the source. Upon moving, this policy will get inherited from the target."
              }
            ],
            "blockers": [
              {
                "detail": "constraints/gcp.resourceLocations: The value applied at the source is not compliant with the target compliance program. The expected allowed values are [us-west4, us-west1, us-west2, us-west3, us-central1, us-east1, us-east4, us-south1, us-central2, us-east5]."
              },
              {
                "detail": "constraints/container.restrictNoncompliantDiagnosticDataAccess: The value applied at the source is not compliant with the target compliance program. The expected value is [true]."
              },
              {
                "detail": "constraints/container.restrictTLSVersion: The value applied at the source is not compliant with the target compliance program. The expected denied values are [TLS_VERSION_1, TLS_VERSION_1_1]."
              }
            ]
          }
        }
      ]
    }
  ],
  "nextPageToken": "Ch8wLDc0MzY3NTExNCwzMzg4ODM1NTM2NDQ0NTg4MDMy"
}

如需按特定资产类型过滤结果,请使用 asset_types 查询参数:

GET https://assuredworkloads.googleapis.com/v1/organizations/919698298765/locations/us-west1/workloads/00-701ea036-7152-4781-a867-9f5:analyzeWorkloadMove?project=projects/my-project-123&asset_types=cloudresourcemanager.googleapis.com/Project&page_size=5&page_token=CiAKGjBpNDd2Nmp2Zml2cXRwYjBpOXA

结果将仅包含指定类型 (cloudresourcemanager.googleapis.com/Project) 的任何发现结果:

{
  "assetMoveAnalyses": [
    {
      "asset": "//cloudresourcemanager.googleapis.com/projects/my-project-123",
      "assetType": "cloudresourcemanager.googleapis.com/Project",
      "analysisGroups": [
        {
          "displayName": "ORG_POLICIES",
          "analysisResult": {
            "warnings": [
              {
                "detail": "constraints/gcp.resourceLocations: Target applies/inherits this custom policy and it is not applied by the source. Upon moving, this policy will get inherited from the target."
              },
              {
                "detail": "constraints/compute.disableInstanceDataAccessApis: Source applies this custom policy and it is not applied by the target."
              }
            ],
            "blockers": [
              {
                "detail": "constraints/gcp.resourceLocations: The value applied at the source is not compliant with the target compliance program. The expected allowed values are [us-west4, us-west1, us-west2, us-west3, us-central1, us-east1, us-east4, us-south1, us-central2, us-east5]."
              }
            ]
          }
        }
      ]
    }
  ],
  "nextPageToken": "Ch8wLDc0MzY3NTExNCwzMzg4ODM1NTM2NDQ0NTg4MDMy"
}

如需按多种资产类型过滤结果,请将每种资产类型添加为额外的查询参数:

GET https://assuredworkloads.googleapis.com/v1/organizations/919698298765/locations/us-west1/workloads/00-701ea036-7152-4781-a867-9f5:analyzeWorkloadMove?project=projects/my-project-123&asset_types=cloudresourcemanager.googleapis.com/Project&asset_types=serviceusage.googleapis.com/Service&page_size=5&page_token=CiAKGjBpNDd2Nmp2Zml2cXRwYjBpOXA

结果将仅包含指定类型(cloudresourcemanager.googleapis.com/Projectserviceusage.googleapis.com/Service)的任何发现结果:

{
  "assetMoveAnalyses": [
    {
      "asset": "//serviceusage.googleapis.com/projects/130536381852/services/bigquerymigration.googleapis.com",
      "assetType": "serviceusage.googleapis.com/Service",
      "analysisGroups": [
        {
          "displayName": "DISALLOWED_SERVICES",
          "analysisResult": {
            "warnings": [
              {
                "detail": "This service is not allowed by the gcp.restrictServiceUsage org policy effective at the target"
              }
            ]
          }
        }
      ]
    },
    {
      "asset": "//cloudresourcemanager.googleapis.com/projects/my-project-123",
      "assetType": "cloudresourcemanager.googleapis.com/Project",
      "analysisGroups": [
        {
          "displayName": "ORG_POLICIES",
          "analysisResult": {
            "warnings": [
              {
                "detail": "constraints/gcp.resourceLocations: Target applies/inherits this custom policy and it is not applied by the source. Upon moving, this policy will get inherited from the target."
              },
              {
                "detail": "constraints/compute.disableInstanceDataAccessApis: Source applies this custom policy and it is not applied by the target."
              }
            ],
            "blockers": [
              {
                "detail": "constraints/gcp.resourceLocations: The value applied at the source is not compliant with the target compliance program. The expected allowed values are [us-west4, us-west1, us-west2, us-west3, us-central1, us-east1, us-east4, us-south1, us-central2, us-east5]."
              }
            ]
          }
        }
      ]
    }
  ],
  "nextPageToken": "Ch8wLDc0MzY3NTExNCwzMzg4ODM1NTM2NDQ0NTg4MDMy"
}

执行迁移分析后,查看并解决任何警告或障碍,然后再次运行分析以验证它们是否已得到解决。然后,您可以继续移动项目

后续步骤