始める前に
- ラボでは、Google Cloud プロジェクトとリソースを一定の時間利用します
- ラボには時間制限があり、一時停止機能はありません。ラボを終了した場合は、最初からやり直す必要があります。
- 画面左上の [ラボを開始] をクリックして開始します
Solve Task One
/ 100
Cloud Shell is a virtual machine that is loaded with development tools. It offers a persistent 5GB home directory and runs on the Google Cloud. Cloud Shell provides command-line access to your Google Cloud resources.
When you are connected, you are already authenticated, and the project is set to your PROJECT_ID. The output contains a line that declares the PROJECT_ID for this session:
gcloud is the command-line tool for Google Cloud. It comes pre-installed on Cloud Shell and supports tab-completion.
Click Authorize.
Your output should now look like this:
Output:
Output:
Example output:
gcloud, in Google Cloud, refer to the gcloud CLI overview guide.
This lab demonstrates how to use Terraform to create a Google Compute Engine (GCE) instance. You will define your infrastructure as code, allowing you to easily provision and manage your resources. This lab assumes you have basic knowledge of Google Cloud and Terraform.
Before you begin, ensure you have the following:
A Google Cloud project with billing enabled. You will need the Project ID for subsequent steps. The project ID will be:
Terraform installed on your local machine or in Cloud Shell. If using Cloud Shell, Terraform is pre-installed.
The Google Cloud SDK (gcloud) installed and configured. If using Cloud Shell, gcloud is pre-installed and authenticated.
Authenticate to your Google Cloud project. In Cloud Shell, this might be done automatically.
Set your Project ID to be:
Terraform uses a state file to track the resources it manages. For collaborative projects and increased reliability, it's best to store this state remotely in a Cloud Storage bucket.
Create a Cloud Storage bucket. The bucket name must be globally unique and should include your project ID as a prefix.
Enable versioning on the bucket. This allows you to revert to previous states if necessary.
Now, you will create the Terraform configuration files that define your GCE instance.
Create a file named main.tf with the following content:
Create a file named variables.tf (optional, but recommended for defining variables):
With the configuration files created, you can now initialize, plan, and apply your Terraform configuration.
Initialize Terraform. This downloads the necessary provider plugins.
Plan the changes. This shows you what Terraform will do before it makes any actual changes.
Apply the changes. This creates the GCE instance.
Once Terraform has finished, verify that the GCE instance has been created.
In the Google Cloud Console, navigate to Compute Engine > VM instances. You should see an instance named 'terraform-instance'.
Alternatively, use the gcloud command to list instances.
When you are finished, destroy the infrastructure to avoid incurring unnecessary costs.
Destroy the resources created by Terraform.
In this lab, you learned how to use Terraform to create a Google Compute Engine instance. By defining your infrastructure as code, you can easily manage and provision resources in a consistent and repeatable way. Remember to destroy your resources when you're finished to avoid unnecessary costs. Continue exploring Terraform's capabilities and integrate it into your Google Cloud workflows.
Manual Last Updated Jul 25, 2025
Lab Last Tested Jul 25, 2025
このコンテンツは現在ご利用いただけません
利用可能になりましたら、メールでお知らせいたします
ありがとうございます。
利用可能になりましたら、メールでご連絡いたします
1 回に 1 つのラボ
既存のラボをすべて終了して、このラボを開始することを確認してください