0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

🌍 Terraform による AWSリソース管理 のファーストステップ

Last updated at Posted at 2025-02-09

📌 概要

Terraform を使って Amazon Route 53 のホストゾーンをする方法 を解説します ✨

📌 main.tf

main.tf の作成がまだの方は以下の記事を参考にファイルを作成してください。

📌 ディレクトリ構成

以下のようなディレクトリ構造でファイルを配置してください。

terraform-project/
│── main.tf
│── modules/
│   ├── route53/
│   │   ├── main.tf

📌 Route 53 のホストゾーンを作成

main.tf

AWS のプロバイダーを設定し、VPC とセキュリティグループのモジュールを読み込む


# 利用するリージョンを "ap-northeast-1"(東京)に指定
provider "aws" {
  region = "ap-northeast-1"
}

# Route 53 のモジュールを読み込む
module "route53" {
  source = "./route53"
}

route53/mainf.tf

ホストゾーンを作成し、ホストゾーン の ID を出力します。

# Route 53 のホストゾーンを作成
# "sandbox-terraform.com" というドメイン名のホストゾーンを管理
resource "aws_route53_zone" "zone" {
  name = "sandbox-terraform.com"
}

# 作成した Route 53 ホストゾーンの ID を出力

output "route53_zone_id" {
  value = aws_route53_zone.zone.zone_id
}

[参考リポジトリ]

📌 実行

準備ができたらコマンド実行しましょう!

  1. terraform init
  2. terraform plan
  3. terraform apply

Terraform関連のコマンドについては以下の記事を参考にしてください ☺️

📌 NSレコードの設定

ドメインの発行にお名前どっとこむを利用された方は以下の記事も見てみてくださいね 👋

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?