Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Cette page décrit la procédure à suivre pour installer et configurer Terraform pour Google Cloud dans Cloud Shell et dans un shell local.
Cloud Shell est un environnement de shell interactif pour Google Cloud qui vous permet de vous familiariser avec Google Cloud, et de gérer vos projets et vos ressources depuis un navigateur Web.
Cloud Shell
Pour utiliser un terminal en ligne avec la gcloud CLI et Terraform déjà configurés, activez Cloud Shell :
En bas de la page, une session Cloud Shell démarre et affiche une invite de ligne de commande. L'initialisation de la session peut prendre quelques secondes.
Pour provisionner des ressources Google Cloud à l'aide de Terraform, vous devez activer les API correspondantes :
gcloudservicesenable"API"
Remplacez API par l'API que vous souhaitez activer.
Pour provisionner des ressources Google Cloud à l'aide de Terraform, vous avez besoin de rôles Identity and Access Management spécifiques à ces ressources.
Pour provisionner une ressource Google Cloud à l'aide de Terraform, vous avez besoin de rôles Identity and Access Management spécifiques à ces ressources.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/04 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/09/04 (UTC)."],[[["\u003cp\u003eThis guide details the process of installing and configuring Terraform for Google Cloud, both in the online Cloud Shell environment and in a local shell.\u003c/p\u003e\n"],["\u003cp\u003eTo get started, you'll need to create or select a Google Cloud project and ensure that billing is enabled for it.\u003c/p\u003e\n"],["\u003cp\u003eProvisioning Google Cloud resources with Terraform requires enabling the relevant APIs and setting up specific Identity and Access Management roles for your user account.\u003c/p\u003e\n"],["\u003cp\u003eVerify that Terraform is correctly installed and operational by executing the \u003ccode\u003eterraform\u003c/code\u003e command in your terminal.\u003c/p\u003e\n"],["\u003cp\u003eThe Cloud Shell environment comes pre-configured with Terraform and the gcloud CLI, while local shell users will have to install and initialize them.\u003c/p\u003e\n"]]],[],null,["# Install Terraform\n\nThis page describes the steps to install Terraform for\nGoogle Cloud in [Cloud Shell](/shell/docs) and in a local shell.\nCloud Shell is an interactive shell environment for Google Cloud\nthat lets you learn and experiment with Google Cloud and manage your\nprojects and resources from your web browser.\n\nFor a introductory guide to using Terraform with Google Cloud, see the\n[Terraform for Google Cloud Quickstart](/docs/terraform/create-vm-instance). \n\n### Cloud Shell\n\n\n1. To use an online terminal with the gcloud CLI and Terraform\n already set up, activate Cloud Shell:\n\n At the bottom of this page, a Cloud Shell session starts and\n displays a command-line prompt. It can take a few seconds for the session\n to initialize.\n2. Run the following command to verify that Terraform is available:\n\n terraform\n\n The output should be similar to the following: \n\n\n Usage: terraform [global options] \u003csubcommand\u003e [args]\n\n The available commands for execution are listed below.\n The primary workflow commands are given first, followed by\n less common or more advanced commands.\n\n Main commands:\n init Prepare your working directory for other commands\n validate Check whether the configuration is valid\n plan Show changes required by the current configuration\n apply Create or update infrastructure\n destroy Destroy previously-created infrastructure\n\n3. To use Terraform with Google Cloud, you should ensure the\n following tasks are completed within Google Cloud:\n\n - [Create or have a Google Cloud project](/resource-manager/docs/creating-managing-projects).\n - [Enable billing](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project) for the Google Cloud project.\n - [Enable APIs](/apis/docs/getting-started#enabling_apis) for the Google Cloud services you intend to work with.\n - [Set up authentication](/docs/terraform/authentication) for Terraform.\n\n### Local shell\n\n1. Use the [installation instructions](https://developer.hashicorp.com/terraform/tutorials/gcp-get-started/install-cli)\n provided by Terraform.\n\n2. Run the following command to verify that Terraform is available:\n\n terraform\n\n The output should be similar to the following: \n\n\n Usage: terraform [global options] \u003csubcommand\u003e [args]\n\n The available commands for execution are listed below.\n The primary workflow commands are given first, followed by\n less common or more advanced commands.\n\n Main commands:\n init Prepare your working directory for other commands\n validate Check whether the configuration is valid\n plan Show changes required by the current configuration\n apply Create or update infrastructure\n destroy Destroy previously-created infrastructure\n\n3. To use Terraform with Google Cloud, you should ensure the\n following tasks are completed within Google Cloud:\n\n - [Create or have a Google Cloud project](/resource-manager/docs/creating-managing-projects).\n - [Enable billing](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project) for the Google Cloud project.\n - [Enable APIs](/apis/docs/getting-started#enabling_apis) for the Google Cloud services you intend to work with.\n - [Set up authentication](/docs/terraform/authentication) for Terraform.\n\nWhat's next\n-----------\n\n- Work through the [Terraform for Google Cloud quickstart](/docs/terraform/create-vm-instance)\n- Learn about the [basic Terraform commands](/docs/terraform/basic-commands)."]]