> For the complete documentation index, see [llms.txt](https://psedu.gitbook.io/cloudia/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://psedu.gitbook.io/cloudia/task-3-subnet.md).

# Task 3 Subnet 생성

Info

\-       Terraform VPC Subnet Example

\-       VPC CIDR 은 10.0.0.0/16

\-       Subnet CIDR 은 10.X.0.0/24

\-       Subnet 은 본인이 선택한 Region의 Availability Zone 수만큼 생성 (ex. us-east-1 -> 4 Availability Zones -> 4 Subnets)

\-       각 Availability Zone 별로 Public Subnet, Private Subnet 페어로 한개씩 존재하도록 생성

1\)    Subnet 실습을 진행하기 위해서 02-subnet 폴더로 경로 이동

\-       <mark style="color:blue;">cd ../02-subnet/</mark>

<figure><img src="/files/nOezd24z52l1xEp7VTzL" alt=""><figcaption></figcaption></figure>

2\)    업로드 된 폴더 02-subnet 하위 파일인subnet.tfvars 파일 실행

## &#x20;

3\)    subnet.tfvars 파일 확인 실행 환경에 맞게 변경

변수 설정

\- # subnet.tfvars 파일\
\
prefix              =       "user<mark style="background-color:red;">\*\*</mark>"\
region              =       "ap-northeast-2"\
vpc\_cidr            =       "10.<mark style="background-color:red;">\*\*</mark>.0.0/16"\
\
public\_subnets      =       \[\
&#x20;   {cidr = "10.<mark style="background-color:red;">\*\*</mark>.1.0/24", availability\_zone = "ap-northeast-2a"},\
&#x20;   {cidr = "10.<mark style="background-color:red;">\*\*</mark>.3.0/24", availability\_zone = "ap-northeast-2c"},\
&#x20;   ]\
\
private\_subnets = \[\
&#x20;   {cidr = "10.<mark style="background-color:red;">\*\*</mark>.11.0/24", availability\_zone = "ap-northeast-2a"},\
&#x20;   {cidr = "10.<mark style="background-color:red;">\*\*</mark>.13.0/24", availability\_zone = "ap-northeast-2c"},\
]\ <br>

\- Prefix는 알맞게 변경

\- Region 은 본인이 사용할 region 코드로 변경

\- Subnet의 Availability Zone 값은 Region에 맞게 변경

&#x20;

4\)    Init 명령으로 Terraform 수행을 위한 provider plugin 초기화 및 다운로드 수행

\- <mark style="color:blue;">terraform init</mark>

&#x20;

5\)    Plan 명령으로 Terraform 수행 전 실행 시뮬레이션 확인

\- <mark style="color:blue;">terraform plan --var-file=subnet.tfvars</mark>

&#x20;

6\)    Apply 명령으로 Terraform을 통한 Resource 생성 수행

\- <mark style="color:blue;">terraform apply --var-file=subnet.tfvars</mark>

&#x20;

7\)    선택한 Region에 VPC 및 Subnet 생성 내용 확인

&#x20;

8\)    Resource 삭제

\-       destroy

\-       Destroy 명령으로 생성된 VPC 삭제 수행

\-       <mark style="color:blue;">terraform destroy --var-file=subnet.tfvars</mark>

9\) 폴더 삭제

\-       Cloud9 왼쪽 메뉴에 02-subnet 폴더 우 클릭 후 Delete


---

# 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, and the optional `goal` query parameter:

```
GET https://psedu.gitbook.io/cloudia/task-3-subnet.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
