始める前に
- ラボでは、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 guides you through creating a firewall rule in Google Cloud using Terraform. You will learn how to define a firewall rule resource, configure its properties, and apply it to your Google Cloud project. This lab assumes you have a basic understanding of Google Cloud and Terraform.
Before you begin, configure your Google Cloud project. This includes setting the project ID, region, and zone. Also, enable the IAM API.
Set your Project ID:
Set your default region to
Set your default zone to
Terraform uses a state file to track the resources it manages. For collaboration and persistence, it's best to store this state file in a remote backend like Google Cloud Storage (GCS).
Create a Cloud Storage bucket. Ensure the bucket name is globally unique and prefixed with your project ID:
Enable versioning on the GCS bucket:
Now, you will define the firewall rule using Terraform's configuration language.
Create a new directory for your Terraform configuration files.
Create a file named firewall.tf and add the following code to define a firewall rule that allows SSH traffic (port 22) to instances with the tag ssh-allowed.
Create a variables.tf file to define variables used in firewall.tf and main.tf.
Create an outputs.tf file to output the firewall rule name.
Now you will apply the Terraform configuration to create the firewall rule in your Google Cloud project.
Run terraform init to enable Terraform.
Run terraform plan to preview the changes Terraform will make.
Run terraform apply to apply the configuration and create the firewall rule.
Verify that the firewall rule has been created in the Google Cloud Console.
To avoid incurring unnecessary costs, destroy the resources created in this lab.
Run terraform destroy to remove the firewall rule.
You have successfully created and destroyed a firewall rule in Google Cloud using Terraform. You have learned how to define firewall rules as code, manage their properties, and apply them to your Google Cloud project. This approach enables you to automate and manage your infrastructure in a consistent and repeatable manner.
Manual Last Updated Jul 22, 2025
Lab Last Tested Jul 22, 2025
このコンテンツは現在ご利用いただけません
利用可能になりましたら、メールでお知らせいたします
ありがとうございます。
利用可能になりましたら、メールでご連絡いたします
1 回に 1 つのラボ
既存のラボをすべて終了して、このラボを開始することを確認してください