# Terraformを使用した大規模インフラ

ソース: <https://github.com/antonbabenko/terraform-best-practices/tree/master/examples/large-terraform>

この例は、大規模インフラストラクチャ向けのTerraform構成を整理するコード例で、以下の内容を使用しています。

* 2つのAWSアカウント
* 2つのリージョン
* 2つの独立した環境（プロダクションとステージング、共有は一切なし）。各環境は異なるAWSアカウント内にあり、2つのリージョン間でリソースを展開する
* 各環境は、[Terraform Registry](https://registry.terraform.io/)から取得した既製のインフラモジュール（`alb`）の異なるバージョンを使用
* 各環境は、ローカルディレクトリから取得される内部モジュール`modules/network`の同じバージョンを使用

{% hint style="info" %}
ここで説明するような大規模プロジェクトでは、Terragruntを使用する利点が非常に明確になります。[Terragruntのコード構造例](/ja/examples/terragrunt.md)をご覧ください。
{% endhint %}

{% hint style="success" %}

* インフラが論理的に分離されているプロジェクトに最適（AWSアカウントが分かれている場合）
* AWSアカウント間で共有されるリソースを変更する必要がない場合に適している（一つの環境＝一つのAWSアカウント＝一つの状態ファイル）
* 環境間での変更のオーケストレーションが不要な場合に適している
* 環境ごとにインフラリソースが異なり、一般化できない場合に適している（例：ある環境またはリージョンに存在しないリソースがある場合）
  {% endhint %}

{% hint style="warning" %}
プロジェクトが成長するにつれ、これらの環境を互いに最新の状態に保つことが難しくなります。繰り返し行われるタスクには、既製または内部のインフラモジュールの使用を検討してください。
{% endhint %}

##


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.terraform-best-practices.com/ja/examples/terraform/large-size-infrastructure-with-terraform.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
