You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: KR_exercises/exercise27-creating_count.md
+15-15Lines changed: 15 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,29 +1,29 @@
1
-
# Creating Multiple Subnets with the `count` Argument
1
+
# `count` 인수를 사용하여 여러 서브넷 만들기
2
2
3
3
## Introduction
4
4
5
-
In this exercise, we'll delve into the creation of multiple subnets using the `count`argument in Terraform. This exercise is designed to help you understand how to efficiently manage resources in Terraform and avoid code duplication. You'll learn how to define a local variable, create a Virtual Private Cloud (VPC), and use the `count`meta-argument to create multiple subnets. You'll also learn how to use the `tags`attribute to assign unique names to the subnets using the `count.index`value and make the count of subnets configurable by creating a new `subnet_count` variable. This exercise will provide a step-by-step guide on how to achieve these tasks.
5
+
이 연습에서는 Terraform에서 `count`인수를 사용하여 여러 서브넷을 생성하는 방법을 살펴봅니다. 이 연습은 Terraform에서 리소스를 효율적으로 관리하고 코드 중복을 피하는 방법을 이해하는 데 도움이 되도록 설계되었습니다. 로컬 변수를 정의하고, 가상 프라이빗 클라우드(VPC)를 생성하고, `count`메타 인수를 사용하여 여러 서브넷을 생성하는 방법을 배우게 됩니다. 또한 `tags`속성을 사용하여 `count.index`값을 사용하여 서브넷에 고유 이름을 할당하는 방법과 새로운 `subnet_count` 변수를 생성하여 서브넷 수를 구성할 수 있게 만드는 방법도 배우게 됩니다. 이 연습에서는 이러한 작업을 수행하는 방법에 대한 단계별 가이드를 제공합니다.
6
6
7
7
## Desired Outcome
8
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:
9
+
자세한 단계별 내용과 솔루션 동영상을 살펴보기 전에 한 번 사용해 보고 싶다면 생성된 솔루션이 배포해야 하는 내용을 간략하게 살펴보세요:
10
10
11
-
1.Create a Virtual Private Cloud (VPC) with a CIDR block set to `10.0.0.0/16`. The VPC is tagged with the `Project` and `Name` tags that hold the value of a newly created `local.project` local variable.
12
-
2.Leverage the `count`meta-argument to create multiple subnets, reducing code duplication and making extension easier.
13
-
3.Assign unique names to the subnets using the `count.index`value and the `tags`attribute.
14
-
4.Create a new variable `subnet_count` to replace the hard-coded count value in the `aws_subnet` resource, thereby making the count of subnets configurable.
11
+
1. CIDR 블록이 `10.0.0.0/16`으로 설정된 가상 프라이빗 클라우드(VPC)를 생성합니다. VPC에는 새로 생성된 `local.project` 로컬 변수의 값을 담고 있는 `Project` 및 `Name` 태그가 지정됩니다.
12
+
2.`count`메타 인수를 활용하여 여러 개의 서브넷을 생성하면 코드 중복을 줄이고 확장을 더 쉽게 할 수 있습니다.
13
+
3.`count.index`값과 `tags`속성을 사용하여 서브넷에 고유한 이름을 할당합니다.
14
+
4.서브넷 개수를 구성할 수 있도록 `aws_subnet` 리소스에 하드코딩된 개수 값을 대체하는 새 변수 `subnet_count`를 생성합니다.
15
15
16
16
## Step-by-Step Guide
17
17
18
-
1.Create a new `networking.tf`file, and define a local variable to store the `project` we are working on. This will help to keep your code neat and reusable. For this exercise, we have a project variable with the value `11-multiple-resources`.
18
+
1.새 `networking.tf`파일을 만들고, 작업 중인 `project`를 저장할 로컬 변수를 정의합니다. 이렇게 하면 코드를 깔끔하고 재사용 가능하게 유지하는 데 도움이 됩니다. 이 연습에서는 `11-multiple-resources` 값을 가진 프로젝트 변수가 있습니다.
19
19
20
20
```
21
21
locals {
22
22
project = "11-multiple-resources"
23
23
}
24
24
```
25
25
26
-
2. Create a Virtual Private Cloud (VPC) by defining a resource of type `aws_vpc`, and set the CIDR block to `10.0.0.0/16`. Add two tags, `Project` and `Name`, that hold the value stored in the `local.project` local variable.
26
+
2. `aws_vpc` 유형의 리소스를 정의하여 가상 프라이빗 클라우드(VPC)를 생성하고 CIDR 블록을 `10.0.0.0/16`으로 설정합니다. `local.project` 로컬 변수에 저장된 값을 저장하는 두 개의 태그, `Project`와 `Name`을 추가합니다.
27
27
28
28
```
29
29
resource "aws_vpc" "main" {
@@ -36,7 +36,7 @@ If you wish to give it a shot before looking into the detailed step-by-step and
36
36
}
37
37
```
38
38
39
-
3. Create two subnets by adding two `aws_subnet` resources.
39
+
3. 두 개의 `aws_subnet` 리소스를 추가하여 두 개의 서브넷을 생성합니다.
40
40
41
41
```
42
42
resource "aws_subnet" "subnet1" {
@@ -60,7 +60,7 @@ If you wish to give it a shot before looking into the detailed step-by-step and
60
60
}
61
61
```
62
62
63
-
4. While this works, it has a lot of duplication, and it’s not easy to extend. Let’s try to use the `count` meta-argument to create multiple subnets. Remove the subnet2 entry, and change the subnet1 to include a `count = 2` meta-argument. Rename the resource to `aws_subnet.main` instead of `aws_subnet.subnet1`.
63
+
4. 이 방법은 작동하지만 중복이 많고 확장하기가 쉽지 않습니다. `count` 메타 인수를 사용하여 여러 서브넷을 생성해 보겠습니다. subnet2 항목을 제거하고 subnet1에 `count = 2` 메타 인수를 포함하도록 변경합니다. 리소스 이름을 `aws_subnet.subnet1` 대신 `aws_subnet.main`으로 변경합니다.
64
64
65
65
```
66
66
resource "aws_subnet" "main" {
@@ -76,8 +76,8 @@ If you wish to give it a shot before looking into the detailed step-by-step and
76
76
77
77
```
78
78
79
-
5. Try to apply this configuration. Does it work? Which error do we get back?
80
-
6. For the subnets to be successfully created, we must ensure that the CIDR blocks are not overlapping with each other. We can leverage the `count.index` value that becomes available whenever we use the `count` meta-argument. Update the `cidr_block` of the subnet to `"10.0.${count.index}.0/24"`, where `${count.index}` is the index of the current iteration, allowing for a unique CIDR block for each subnet. The `tags` attribute is used to assign names to the subnets, and you can also leverage `count.index` there to uniquely identify each subnet.
79
+
5. 이 구성을 적용해 보세요. 작동하나요? 어떤 오류가 발생하나요?
80
+
6. 서브넷을 성공적으로 생성하려면 CIDR 블록이 서로 겹치지 않는지 확인해야 합니다. `count` 메타 인수를 사용할 때마다 사용할 수 있는 `count.index` 값을 활용할 수 있습니다. 서브넷의 `cidr_block`을 `"10.0.${count.index}.0/24"`로 업데이트합니다. 여기서 `${count.index}`는 현재 반복의 인덱스이므로 각 서브넷에 고유한 CIDR 블록을 사용할 수 있습니다. `tags` 속성은 서브넷에 이름을 할당하는 데 사용되며, `count.index`를 활용하여 각 서브넷을 고유하게 식별할 수도 있습니다.
81
81
82
82
```
83
83
resource "aws_subnet" "main" {
@@ -92,7 +92,7 @@ If you wish to give it a shot before looking into the detailed step-by-step and
92
92
}
93
93
```
94
94
95
-
7. Last but not least, create a new variable `subnet_count` and migrate away from the hard-coded count value in the `aws_subnet` resource.
@@ -114,4 +114,4 @@ If you wish to give it a shot before looking into the detailed step-by-step and
114
114
115
115
## Congratulations on Completing the Exercise!
116
116
117
-
Great job on completing this exercise! You've taken a significant step in mastering Terraform by learning how to create multiple resources using the `count` argument. Your understanding of how to efficiently manage resources and avoid code duplication has improved. Keep up the good work!
117
+
이 연습을 완료해 주셔서 감사합니다! `count` 인수를 사용하여 여러 리소스를 생성하는 방법을 배움으로써 테라폼을 마스터하는 데 중요한 한 걸음을 내디뎠습니다. 리소스를 효율적으로 관리하고 코드 중복을 피하는 방법에 대한 이해도가 향상되었습니다. 계속 열심히 공부하세요!
Copy file name to clipboardExpand all lines: KR_exercises/exercise28-referencing_count.md
+14-14Lines changed: 14 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,21 +1,21 @@
1
-
# Referencing Resources with `count`Arguments
1
+
# `count`인수를 사용하여 리소스 참조하기
2
2
3
3
## Introduction
4
4
5
-
In this exercise, we will explore how to reference resources created with `count`arguments in Terraform. We will create a new variable to determine the number of EC2 instances to be created, leverage a data source to read an Ubuntu AWS AMI, and distribute these instances across different subnets. This exercise provides practical experience with the use of variables, data sources, and resource creation in Terraform.
5
+
이 실습에서는 Terraform에서 `count`인자로 생성된 리소스를 참조하는 방법을 살펴보겠습니다. 생성할 EC2 인스턴스 수를 결정하는 새 변수를 만들고, 데이터 소스를 활용하여 Ubuntu AWS AMI를 읽고, 이러한 인스턴스를 여러 서브넷에 배포합니다. 이 실습은 Terraform에서 변수, 데이터 소스 및 리소스 생성에 대한 실질적인 경험을 제공합니다.
6
6
7
7
## Desired Outcome
8
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:
9
+
자세한 단계별 내용과 솔루션 동영상을 살펴보기 전에 한 번 사용해 보고 싶다면 생성된 솔루션이 배포해야 하는 내용을 간략하게 살펴보세요:
10
10
11
-
1.Create a new variable, `ec2_instance_count`, of type number and with a default value of 1.
12
-
2.Create a data source that reads an Ubuntu AWS AMI.
13
-
3.Create an `aws_instance` resource that uses the `ec2_instance_count` variable to create multiple EC2 instances.
14
-
4.Distribute the EC2 instances equally across all the subnets we have created in the previous exercise.
11
+
1.숫자 유형이고 기본값이 1인 새 변수 `ec2_instance_count`를 생성합니다.
12
+
2.우분투 AWS AMI를 읽는 데이터 소스를 생성합니다.
13
+
3.`ec2_instance_count` 변수를 사용하여 여러 EC2 인스턴스를 생성하는 `aws_instance` 리소스를 생성합니다.
14
+
4.이전 연습에서 생성한 모든 서브넷에 EC2 인스턴스를 균등하게 배포합니다.
15
15
16
16
## Step-by-Step Guide
17
17
18
-
1.Create a new variable,`ec2_instance_count`, which is of type number and has a default value of 1.
18
+
1.숫자 유형이고 기본값이 1인`ec2_instance_count`라는 변수를 새로 만듭니다.
19
19
20
20
```
21
21
variable "ec2_instance_count" {
@@ -24,7 +24,7 @@ If you wish to give it a shot before looking into the detailed step-by-step and
24
24
}
25
25
```
26
26
27
-
2. Create a data source that reads an Ubuntu AWS AMI as we have defined in previous exercises, and an `aws_instance` resource that leverages the `ec2_instance_count` variable to create multiple EC2 instances. Run a `terraform plan` command to inspect if there will be any issues.
27
+
2. 이전 연습에서 정의한 대로 Ubuntu AWS AMI를 읽는 데이터 소스를 생성하고, `ec2_instance_count` 변수를 활용하여 여러 EC2 인스턴스를 생성하는 `aws_instance` 리소스를 생성합니다. `terraform plan` 명령을 실행하여 문제가 있는지 검사합니다.
28
28
29
29
```
30
30
data "aws_ami" "ubuntu" {
@@ -54,7 +54,7 @@ If you wish to give it a shot before looking into the detailed step-by-step and
54
54
}
55
55
```
56
56
57
-
3. Set the subnet ID to be that of the first subnet created in our `aws_subnet.main` resource. Run a `terraform apply` command, confirm the changes, and make sure that it is deployed in the correct subnet.
57
+
3. 서브넷 ID를 `aws_subnet.main` 리소스에서 생성한 첫 번째 서브넷의 ID로 설정합니다. `terraform apply` 명령을 실행하고 변경 사항을 확인한 후 올바른 서브넷에 배포되었는지 확인합니다.
58
58
59
59
```
60
60
data "aws_ami" "ubuntu" {
@@ -85,7 +85,7 @@ If you wish to give it a shot before looking into the detailed step-by-step and
85
85
}
86
86
```
87
87
88
-
4. Let’s now create four EC2 instances. Create a `terraform.tfvars` file, and set the `ec2_instance_count` variable to 4. We also want to distribute these EC2 instances equally across the subnets we have created. How can we achieve this with what we have learned so far? (**Hint:** We can dynamically calculate the index that we use to access the subnet.)
88
+
4. 이제 4개의 EC2 인스턴스를 생성해 보겠습니다. `terraform.tfvars` 파일을 생성하고 `ec2_instance_count` 변수를 4로 설정합니다. 또한 생성한 서브넷에 이러한 EC2 인스턴스를 균등하게 배포하고 싶습니다. 지금까지 배운 것을 가지고 어떻게 이를 달성할 수 있을까요? (**Hint:** 서브넷에 액세스하는 데 사용하는 인덱스를 동적으로 계산할 수 있습니다.)
89
89
90
90
```
91
91
resource "aws_instance" "from_count" {
@@ -103,9 +103,9 @@ If you wish to give it a shot before looking into the detailed step-by-step and
103
103
}
104
104
```
105
105
106
-
5. Run `terraform apply` and inspect the changes.
107
-
6. Make sure to destroy the resources after you complete all the steps!
106
+
5. `terraform apply`을 실행하고 변경 사항을 확인합니다.
107
+
6. 모든 단계를 완료한 후에는 반드시 리소스를 삭제하세요!
108
108
109
109
## Congratulations on Completing the Exercise!
110
110
111
-
Great job! You've successfully completed this exercise on referencing resources with count arguments in Terraform. You've learned how to use variables, data sources, and resource creation to manage and distribute multiple EC2 instances across different subnets. Keep up the good work!
111
+
수고하셨습니다! Terraform에서 카운트 인수를 사용하여 리소스를 참조하는 이 연습을 성공적으로 완료하셨습니다. 변수, 데이터 소스 및 리소스 생성을 사용하여 여러 서브넷에 걸쳐 여러 EC2 인스턴스를 관리하고 배포하는 방법을 배웠습니다. 계속 열심히 공부하세요!
Copy file name to clipboardExpand all lines: KR_exercises/exercise29-multiple_ec2_list_input.md
+12-12Lines changed: 12 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,21 +1,21 @@
1
-
# Creating EC2 Instances based on a List Variable
1
+
# List 변수를 기반으로 EC2 인스턴스 생성하기
2
2
3
3
## Introduction
4
4
5
-
In this exercise, we will learn how to create multiple EC2 instances in Terraform based on a list of configurations. We will define the desired EC2 instance properties such as instance type and AMI in a list variable and then use Terraform to create these instances. This exercise will provide you with practical experience in handling complex configurations and manipulating data sources and resources in Terraform.
5
+
이 실습에서는 구성 목록을 기반으로 Terraform에서 여러 EC2 인스턴스를 생성하는 방법을 배웁니다. 인스턴스 유형 및 AMI와 같은 원하는 EC2 인스턴스 속성을 목록 변수에 정의한 다음 Terraform을 사용하여 이러한 인스턴스를 생성합니다. 이 실습을 통해 복잡한 구성을 처리하고 Terraform에서 데이터 소스 및 리소스를 조작하는 실무 경험을 쌓을 수 있습니다.
6
6
7
7
## Desired Outcome
8
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:
9
+
자세한 단계별 내용과 솔루션 동영상을 살펴보기 전에 한 번 사용해 보고 싶은 경우, 생성된 솔루션이 배포해야 하는 내용을 간략하게 살펴보세요:
10
10
11
-
1.Create a list of EC2 instances based on a specified configuration list variable.
12
-
2.The configuration list includes details such as the instance type and AMI.
13
-
3.The AMI property should receive a user-friendly value, such as `"ubuntu"`, and retrieve the AMI ID based on a data source.
14
-
4.The instances are distributed across different subnets.
11
+
1.지정된 구성 목록 변수를 기반으로 EC2 인스턴스 목록을 생성합니다.
12
+
2.구성 목록에는 인스턴스 유형 및 AMI와 같은 세부 정보가 포함됩니다.
13
+
3. AMI 속성은 `"ubuntu"`와 같은 사용자 친화적인 값을 수신하고 데이터 소스를 기반으로 AMI ID를 검색해야 합니다.
14
+
4.인스턴스는 여러 서브넷에 분산되어 있습니다.
15
15
16
16
## Step-by-Step Guide
17
17
18
-
1.Create a new variable `ec2_instance_config_list` under the file `variables.tf`. This variable is of type list, which contains objects with specific keys. The keys include `instance_type`and`ami`, both of type string. The default value for this variable is an empty list.
18
+
1.`variables.tf` 파일 아래에 새 변수 `ec2_instance_config_list`를 생성합니다. 이 변수는 특정 키를 가진 객체를 포함하는 목록 유형입니다. 키는 모두 문자열 유형인 `instance_type`및`ami`를 포함합니다. 이 변수의 기본값은 빈 목록입니다.
19
19
20
20
```
21
21
variable "ec2_instance_config_list" {
@@ -28,7 +28,7 @@ If you wish to give it a shot before looking into the detailed step-by-step and
28
28
}
29
29
```
30
30
31
-
2. Add an entry for the variable in the `terraform.tfvars` file. The list should contain one object with the `instance_type` set to `"t2.micro"` (or whatever type falls under your free tier), and the `ami` set to `"ubuntu"`. Also make sure to set the `ec2_instance_count` variable to `0` so that we do not create any additional ec2 instances.
31
+
2. `terraform.tfvars` 파일에 변수에 대한 항목을 추가합니다. 목록에는 `instance_type`이 `"t2.micro"`(또는 무료 티어에 해당하는 유형)로 설정되고 `ami`가 `"ubuntu"`로 설정된 객체 하나가 포함되어야 합니다. 또한 추가 ec2 인스턴스가 생성되지 않도록 `ec2_instance_count` 변수를 `0`으로 설정해야 합니다.
32
32
33
33
```
34
34
ec2_instance_config_list = [
@@ -39,7 +39,7 @@ If you wish to give it a shot before looking into the detailed step-by-step and
39
39
]
40
40
```
41
41
42
-
3. In the `compute.tf` file, add a new resource `aws_instance.from_list` which iterates over the list by using a `count = length(var.ec2_instance_config_list)` meta-argument. Retrieve the information from the configuration object. How can we use the `ubuntu` value to get the AMI ID? (Hint: Try to use a local map to store the AMI ID coming from the data source).
42
+
3. `compute.tf` 파일에서 `count = length(var.ec2_instance_config_list)` 메타 인수를 사용하여 목록을 반복하는 새 리소스 `aws_instance.from_list`를 추가합니다. 구성 개체에서 정보를 검색합니다. `ubuntu` 값을 사용하여 AMI ID를 가져오려면 어떻게 해야 하나요? (힌트: 로컬 맵을 사용하여 데이터 소스에서 오는 AMI ID를 저장하세요).
43
43
44
44
```
45
45
locals {
@@ -78,8 +78,8 @@ If you wish to give it a shot before looking into the detailed step-by-step and
78
78
}
79
79
```
80
80
81
-
4. Run a `terraform plan` and inspect the proposed changes.
81
+
4. `terraform plan`을 실행하고 제안된 변경 사항을 검사합니다.
82
82
83
83
## Congratulations on Completing the Exercise!
84
84
85
-
Well done on completing this exercise! You've successfully learned how to create multiple EC2 instances based on a list in Terraform. This is a significant step forward in managing complex configurations and manipulating data sources and resources in Terraform. Keep up the good work!
85
+
이 연습을 완료했습니다! 이제 Terraform에서 목록을 기반으로 여러 EC2 인스턴스를 생성하는 방법을 성공적으로 배웠습니다. 이는 Terraform에서 복잡한 구성을 관리하고 데이터 소스 및 리소스를 조작하는 데 있어 중요한 진전입니다. 계속 열심히 하세요!
0 commit comments