> For the complete documentation index, see [llms.txt](https://www.terraform-best-practices.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.terraform-best-practices.com/ja/examples/terraform/medium-size-infrastructure.md).

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

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

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

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

{% hint style="success" %}

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

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

##


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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/medium-size-infrastructure.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.
