본문 바로가기

AWS

[AWS] GWLB 구성 가이드 with Terraform(1)

반응형

목표

Terraform을 이용한 Gateway Load Balancer를 구성 가이드 입니다.

이 가이드에서는 다음을 할 수 있게 됩니다.

  • 중앙 집중방식으로 모든 트래픽을 모니터링 할 수 있습니다.
  • VPC에서 외부 전송 트래픽에 대해 Transit Gateway를 기반으로 구성합니다.
  • Application을 외부에 서비스를 제공하기 위해 ALB와 내부 NLB로 구성합니다.
  • 내부 Private Subnet 자원들의 외부 통신을 위해 NAT Gateway를 구성합니다.

Architecture

이 가이드에서는 다음과 같이 구성합니다.

Prerequisites

다음 준비 사항이 사전에 준비되어야 합니다.

  • Terraform 설치
  • AWS에 Key pair 등록
  • AWSCLI 설치 및 credential 설정

구성

1 단계: Github clone

아래 GitHub 주소에서 test-gwlb-terraform repository를 다운로드 받습니다.

다음 명령어를 입력하여 repository를 다운로드 받습니다.

$ git clone https://github.com/jonggulee/tf-poc-gwlb.git

 

2 단계: 환경 변수 수정

data.tf 파일을 열어서 환경에 맞는 key pair 명으로 수정 합니다.

variable "app01_web_key" {
  description = "WEB keypair in app01 vpc"
  default     = "test-bastion"
}

variable "appliance_bastion_key" {
  description = "Bastion keypair in appliance vpc"
  default     = "test-bastion"
}

variable "appliance_key" {
  description = "Bastion keypair in appliance vpc"
  default     = "test-bastion"
}

 

3 단계: terraform 초기화 및 실행

아래 명령어를 입력하여 terraform 초기화를 진행합니다.

$ terraform init


위 명령어의 내용은 아래 내용과 유사합니다.

Initializing the backend...

Initializing provider plugins...
- Finding latest version of hashicorp/aws...
- Installing hashicorp/aws v4.15.1...
- Installed hashicorp/aws v4.15.1 (signed by HashiCorp)

Terraform has created a lock file .terraform.lock.hcl to record the provider
selections it made above. Include this file in your version control repository
so that Terraform can guarantee to make the same selections by default when
you run "terraform init" in the future.

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.


아래 명령어를 입력하여 terraform 코드 및 생성되는 리소스에 이상이 없는지 확인합니다.

$ terraform plan

 

위 명령어로 코드 및 리소스에 이상이 없는지 확인이 되었다면 아래 명령어를 실행하여 리소스를 생성합니다. 약 10분 정도 소요 됩니다.

$ terraform apply -auto-approve

 

 

반응형

'AWS' 카테고리의 다른 글

[AWS] IAM 계정 생성  (0) 2023.09.05
[AWS] GWLB 구성 가이드 with Terraform(2)  (0) 2023.08.31
[AWS] EBS 용량 증설 가이드  (0) 2023.08.29
[AWS] Appstream 2.0을 이용한 원격환경 구성  (0) 2023.08.28
[AWS] WAF 구성 가이드  (0) 2023.08.27