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
In this exercise, we will explore the concept of "tainting" in Terraform, which is a way to mark a resource for recreation in the next plan. We'll learn how to use the `terraform taint`and`terraform untaint`commands to control the lifecycle of our resources. This will involve creating and managing an S3 bucket and a VPC, and observing how tainting these resources affects their associated resources. We'll also delve into how to handle potential issues that can arise from the recreation of tainted resources. This exercise will enhance your understanding of resource dependencies and lifecycle management in Terraform.
5
+
이 연습에서는 Terraform에서 "tainting" 개념을 탐색합니다. 이는 리소스를 다음 계획에서 다시 생성하기 위해 표시하는 방법입니다. `terraform taint`및`terraform untaint`명령을 사용하여 리소스의 라이프사이클을 제어하는 방법을 배우게 될 것입니다. 이를 위해 S3 버킷과 VPC를 생성하고 관리하며, 이러한 리소스에 대한 tainting이 관련 리소스에 어떤 영향을 미치는지 관찰할 것입니다. 또한 tainted 리소스의 재생성으로 인해 발생할 수 있는 잠재적인 문제를 처리하는 방법에 대해 알아볼 것입니다. 이 연습을 통해 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
+
11
+
12
+
1. S3 버킷을 생성합니다.
13
+
2. CLI를 통해 버킷을 tainted 상태로 표시하고 untaint 상태로 변경합니다.
14
+
3. 올바른 CIDR 블록을 가진 VPC와 해당 VPC 내의 서브넷을 생성합니다.
15
+
4. VPC를 tainted 상태로 표시하고 해당 VPC의 재생성이 서브넷의 재생성을 트리거하는지 확인합니다.
16
+
5.`aws_s3_bucket_public_access_block` 리소스를 생성하고, `block_public_acls` 및 `block_public_policy` 옵션을 false로 설정합니다.
17
+
6. S3 버킷을 tainted 상태로 표시하고, 해당 버킷의 재생성이 `aws_s3_bucket_public_access_block` 리소스의 재생성을 **트리거하지 않는지** 확인합니다. 이 동작의 결과는 무엇인가요? 라이프사이클 메타-인자를 사용하여 이 문제를 해결할 수 있을까요?
10
18
11
-
1. Create an S3 bucket.
12
-
2. Taint and untaint the bucket via the CLI.
13
-
3. Create a VPC and a subnet within the created VPC with correct CIDR blocks.
14
-
4. Taint the VPC and inspect how its recreation triggers the recreation of the subnet.
15
-
5. Create an `aws_s3_bucket_public_access_block` resource, and set the options `block_public_acls` and `block_public_policy` to false.
16
-
6. Taint the S3 bucket and inspect how its recreation **does not** trigger the recreation of the `aws_s3_bucket_public_access_block` resource. What are the consequences of this behavior? Can we tackle this using lifecycle meta-arguments?
17
19
18
20
## Step-by-Step Guide
19
21
20
-
1. Create a new file named `taint.tf` and create an S3 bucket within the file. Run `terraform apply` to create the bucket.
22
+
23
+
1.`taint.tf`라는 새 파일을 생성하고 파일 내에 S3 버킷을 생성합니다. `terraform apply`를 실행하여 버킷을 생성합니다.
24
+
21
25
22
26
```
23
27
resource "aws_s3_bucket" "tainted" {
24
28
bucket = "my-tainted-bucket-19384981jhahds"
25
29
}
26
30
```
27
31
28
-
2. Taint the bucket by using the CLI command `terraform taint aws_s3_bucket.tainted`. Run the `terraform apply` command and verify that Terraform has marked the resource for recreation.
29
-
3. Untaint the bucket by running `terraform untaint aws_s3_bucket.tainted`. Verify that Terraform will not try to recreate the resource anymore.
30
-
4. Let’s now see how Terraform handles dependent resources when a tainted resource is recreated. For that, create a VPC and subnet using the same CIDR blocks we have been using so far. Create the resources with `terraform apply`.
32
+
33
+
2. CLI 명령 `terraform taint aws_s3_bucket.tainted`을 사용하여 버킷을 tainted 상태로 표시합니다. `terraform apply` 명령을 실행하고 Terraform이 리소스를 재생성하기 위해 표시한 것을 확인합니다.
34
+
3. `terraform untaint aws_s3_bucket.tainted`를 실행하여 버킷을 untaint 상태로 변경합니다. 이제 Terraform이 리소스를 다시 생성하려고 시도하지 않을 것임을 확인합니다.
35
+
4. 이제 tainted 리소스가 재생성될 때 Terraform이 종속 리소스를 어떻게 처리하는지 알아보겠습니다. 이를 위해 동일한 CIDR 블록을 사용하여 VPC와 서브넷을 생성합니다. `terraform apply`를 사용하여 리소스를 생성합니다.
36
+
31
37
32
38
```
33
39
resource "aws_vpc" "this" {
@@ -40,8 +46,10 @@ If you wish to give it a shot before looking into the detailed step-by-step and
40
46
}
41
47
```
42
48
43
-
5. Taint the `aws_vpc` we have created, and run the terraform apply command. What does the output look like?
44
-
6. Terraform will not always recreate downstream resources by default. To visualize that, add an `aws_s3_bucket_public_access_block` resource to the S3 bucket. Set both the `block_public_acls` and `block_public_policy` to false, so that we can visualize the issue more easily.
49
+
50
+
5. 우리가 생성한 `aws_vpc`를 tainted 상태로 표시하고, terraform apply 명령을 실행합니다. 출력은 어떻게 나오나요?
51
+
6. Terraform은 기본적으로 downstream 리소스를 항상 다시 생성하지 않습니다. 이를 시각화하기 위해 S3 버킷에 `aws_s3_bucket_public_access_block` 리소스를 추가하세요. `block_public_acls`와 `block_public_policy`를 모두 false로 설정하여 문제를 더 쉽게 시각화할 수 있도록 합니다.
@@ -54,10 +62,12 @@ If you wish to give it a shot before looking into the detailed step-by-step and
54
62
}
55
63
```
56
64
57
-
7. Confirm the creation via `terraform apply`, and verify that the public access block is correctly configured in the AWS console.
58
-
8. Taint the S3 bucket, and then run `terraform apply`. Confirm the changes, and then check how the public access block is configured in the AWS console. Does it match the configuration we have in the Terraform configuration?
59
-
9. Make sure to delete the infrastructure before finishing this exercise!
65
+
66
+
7. `terraform apply`를 통해 생성을 확인하고 AWS 콘솔에서 공개 액세스 블록이 올바르게 구성되었는지 확인합니다.
67
+
8. S3 버킷을 tainted 상태로 표시하고 `terraform apply`를 실행합니다. 변경 사항을 확인하고 AWS 콘솔에서 공개 액세스 블록이 Terraform 구성과 일치하는지 확인합니다.
68
+
9. 이 연습을 마치기 전에 인프라를 삭제하는 것을 잊지 마세요!
69
+
60
70
61
71
## Congratulations on Completing the Exercise!
62
72
63
-
Great job on completing this exercise! You've taken another important step in mastering Terraform! The knowledge you've acquired about tainting and untainting resources will be crucial in managing your Terraform infrastructure. Keep up the good work!
73
+
이 연습을 완료하신 것을 축하드립니다! Terraform을 숙달하기 위한 또 다른 중요한 단계를 거치셨습니다! 리소스의 tainting과 untainting에 대한 습득한 지식은 Terraform 인프라 관리에 필수적입니다. 좋은 작업을 계속 이어나가세요!
This project focuses on importing existing AWS resources into Terraform. The primary goal is to learn how to use code generation features from Terraform to help us import several infrastructure components. The project will guide you through the process of creating, importing, and managing Lambda functions. It's important to note that all resources created during this project should be deleted at the end to avoid unnecessary costs.
3
+
이 프로젝트는 기존 AWS 리소스를 Terraform으로 가져오는 데 중점을 둡니다. 주요 목표는 Terraform의 코드 생성 기능을 사용하여 여러 인프라 구성 요소를 가져오는 데 도움이 되는 방법을 배우는 것입니다. 이 프로젝트는 Lambda 함수를 생성하고, 가져오고, 관리하는 과정을 안내합니다. 이 프로젝트에서 생성된 모든 리소스는 불필요한 비용을 피하기 위해 마지막에 삭제해야 한다는 점에 유의하세요.
4
4
5
5
## Desired Outcome
6
6
7
-
1. Create a Lambda function manually in the AWS console.
8
-
1. Use the hello-world blueprint.
9
-
2. For the execution role, select the "Create a new role with basic permissions" option.
10
-
2. Identify all the resources that were created when creating the Lambda function.
11
-
3. Import the Lambda function and its code into Terraform.
12
-
1.**Hint:** Lambda function code can be provided via a ZIP file. Terraform offers ZIP file management via the `archive` provider.
13
-
4. Import the other created resources into Terraform.
14
-
5. Use as much configuration generation as possible, always keeping in mind that the generated code should be first refined before being definitely added to the project.
15
-
6. Make sure to delete all the resources at the end of the project!
7
+
8
+
1. AWS 콘솔에서 Lambda 함수를 수동으로 생성합니다.
9
+
1. hello-world 블루프린트를 사용합니다.
10
+
2. 실행 역할로 "기본 권한으로 새 역할 생성" 옵션을 선택합니다.
11
+
2. Lambda 함수를 생성할 때 생성된 모든 리소스를 식별합니다.
12
+
3. Lambda 함수와 코드를 Terraform으로 가져옵니다.
13
+
1.**힌트:** Lambda 함수 코드는 ZIP 파일로 제공할 수 있습니다. Terraform은 `archive` 프로바이더를 통해 ZIP 파일 관리를 제공합니다.
14
+
4. 다른 생성된 리소스를 Terraform으로 가져옵니다.
15
+
5. 가능한 한 많은 구성 생성을 사용하되, 생성된 코드를 최종적으로 프로젝트에 추가하기 전에 먼저 정제해야 합니다.
0 commit comments