안녕하세요!
하씨가문의
영광입니다!
지난주
Terraform AWS IAM까지 다루었는데요!
이번에는 AWS의 VPN에 대해서 다뤄보도록
하겠습니다:)
Don't have
a good day, Have a great day!
▶ 목차
- aws_customer_gateway
- aws_vpn_connection
- aws_vpn_connection_route
- aws_vpn_gateway
- aws_vpn_gateway_attachment
1.
aws_customer_gateway
resource "aws_customer_gateway" "main" {
bgp_asn = 65000
ip_address = "172.83.124.10"
type = "ipsec.1"
tags = {
Name = "main-customer-gateway"
}
}
| 필수 |
설명 |
옵션 |
설명 |
| bgp_asn |
게이트웨이의 BGP 시스템
번호입니다. |
certificate_arn
|
고객 게이트웨이 인증서 리소스
이름입니다. |
| ip_address |
고객 게이트웨이 장치의 외부 인터페이스에
대한 IPv4 주소를 입력합니다. |
device_name |
고객 게이트웨이 장치의 이름을
입력합니다. |
| type |
고객 게이트웨이 유형으로 유일한 유형은
"ipsec.1"입니다. |
tags |
게이트웨이에 적용할 태그입니다.
|
2.
aws_vpn_connection
resource "aws_ec2_transit_gateway" "example" {}
resource "aws_customer_gateway" "example" {
bgp_asn = 65000
ip_address = "172.0.0.1"
type = "ipsec.1"
}
resource "aws_vpn_connection" "example" {
customer_gateway_id = aws_customer_gateway.example.id
transit_gateway_id = aws_ec2_transit_gateway.example.id
type = aws_customer_gateway.example.type
}
resource "aws_vpc" "vpc" {
cidr_block = "10.0.0.0/16"
}
resource "aws_vpn_gateway" "vpn_gateway" {
vpc_id = aws_vpc.vpc.id
}
resource "aws_customer_gateway" "customer_gateway" {
bgp_asn = 65000
ip_address = "172.0.0.1"
type = "ipsec.1"
}
resource "aws_vpn_connection" "main" {
vpn_gateway_id = aws_vpn_gateway.vpn_gateway.id
customer_gateway_id = aws_customer_gateway.customer_gateway.id
type = "ipsec.1"
static_routes_only = true
}
| 필수 |
설명 |
옵션 |
설명 |
| customer_gateway_id
|
고객 게이트웨이의 ID를
입력합니다. |
transit_gateway_id
|
EC2 Transit Gateway의
ID입니다. |
| vpn_gateway_id
|
가상
게이트웨이의 ID를 입력합니다. |
| static_routes_only
|
VPN 연결이 정적 경로만 사용하는지 여부를
결정하는 곳입니다. |
| type |
VPN 연결 유형을 선택하며, 현재 AWS가
지원하는 유일한 유형은 "ipsec.1"입니다. |
enable_acceleration
|
VPN 연결에 대한 가속을 활성화할지 여부를
결정합니다. |
| tunnel1_preshared_key
|
첫
번째 VPN터널의 사전 공유키를 나타냅니다. |
| tunnel1_replay_window_size
|
첫
번째 VPN 터널에 대한 IKE 재생 창의 패킷 수입니다. |
3.
aws_vpn_connection_route
resource "aws_vpn_connection" "main" {
vpn_gateway_id = aws_vpn_gateway.vpn_gateway.id
customer_gateway_id = aws_customer_gateway.customer_gateway.id
type = "ipsec.1"
static_routes_only = true
}
resource "aws_vpn_connection_route" "office" {
destination_cidr_block = "192.168.10.0/24"
vpn_connection_id = aws_vpn_connection.main.id
}
| 필수 |
설명 |
| destination_cidr_block
|
고객 네트워크의 로컬 서브넷과 연결된
CIDR를 입력합니다. |
| vpn_connection_id
|
VPN 연결의 ID를
입력합니다. |
4.
aws_vpn_gateway
resource "aws_vpn_gateway" "vpn_gw" {
vpc_id = aws_vpc.main.id
tags = {
Name = "main"
}
}
| 필수 |
설명 |
옵션 |
설명 |
| vpc_id |
생성할 VPC ID를
지정합니다. |
availability_zone
|
가상 프라이빗 게이트웨의 가용영역을
지정합니다. |
| tags |
리소스에 할당할 태그 맵입니다.
|
| amazon_side_asn
|
게이트웨이의 Amazon에서의 시스템
번호입니다. |
5.
aws_vpn_gateway_attachment
resource "aws_vpc" "network" {
cidr_block = "10.0.0.0/16"
}
resource "aws_vpn_gateway" "vpn" {
tags = {
Name = "example-vpn-gateway"
}
}
resource "aws_vpn_gateway_attachment" "vpn_attachment" {
vpc_id = aws_vpc.network.id
vpn_gateway_id = aws_vpn_gateway.vpn.id
}
| 필수 |
설명 |
| vpc_id |
VPC의 ID를 입력합니다
|
| vpn_gateway_id
|
가상 사설 게이트웨이의 ID를
입력합니다. |
이렇게 Terraform 기반
AWS VPN에 대해서 알아보았는데요!
VPN은 종종 사용할 수 있어서 알아두면 좋을 거 같아요!
오늘도 읽어주셔서 감사합니다:)
댓글