[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["わかりにくい","hardToUnderstand","thumb-down"],["情報またはサンプルコードが不正確","incorrectInformationOrSampleCode","thumb-down"],["必要な情報 / サンプルがない","missingTheInformationSamplesINeed","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-09-04 UTC。"],[],[],null,["# Deploy virtual machine (VM) products using the command-line interface (CLI)\n\nVirtual machine (VM) products offered through Google Cloud Marketplace are custom VM\ninstances that you can run on Compute Engine. For an overview of\nCompute Engine concepts, visit the\n[Compute Engine documentation](/compute/docs).\n\nSome VM products on Google Cloud Marketplace support deployment through the command-line\ninterface (CLI) using [Terraform](https://www.terraform.io/),\nan open-source tool for provisioning and managing infrastructure. For more\ninformation on Terraform, visit\n[Get started with Terraform](/docs/terraform/get-started-with-terraform).\n\nOverview\n--------\n\nThis page describes the steps for deploying VM products through the CLI by using\nTerraform. At a high level, you:\n\n1. [Visit the relevant section](#visit-tab) of the product's Google Cloud Marketplace\n listing.\n\n2. Optionally,\n [select or create the service account](#configure-service-account) that you\n want to use for your command-line deployment.\n\n3. Optionally,\n [set up service account impersonation](#service-account-impersonation).\n\n4. [Configure your `gcloud` environment](#configure-gcloud) for Terraform.\n\n5. [Download the Terraform module or code snippet](#download-module) that you\n use to deploy the VM product through the CLI.\n\n6. Use the module or code snippet to [deploy the VM product](#use-snippet).\n\nVisit the command-line deployment tab\n-------------------------------------\n\nTo start deploying a VM product through the CLI:\n\n1. In Cloud Marketplace, visit the product listing page for the VM product\n that you want to deploy through the CLI.\n\n [Go to Marketplace](https://console.cloud.google.com/marketplace)\n2. Click the **Launch** button, or click **Deploy with CLI** to visit the\n **Command-line deployment** tab.\n\n(Optional) Select or create your service account\n------------------------------------------------\n\nWithin the **Command-line deployment** tab, you can choose to select or create\nthe service account that you want to use for your command-line deployment. If\nyou haven't selected or created a service account in the\n**Command-line deployment** tab when you\n[generate your code snippet](#generate-snippet), you must manually edit the\ngenerated Terraform snippet to add a service account before you use it. For more\ninformation about service accounts, visit\n[Creating and managing service accounts](/iam/docs/creating-managing-service-accounts).\n\nIf you want to deploy a Cloud Marketplace VM product through the CLI, the\nservice account that you use must have the\n[Compute Admin (`roles/compute.admin`) Identity and Access Management (IAM) role](/compute/docs/access/iam#compute.admin).\nIf you create a new service account from the **Command-line deployment** tab,\nGoogle Cloud Marketplace automatically grants this role to the new service account. If\nyou select an existing service account from the **Command-line deployment** tab,\nyou must verify that the service account has this role.\n\nTo select or create your service account:\n\n1. From [the **Command-line deployment** tab](#visit-tab) of the VM product's\n Google Cloud Marketplace listing, under **Configure a service account (optional)** ,\n click the **Configure** button.\n\n2. Under **Service account requesting permissions** , you can click to\n **Select an existing service account** , or **Create a new service account**.\n\n### Select an existing service account\n\nTo select an existing service account:\n\n1. Under **Select a service account** , select the service account that you want\n to use. The list contains all of your existing service accounts that have the\n [Compute Admin (`roles/compute.admin`) role](/compute/docs/access/iam#compute.admin).\n\n If none of your existing service accounts have the Compute Admin\n (`roles/compute.admin`) role, the list is empty. If the list is empty, you\n can grant this role to one of your existing service accounts and then return\n to this tab, or you can choose to\n [create a new service account](#create-service-account) instead.\n2. Click the **Submit** button.\n\n### Create a new service account\n\nTo create a new service account:\n\n1. Choose a name for your service account, and add it in the\n **Service account name** field.\n\n2. Choose an ID for your service account, and add it in the\n **Service account ID** field.\n\n3. Add a description for your service account to the\n **Service account description** field.\n\n4. Click the **Create service account** button.\n\nAfter you've created your service account, you can continue to\n[manage the service account's access control](/iam/docs/overview) by using\nIAM.\n\n(Optional) Set up service account impersonation\n-----------------------------------------------\n\nWe recommend that you use *service account impersonation* to manage access to\nyour command-line deployment. If you use impersonation, instead of creating\nservice account keys that anyone can use to access your deployment, you manage\naccess by granting or revoking the\n[Service Account Token Creator (`roles/iam.serviceAccountTokenCreator`) IAM role](/iam/docs/service-account-permissions#token-creator-role)\nto specific principals.\n\nTo learn how to grant and revoke roles on a service accounts, see\n[Manage access to service accounts](/iam/docs/manage-access-service-accounts).\nTo learn more about service account impersonation, see [Service account\nimpersonation](/iam/docs/service-account-impersonation).\n\nConfigure your gcloud environment for Terraform\n-----------------------------------------------\n\nIn the **Command-line deployment** tab, under **Configure gcloud** , you see a\nseries of commands. To configure your `gcloud` environment for Terraform, you\ncan copy and run the provided commands.\n\nDownload the Terraform module\n-----------------------------\n\nYou use either an included Terraform module or a generated code snippet to\ndeploy a VM product through the CLI, depending on how the VM product is\nconfigured. To verify whether you use an included module or a generated code\nsnippet to deploy a VM product, visit the **Command-line deployment** tab of the\nproduct's Cloud Marketplace listing. If you use an included module to\ndeploy the product, you see a **Download** button. If you use a generated code\nsnippet to deploy the product, you see a **Generate code** button.\n\nTo download the included module or generated code snippet, complete the\nfollowing steps: \n\n### Included Terraform module\n\n1. From the **Command-line deployment** tab of the VM product's\n Cloud Marketplace listing, click the **Download** button. This\n downloads a zip file that contains the Terraform module you use.\n\n2. Extract the Terraform module from the zip file that you downloaded.\n\n### Generated code snippet\n\n1. From the **Command-line deployment** tab of the VM product's\n Cloud Marketplace listing, click the **Generate code** button. This\n generates a code snippet that you can copy and use with Terraform to deploy\n a VM with Terraform.\n\n2. To copy the generated code snippet, click **Copy to clipboard**.\n\nUse the included module or generated code snippet to deploy the VM product\n--------------------------------------------------------------------------\n\nTo use the included module or generated code snippet to deploy the VM product\nthrough the CLI, complete the following steps: \n\n### Included Terraform module\n\n1. In the Terraform module that you [downloaded](#download-module), locate the\n `README.md` file .\n\n2. Follow the product-specific instructions from the `README.md` file.\n\n While you follow the product-specific instructions, if you experience\n issues, you can optionally try to deploy the module by running the\n following commands:\n - `terraform init`\n\n - `terraform apply`\n\n### Generated code snippet\n\n1. Verify that the generated code snippet includes the service account that\n you want to use. If you've\n [configured a service account](#configure-service-account) for your\n command-line deployment, that service account's information is included in\n the generated code snippet. If you haven't configured a service account,\n you must edit the generated code snippet to specify the service account\n that you want to use.\n\n2. Create a new file named `main.tf` on the machine where you've installed\n Terraform.\n\n3. Paste the generated code snippet, with any edits you've made to it, into\n the `main.tf` file that you created.\n\n4. Run the following commands:\n\n - `terraform init`\n\n - `terraform apply`\n\nNext steps\n----------\n\nFor information on managing your CLI deployments of VM products, visit\n[Manage CLI deployments of VM products](/marketplace/docs/manage-cli-deployments)."]]