Cloud Scheduler を VPC Service Controls の境界に追加する前にこれらのジョブを削除しない場合、ジョブは引き続き実行されますが、VPC Service Controls はそれらには適用されません(適用されたアクションをご覧ください)。
たとえば、サポートされていないターゲット(Cloud Run カスタム ドメインなど)をターゲットとする Cloud Scheduler ジョブがある場合、Cloud Scheduler を VPC Service Controls の境界に追加した後も、ジョブは継続して実行されますが、VPC Service Controls によって保護されていません。同様のことが、VPC Service Controls の境界の外側にあるターゲットを持つ既存のジョブに当てはまります。
必要な IAM ロールを追加する
必須。VPC Service Controls を使用するには、Cloud Scheduler サービス アカウントに Cloud Scheduler サービス エージェント IAM ロールが付与されている必要があります。プロジェクトの Cloud Scheduler サービス アカウントは自動的に作成されます。Cloud Scheduler サービス エージェントの IAM ロールがあることを確認する手順、またはこのロールを付与する手順は次のとおりです。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["わかりにくい","hardToUnderstand","thumb-down"],["情報またはサンプルコードが不正確","incorrectInformationOrSampleCode","thumb-down"],["必要な情報 / サンプルがない","missingTheInformationSamplesINeed","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2024-12-18 UTC。"],[],[],null,["# Secure cron jobs with VPC Service Controls\n\n[VPC Service Controls](/vpc-service-controls/docs/overview) is a Google Cloud feature\nthat lets you set up a secure perimeter to guard against data exfiltration.\nThis guide shows how to include Cloud Scheduler jobs in a\nVPC Service Controls perimeter.\n\nLimitations\n-----------\n\nThe following limitations apply to VPC Service Controls support for\nCloud Scheduler.\n\n### Enforced actions\n\nVPC Service Controls is only enforced on the following actions:\n\n- Cloud Scheduler job creation\n- Cloud Scheduler job updates\n\n#### Why does this matter?\n\nBecause VPC Service Controls is only enforced on job creation and job updates,\nVPC Service Controls is not automatically enforced for jobs that were\ncreated before you added Cloud Scheduler to your VPC Service Controls\nperimeter. Jobs continue to execute even if the job targets aren't part of your\nVPC Service Controls perimeter or are not [supported targets](#targets). To\nenforce VPC Service Controls for all Cloud Scheduler jobs:\n\n- **Jobs with targets that are either unsupported or are outside your\n perimeter:** Delete the jobs. In this document, see [Delete non-compliant jobs](#non-compliant).\n- **Jobs with targets that are both supported and inside your perimeter:** Run an update on each job after adding Cloud Scheduler to your perimeter. In this document, see [Enforce VPC Service Controls on pre-existing jobs](#preexisting).\n\n### Supported targets\n\nThe Cloud Scheduler integration with VPC Service Controls supports\nthe following targets. HTTP endpoints are supported if listed; however,\narbitrary HTTP endpoints are *not* supported.\n\n- Cloud Run functions---on the `functions.net` URL\n- Cloud Run---on the `run.app` URL for Cloud Run services. Cloud Run job targets are not supported. To learn about the difference between Cloud Run service and job resources, see [Services and jobs: two ways to run your code](/run/docs/overview/what-is-cloud-run#services-and-jobs).\n- Dataflow API---must be in the same Google Cloud project as your Cloud Scheduler job\n- Data Pipelines---must be in the same Google Cloud project as your Cloud Scheduler job\n- Pub/Sub---must be in the same Google Cloud project as your Cloud Scheduler job\n\nDelete non-compliant jobs\n-------------------------\n\nRecommended. Delete Cloud Scheduler jobs with targets that are\neither:\n\n- Unsupported (see [Supported targets](#targets))\n- Outside of the VPC Service Controls perimeter you plan to use\n\nFor instructions on deleting jobs, see\n[Delete a job](/scheduler/docs/creating#delete).\n\nIf you don't delete these jobs before adding Cloud Scheduler to\nyour VPC Service Controls perimeter, the jobs continue to run, but\nVPC Service Controls is not enforced on them. In this document, see\n[Enforced actions](#enforced-actions).\n\nFor example, if you have a Cloud Scheduler job that targets an\nunsupported target (such as a Cloud Run custom domain), the job\ncontinues to run after you add Cloud Scheduler to your\nVPC Service Controls perimeter, but it is not protected by VPC Service Controls. The\nsame is true for a pre-existing job with a target outside of your\nVPC Service Controls perimeter.\n\nAdd required IAM roles\n----------------------\n\nRequired. In order to use VPC Service Controls, the Cloud Scheduler\nservice account must have the **Cloud Scheduler Service Agent**\nIAM role. The Cloud Scheduler service account is created\nfor your project automatically. To verify that it has the Cloud Scheduler\nService Agent IAM role, or to grant this role, take the following\nsteps:\n\n1. In the Google Cloud console, go to **IAM**.\n\n [Go to IAM](https://console.cloud.google.com/iam-admin)\n2. Select the **Include Google-provided role grants** checkbox.\n\n3. In the filter, type **Cloud Scheduler Service Account**, and select this\n principal.\n\n4. Look at the **Role** column for the **Cloud Scheduler Service Account**\n principal. You can proceed if the following role is listed:\n\n - **Cloud Scheduler Service Agent**\n\n If the Cloud Scheduler Service Account role is not listed, click the\n **Edit** icon and grant the **Cloud Scheduler Service Agent** role to the\n Cloud Scheduler Service Account principal.\n\nSpecify a VPC Service Controls perimeter\n----------------------------------------\n\nRequired. You can use an existing perimeter or create a new perimeter to\nprotect your Cloud Scheduler jobs that have supported\ntargets. Both approaches give you the chance to specify services to restrict.\nSpecify the **Cloud Scheduler API**.\n\n- **Existing perimeters:** To update an existing VPC Service Controls perimeter\n to include Cloud Scheduler, follow the steps for\n [updating a service perimeter](/vpc-service-controls/docs/manage-service-perimeters#update).\n\n- **New perimeters:** To create a new perimeter for Cloud Scheduler,\n follow the steps to\n [create a service perimeter](/vpc-service-controls/docs/create-service-perimeters).\n\nEnforce VPC Service Controls on pre-existing jobs\n-------------------------------------------------\n\nRecommended. To enforce VPC Service Controls on Cloud Scheduler jobs\nthat you created before you added Cloud Scheduler to your\nVPC Service Controls perimeter, run an `update` on the job. You don't have to\nchange the job, but you must run the update in order for VPC Service Controls to\napply to the job and its future executions.\n\nYou can run an update for the job from the Google Cloud console (select\nthe job and use the **Edit** button), using the API, or with the\ngcloud CLI.\n\nTo enforce VPC Service Controls on a pre-existing job by using the\ngcloud CLI, run the following: \n\n### HTTP targets\n\n```bash\ngcloud scheduler jobs update http JOB_ID\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eJOB_ID\u003c/var\u003e: the ID of your job\n\n### Pub/Sub targets\n\n```bash\ngcloud scheduler jobs update pubsub JOB_ID\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eJOB_ID\u003c/var\u003e: the ID of your job"]]