Skip to content

Commit a087cb4

Browse files
author
Your Name
committed
add kr doc
1 parent 656dbce commit a087cb4

File tree

61 files changed

+4044
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+4044
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# AWS에서 수동으로 VPC와 서브넷 생성하기
2+
3+
## Introduction
4+
5+
이 연습에서는 AWS 콘솔에서 간단한 VPC-서브넷 인프라를 수동으로 구축하는 데 중점을 두겠습니다. 여기에는 VPC, 2개의 서브넷(공용 및 사설), 인터넷 게이트웨이 및 공용 라우트 테이블을 만드는 것이 포함됩니다. 이러한 요소를 수동으로 생성함으로써 인프라를 생성하고 관리하는 프로세스가 얼마나 복잡하고 어려운지 더 깊이 이해할 수 있습니다. 이를 통해 이러한 작업을 자동화하고 환경 전반에서 일관성을 유지하는 데 있어 코드형 인프라(IaC)의 이점을 이해할 수 있는 토대를 마련할 수 있습니다.
6+
## Desired Outcome
7+
8+
생성된 솔루션이 배포하는 내용은 아래와 같습니다.:
9+
10+
1. CIDR 블록이 `10.0.0.0/16`인 VPC.
11+
2. CIDR 블록이 `10.0.0.0/24`인 Public Subnet 하나.
12+
3. CIDR 블록이 `10.0.1.0/24`인 Private Subnet 하나.
13+
4. 인터넷 게이트웨이 하나.
14+
5. 인터넷 게이트웨이에 대한 Route설정이 있는 Pblic Route Table 하나, Public Subnet과 Public Route Table 간의 올바른 연결.
15+
16+
## Step-by-Step Guide
17+
18+
1. AWS 콘솔에 로그인합니다.
19+
2. VPC 대시보드로 이동합니다.
20+
3. "내 VPC"를 클릭한 다음 "VPC 생성"을 클릭합니다.
21+
4. 이름 태그와 CIDR 블록 `10.0.0.0/16`을 입력한 후 "생성"을 클릭합니다.
22+
5. VPC 대시보드로 돌아가서 "서브넷"을 클릭합니다.
23+
6. "서브넷 생성"을 클릭합니다.
24+
7. 이름 태그를 입력하고 방금 생성한 VPC를 선택한 후 CIDR 블록 `10.0.0.0/24`를 입력해 Public Subnet을 생성합니다.
25+
8. CIDR 블록 `10.0.1.0/24`로 이 과정을 반복하여 Private Subnet을 생성합니다.
26+
9. 9. VPC 대시보드로 돌아가서 "인터넷 게이트웨이"를 클릭합니다.
27+
10. "인터넷 게이트웨이 생성"을 클릭하고 이름 태그를 지정한 다음 "생성"을 클릭합니다.
28+
11. 방금 생성한 인터넷 게이트웨이를 선택하고 "작업"을 클릭한 다음 "VPC에 연결"을 클릭하고 VPC를 선택합니다.
29+
12. VPC 대시보드로 돌아가서 "라우팅 테이블"을 클릭합니다.
30+
13. "라우팅 테이블 만들기"를 클릭하고 이름 태그를 입력한 후 VPC를 선택한 다음 "만들기"를 클릭합니다.
31+
14. 방금 생성한 라우팅 테이블을 선택하고 "라우팅" 탭을 클릭한 다음 "라우팅 편집"을 클릭합니다.
32+
15. "라우팅 추가"를 클릭하고 목적지에 `0.0.0.0/0`을 입력하고 대상에 생성한 인터넷 게이트웨이를 선택한 다음 "라우팅 저장"을 클릭합니다.
33+
16. "서브넷 연결" 탭을 클릭한 다음 "서브넷 연결 편집"을 클릭합니다.
34+
17. Public Subnet을 선택한 다음 "저장"을 클릭합니다.
35+
36+
37+
## 연습 종료!
38+
39+
이 어려운 연습을 성공적으로 완료하신 것을 축하드립니다! AWS 콘솔에서 VPC 서브넷 인프라를 수동으로 구축했으며, 이 실습 경험을 통해 인프라 생성 및 관리의 프로세스와 복잡성에 대한 귀중한 인사이트를 얻으셨습니다. 이 실습을 통해 이러한 작업을 자동화하고 환경 전반에서 일관성을 유지하는 데 있어 코드형 인프라(IaC)의 이점을 이해하는 데 도움이 되셨기를 바랍니다.
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# Creating VPCs and Subnets with Terraform and IaC
2+
3+
## Introduction
4+
5+
In this exercise, we will walk through the process of creating a basic infrastructure on AWS using Terraform, an open-source Infrastructure as Code (IaC) tool. Specifically, we'll create a Virtual Private Cloud (VPC) with two subnets, a public and a private one. We will also create an Internet gateway and a route table, which will be associated with our public subnet. This setup mimics a typical cloud infrastructure configuration, separating resources into public and private subnets for improved security and control.
6+
7+
## Desired Outcome
8+
9+
If you wish to give it a shot before looking into the detailed step-by-step and the solution videos, here is an overview of what the created solution should deploy:
10+
11+
1. A VPC with a CIDR block of `10.0.0.0/16`.
12+
2. One public subnet with a CIDR block of `10.0.0.0/24`.
13+
3. One private subnet with a CIDR block of `10.0.1.0/24`.
14+
4. One Internet Gateway.
15+
5. One public route table with a route to the Internet Gateway, and the correct association between the public subnet and the public route table.
16+
17+
### Useful Resources
18+
19+
- AWS Terraform Provider: [https://registry.terraform.io/providers/hashicorp/aws](https://registry.terraform.io/providers/hashicorp/aws)
20+
21+
## Step-by-Step Guide
22+
23+
1. Begin by initializing your Terraform configuration with the `terraform` block. This block sets up the necessary details regarding the providers that will be used in your configuration. In this case, the AWS provider is required.
24+
25+
```
26+
terraform {
27+
required_providers {
28+
aws = {
29+
source = "hashicorp/aws"
30+
version = "~> 5.0"
31+
}
32+
}
33+
}
34+
```
35+
36+
2. Next, set up your AWS provider with the `provider` block. Here, you need to specify the region in which your resources will be created.
37+
38+
```
39+
provider "aws" {
40+
region = "eu-west-1"
41+
}
42+
```
43+
44+
3. Create a VPC using the `aws_vpc` resource. You need to specify a CIDR block for your VPC, as well as the `Name` tag with the value `Terraform VPC`.
45+
46+
```
47+
resource "aws_vpc" "demo_vpc" {
48+
cidr_block = "10.0.0.0/16"
49+
50+
tags = {
51+
Name = "Terraform VPC"
52+
}
53+
}
54+
```
55+
56+
4. Then, create two subnets within this VPC using the `aws_subnet` resource. Make sure to reference your VPC ID and set an appropriate CIDR block for each subnet.
57+
58+
```
59+
resource "aws_subnet" "public_subnet" {
60+
vpc_id = aws_vpc.demo_vpc.id
61+
cidr_block = "10.0.0.0/24"
62+
}
63+
64+
resource "aws_subnet" "private_subnet" {
65+
vpc_id = aws_vpc.demo_vpc.id
66+
cidr_block = "10.0.1.0/24"
67+
}
68+
```
69+
70+
5. Next, create an Internet gateway and attach it to your VPC with the `aws_internet_gateway` resource.
71+
72+
```
73+
resource "aws_internet_gateway" "igw" {
74+
vpc_id = aws_vpc.demo_vpc.id
75+
}
76+
```
77+
78+
6. Create a route table for your public subnet using the `aws_route_table` resource. This table will direct all traffic (`0.0.0.0/0`) to the Internet gateway.
79+
80+
```
81+
resource "aws_route_table" "public_rtb" {
82+
vpc_id = aws_vpc.demo_vpc.id
83+
84+
route {
85+
cidr_block = "0.0.0.0/0"
86+
gateway_id = aws_internet_gateway.igw.id
87+
}
88+
}
89+
```
90+
91+
7. Finally, associate the route table with your public subnet using the `aws_route_table_association` resource.
92+
93+
```
94+
resource "aws_route_table_association" "public_subnet" {
95+
subnet_id = aws_subnet.public_subnet.id
96+
route_table_id = aws_route_table.public_rtb.id
97+
}
98+
```
99+
100+
## Congratulations on Completing the Exercise!
101+
102+
Well done on successfully creating a basic infrastructure on AWS using Terraform. You've shown great understanding of Infrastructure as Code (IaC) and how to use Terraform to create and manage a VPC with subnets and Internet gateway on AWS. Keep up the good work and continue to expand your knowledge in this area. You're doing fantastic!
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Understanding the Different Terraform Stages
2+
3+
## Introduction
4+
5+
In this exercise, we aim to learn about the different stages of Terraform. We'll go through the process of initializing our working directory, planning and applying our configuration, and finally, destroying the infrastructure when it's no longer needed. This hands-on experience will provide an understanding of the practical benefits and the lifecycle of IAC.
6+
7+
## Step-by-Step Guide
8+
9+
Make sure you are in the `01-benefits-iac`directory and run the following commands, always taking a break to analyze and understand the output of the commands.
10+
11+
1. Use the `terraform init` command to initialize your working directory. This command prepares your directory for other Terraform commands and ensures that Terraform has everything it needs to run.
12+
2. Use `terraform plan` to create an execution plan. This command determines what actions are necessary to achieve the desired state specified in your configuration files.
13+
3. Once you're satisfied with the plan, apply it using `terraform apply`. This command will make the necessary changes to reach the desired state of your configuration.
14+
4. When you no longer need the infrastructure, you can use `terraform destroy` to remove all resources created by your Terraform configuration. This will also clean up the state.
15+
16+
## Congratulations on Completing the Exercise!
17+
18+
Great job on completing this exercise! You've now gained hands-on experience with the different stages of Terraform and have a better understanding of Infrastructure as Code. Keep up the good work!

KR_exercises/exercise04-hcl.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Overview of the Hashicorp Configuration Language (HCL)
2+
3+
## Introduction
4+
5+
This exercise is focused on exploring the syntax of the HashiCorp Configuration Language (HCL). We will delve into how to declare providers, define resource and data blocks, use variables and outputs, create local blocks, and include modules. This exercise aims to give a comprehensive understanding of how to use HCL in configuring and managing your infrastructure, but don't worry if there are points which are not clear. We will cover all of them in detail throughout the course!
6+
7+
## Desired Outcome
8+
9+
If you wish to give it a shot before looking into the detailed step-by-step and the solution videos, here is an overview of what the created solution should deploy. Check the "Useful Resources" section below for the HCL syntax documentation so that you can check the correct syntax for each block.
10+
11+
1. A declaration of required providers, specifically the AWS provider from HashiCorp.
12+
2. A `resource` block defining an AWS S3 bucket.
13+
3. A `data` block for an externally managed AWS S3 bucket.
14+
4. A variable named `bucket_name`, which is used in the created `resource` block to define the bucket's name.
15+
5. An `output` block that outputs the ID of the managed AWS S3 bucket.
16+
6. A `locals` block defining a local variable named `local_example`.
17+
7. A module block that includes a module located in the `./module-example` directory.
18+
19+
### Useful Resources
20+
21+
- [https://developer.hashicorp.com/terraform/language/syntax](https://developer.hashicorp.com/terraform/language/syntax)
22+
23+
## Step-by-Step Guide
24+
25+
1. Start by declaring your required providers. In this case, we are using the AWS provider, version `5.37.0`, sourced from HashiCorp. This block tells Terraform where to fetch the provider.
26+
27+
```
28+
terraform {
29+
required_providers {
30+
aws = {
31+
source = "hashicorp/aws"
32+
version = "~> 5.0"
33+
}
34+
}
35+
}
36+
```
37+
38+
2. Next, define a resource block for an AWS S3 bucket that you want to manage with this Terraform script. The `bucket` argument is set to a variable which we will define later.
39+
40+
```
41+
resource "aws_s3_bucket" "my_bucket" {
42+
bucket = var.bucket_name
43+
}
44+
```
45+
46+
3. Define a data block for an AWS S3 bucket that is managed outside of this Terraform script. This allows us to fetch and use data about this external bucket.
47+
48+
```
49+
data "aws_s3_bucket" "my_external_bucket" {
50+
bucket = "not-managed-by-us"
51+
}
52+
```
53+
54+
4. Define a `bucket_name` variable. This is used in the `resource` block to set the `bucket` argument.
55+
56+
```
57+
variable "bucket_name" {
58+
type = string
59+
description = "My variable used to set bucket name"
60+
default = "my_default_bucket_name"
61+
}
62+
```
63+
64+
5. Define an output block to output the ID of the bucket that we are managing with this Terraform script.
65+
66+
```
67+
output "bucket_id" {
68+
value = aws_s3_bucket.my_bucket.id
69+
}
70+
```
71+
72+
6. Define a local block to create a local variable. This variable is only available within this Terraform project.
73+
74+
```
75+
locals {
76+
local_example = "This is a local variable"
77+
}
78+
```
79+
80+
7. Lastly, use a module block to include a module that is located in the `./module-example` directory.
81+
82+
```
83+
module "my_module" {
84+
source = "./module-example"
85+
}
86+
```
87+
88+
## Congratulations on Completing the Exercise!
89+
90+
Great job on completing this exercise on HashiCorp Configuration Language (HCL)! You've now gained a broader understanding of how HCL declares providers, defines resource and data blocks, uses variables and outputs, creates local blocks, and includes modules. Keep up the good work and continue enhancing your skills!
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Our First Terraform Project
2+
3+
## Introduction
4+
5+
이 실습에서는 널리 사용되는 코드형 인프라 도구인 Terraform을 사용하여 첫 번째 프로젝트를 만들어 보겠습니다. Terraform 프로젝트 설정, AWS 공급자 구성, 리소스 이름 지정을 위한 임의 ID 생성, AWS S3 버킷 생성 및 버킷 이름 출력의 기본 사항을 다룰 것입니다. 이를 통해 Terraform을 사용하여 AWS 리소스를 관리하는 방법을 실습으로 소개합니다. 시작해 보겠습니다!
6+
7+
## Desired Outcome
8+
9+
자세한 단계별 내용과 솔루션 동영상을 살펴보기 전에 한 번 사용해 보고 싶다면 생성된 솔루션이 배포해야 하는 내용을 간략하게 살펴보세요:
10+
11+
1. 테라폼 버전을 설정하고 필요한 공급자(`random``AWS`)를 지정합니다.
12+
2. 코스에 사용 중인 지역을 사용하도록 AWS 공급자를 구성합니다.
13+
3. AWS S3 버킷 이름에 대한 임의 ID를 생성합니다.
14+
4. AWS S3 버킷을 생성합니다.
15+
5. 버킷 이름에 대한 출력 블록을 생성합니다.
16+
17+
### Useful Resources
18+
19+
- Terraform Random provider: [https://registry.terraform.io/providers/hashicorp/random/latest/docs](https://registry.terraform.io/providers/hashicorp/random/latest/docs)
20+
21+
## Step-by-Step Guide
22+
23+
1. '테라폼' 블록에서 필요한 테라폼 버전(`~> 1.7`)을 지정합니다. 또한 필요한 공급자와 해당 버전을 정의합니다. 이 경우, `aws` 공급자(`~> 5.0`)와 `random` 공급자(`~> 3.0`)가 필요합니다.
24+
25+
```
26+
terraform {
27+
required_version = "~> 1.7"
28+
required_providers {
29+
aws = {
30+
source = "hashicorp/aws"
31+
version = "~> 5.0"
32+
}
33+
random = {
34+
source = "hashicorp/random"
35+
version = "~> 3.0"
36+
}
37+
}
38+
}
39+
```
40+
41+
2. `provider` 블록을 사용하여 AWS 리전을 `"ap-northeast-2"`로 구성합니다.
42+
43+
```
44+
provider "aws" {
45+
region = "ap-northeast-2"
46+
}
47+
```
48+
49+
3. `"bucket_suffix"`라는 이름의 `random_id` 리소스를 `byte_length`가 `6`인 리소스로 생성합니다. 이 ID는 S3 버킷의 고유 이름을 만드는 데 사용됩니다.
50+
51+
```
52+
resource "random_id" "bucket_suffix" {
53+
byte_length = 6
54+
}
55+
```
56+
57+
4. `aws_s3_bucket` 리소스 이름을 `example_bucket`으로 생성하세요. 랜덤 ID를 `"example-bucket-"`에 추가하여 고유한 버킷 이름을 만들기 위해 인터폴레이션을 사용하세요.`
58+
59+
```
60+
resource "aws_s3_bucket" "example_bucket" {
61+
bucket = "example-bucket-${random_id.bucket_suffix.hex}"
62+
}
63+
```
64+
65+
5. 마지막으로 `output` 블록을 사용하여 생성된 버킷의 이름을 출력합니다.
66+
67+
```
68+
output "bucket_name" {
69+
value = aws_s3_bucket.example_bucket.bucket
70+
}
71+
```
72+
73+
6. 테라폼 구성을 작성한 후 터미널에서 다음 테라폼 CLI 명령을 실행합니다:
74+
- `terraform init`: 이 명령은 필요한 공급자 플러그인을 다운로드하여 Terraform 워크스페이스를 초기화합니다.
75+
- `terraform plan`: 이 명령은 실제로 변경하지 않고도 Terraform이 인프라에 어떤 변화를 가져올지 보여줍니다.
76+
- `terraform apply`: 이 명령은 변경 사항을 적용하여 인프라를 만듭니다.
77+
- `terraform destroy`: 인프라 생성이 완료되었으면 이 명령을 사용하여 Terraform 구성으로 생성된 모든 리소스를 제거하세요.
78+
79+
## Congratulations on Completing the Exercise!
80+
81+
이 연습을 잘 완료했습니다! 테라폼 여정에서 한 걸음 더 나아갔습니다. 계속 연습하고 기술을 향상시키세요. 새로운 도구나 기술을 익히려면 꾸준한 연습이 중요하다는 것을 기억하세요. 축하합니다!
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Working with the Terraform CLI
2+
3+
## Introduction
4+
5+
테라폼 명령줄 인터페이스(CLI)에 대한 이 실습에 오신 것을 환영합니다! 이 실습에서는 필수적인 Terraform 명령을 안내합니다. 파일의 유효성을 검사하고, 가독성을 높이기 위해 서식을 지정하고, 실행 계획을 만들고 적용하고, 상태를 관리하는 방법을 배우게 됩니다. 이 강력한 도구에 대해 자세히 알아보세요.
6+
7+
## Step-by-Step Guide
8+
9+
터미널에서 다음 명령을 실행하고 출력을 확인하세요. 각 명령에 대해 자세히 알아보려면 명령에 `-help` 플래그를 추가해 보세요!
10+
11+
- `terraform validate`: Terraform 파일의 구문을 확인하고 내부적으로 일관성이 있는지 확인하지만 리소스가 존재하는지 또는 공급자가 올바르게 구성되었는지 확인하지는 않습니다.
12+
- `terraform fmt`: Terraform 구성 파일을 표준 형식과 스타일로 자동 업데이트하여 일관성과 가독성을 향상시킵니다. 이 명령은 현재 작업 디렉터리에 있는 파일에 대해서만 작동하지만 `-recursive` 플래그를 추가하여 중첩된 디렉터리에 있는 `.tf` 파일의 형식을 지정할 수도 있습니다.
13+
- `terraform plan`: 테라폼 파일에 정의된 원하는 상태를 달성하기 위해 테라폼이 어떤 작업을 수행할지 보여주는 실행 계획을 생성합니다. 이 명령은 실제 리소스나 상태를 수정하지 않습니다.
14+
- `terraform plan -out <filename>`: `terraform plan`과 유사하지만 `terraform apply`에서 사용할 수 있는 파일에 실행 계획을 기록하여 계획된 작업이 정확하게 수행되도록 합니다.
15+
- `terraform apply`: 실행 계획을 적용하여 원하는 리소스 상태에 도달하기 위해 필요한 변경을 수행합니다. `-out` 옵션과 함께 `terraform plan`을 실행하는 경우 `terraform apply <파일 이름>`을 실행하여 실행 계획을 제공할 수 있습니다.
16+
- `terraform show`: 상태 또는 계획 파일에서 사람이 읽을 수 있는 출력을 제공합니다. 현재 상태를 검사하거나 `terraform plan` 명령으로 계획된 작업을 확인하는 데 사용됩니다.
17+
- `terraform state list`: 상태 파일에 있는 모든 리소스를 나열하여 상태를 관리하고 조작하는 데 유용합니다.
18+
- `terraform destroy`: 상태 파일에서 추적된 모든 리소스를 삭제합니다. 이 명령은 `terraform apply` 명령에 `-destroy` 플래그를 전달하는 것과 동일합니다.
19+
- `terraform -help`: 테라폼 명령에 대한 도움말 정보를 제공합니다. 일반적인 개요를 위해 단독으로 사용하거나 특정 명령에 추가하여 해당 명령에 대한 자세한 도움말을 얻을 수 있습니다.
20+
21+
## Congratulations on Completing the Exercise!
22+
23+
Terraform CLI에서 이 연습을 완료해 주셔서 감사합니다! 테라폼을 마스터하는 데 중요한 단계를 밟으셨으며, 이 지식이 향후 프로젝트에 도움이 되기를 바랍니다. 계속 열심히 하세요!

0 commit comments

Comments
 (0)