Route53 DNS Record Management #
한마디로 #
이 스킬은 인터넷의 "전화번호부"를 관리하는 도구입니다. 사람은 app.unibook.co.kr 같은 주소를 외우지만, 컴퓨터는 실제로 어느 서버로 연결해야 하는지를 알아야 합니다. DNS는 그 둘을 이어 주는 안내판 역할을 하며, 이 스킬은 그 안내판을 만들고 고치고 지우는 일을 도와줍니다. 새 서비스 주소를 추가하거나 주소가 엉뚱한 곳으로 연결될 때 이 스킬이 등장합니다.
무엇을·언제 #
무엇을 해 주나요?새로운 하위 주소(예: myapp.unibook.co.kr)를 만들어 실제 서버와 연결해 줍니다. 기존 주소가 가리키는 곳을 바꾸거나, 더 이상 쓰지 않는 주소를 정리합니다. 두 개의 도메인(주 도메인 unibook.co.kr, 예전 도메인 laputa.im)을 함께 관리합니다. 주소가 제대로 연결됐는지 확인하는 점검 절차를 제공합니다.
언제 작동하나요?새 하위 주소(딥링크, 앱 호스팅 등)를 추가할 때 DNS 기록을 수정하거나 삭제할 때 도메인을 옮기는 작업(도메인 이전)을 할 때
핵심 용어 #
용어 쉬운 설명
DNS 사람이 읽는 웹주소를 컴퓨터가 찾아갈 실제 위치로 바꿔 주는 인터넷 전화번호부
Route53 아마존(AWS)이 제공하는 DNS 관리 서비스. 이 전화번호부를 보관하는 곳
DNS Record(레코드) 전화번호부 안의 한 줄. "이 주소는 저 서버로 연결" 같은 항목 하나
Subdomain(하위 주소)
큰 주소 앞에 붙는 이름. 예: app.unibook.co.kr의 app 부분
Hosted Zone 한 도메인에 속한 모든 레코드를 담아 두는 묶음(주소록 한 권)
CNAME "이 주소는 다른 주소와 같은 곳을 가리킨다"라고 별명을 연결하는 방식
A record 주소를 실제 서버의 숫자 주소(IP)로 직접 연결하는 방식
TTL 이 연결 정보를 얼마 동안 기억해 둘지 정하는 시간(초)
ACM Certificate(인증서) 주소가 안전(https) 연결임을 보증하는 보안 증명서
ALB / CloudFront 사용자의 접속을 받아 주는 입구 역할의 AWS 서비스
Terraform 이런 인프라 설정을 코드로 적어 두고 자동으로 적용하는 도구
Production / Staging 실제 사용자용 환경(운영) / 출시 전 시험용 환경(스테이징)
DNS propagation(전파) 바뀐 주소 정보가 전 세계 인터넷에 퍼져 적용되는 과정
Manages Route53 DNS records with Terraform. Multi-domain support (primary + secondary domain).
Triggers #
Add new subdomains (deep links, Firebase Hosting, etc.)
Modify/delete DNS records
Domain migration
Domain Structure #
Hosted Zones #
Domain Zone ID Purpose
unibook.co.kr Z0775776240YOL7IYBNYHPrimary (currently used)
laputa.im Z0911207339KKWN48L9BWSecondary (legacy)
Certificates (ACM) #
Purpose Region Notes
ALB ap-northeast-2 *.unibook.co.kr wildcard
CloudFront
us-east-1
*.unibook.co.kr wildcard (CloudFront required)
Secondary ALB ap-northeast-2 *.laputa.im wildcard
Secondary CloudFront us-east-1 *.laputa.im wildcard
Subdomain Patterns #
Subdomain Target Production Staging
api
ALB
api.unibook.co.kr
api-stg.unibook.co.kr
web
ALB
web.unibook.co.kr
web-stg.unibook.co.kr
insights
ALB
insights.unibook.co.kr
insights-stg.unibook.co.kr
storage
CloudFront
storage.unibook.co.kr
storage-stg.unibook.co.kr
assets
CloudFront
assets.unibook.co.kr
assets-stg.unibook.co.kr
app
Firebase
app.unibook.co.kr
app-stg.unibook.co.kr
console
Firebase
console.unibook.co.kr
console-stg.unibook.co.kr
deeplink
ALB (CNAME)
deeplink.unibook.co.kr
stdeeplink.unibook.co.kr
DNS Record Addition Procedure #
1. Add Map Variable to variables.tf (root) #
variable " new_config " {
description = " New domain configuration "
type = map ( object ( {
subdomain = string
target = string
} ) )
default = { }
}
2. Set Values in config.auto.tfvars #
new_config = {
" production " = {
" subdomain " = " myapp "
" target " = " web.unibook.co.kr "
}
" staging " = {
" subdomain " = " myapp-stg "
" target " = " web-stg.unibook.co.kr "
}
}
3. Add Variable to environment Module variables.tf #
variable " new_subdomain " {
description = " Subdomain for new service "
type = string
default = " "
}
variable " new_target " {
description = " Target for new service "
type = string
default = " "
}
4. Add Resource to firebase-dns.tf (or new .tf file) #
# Primary domain
resource " aws_route53_record " " new_service " {
count = var . enable_route53 & & var . enable_primary_dns & & var . new_subdomain != " " ? 1 : 0
zone_id = var . hosted_zone_id
name = var . new_subdomain
type = " CNAME "
ttl = " 60 "
records = [ var . new_target]
allow_overwrite = true
}
# Secondary domain
resource " aws_route53_record " " new_service_secondary " {
count = var . enable_route53 & & var . secondary_domain != null & & var . new_subdomain != " " ? 1 : 0
zone_id = var . secondary_hosted_zone_id
name = var . new_subdomain
type = " CNAME "
ttl = " 60 "
records = [ " ${ var . new_subdomain } . ${ var . secondary_domain } " ]
allow_overwrite = true
}
5. Pass Variables in main.tf #
module " production_env " {
# ...
new_subdomain = lookup ( var . new_config, " production " , null ) != null ? var . new_config[ " production " ] [ " subdomain " ] : " "
new_target = lookup ( var . new_config, " production " , null ) != null ? var . new_config[ " production " ] [ " target " ] : " "
}
count Condition Patterns #
Primary Domain DNS #
count = var . enable_route53 & & var . enable_primary_dns & & var . < subdomain > != " " ? 1 : 0
Secondary Domain DNS #
count = var . enable_route53 & & var . secondary_domain != null & & var . < subdomain > != " " ? 1 : 0
Production-only Resources (Top domain alias, etc.) #
count = var . enable_route53 & & var . enable_primary_dns & & var . enable_top_domain_alias & & < condition > ? 1 : 0
Verification #
# Check CNAME record
dig < subdomain > . unibook. co. kr CNAME + short
# Check A record
dig < subdomain > . unibook. co. kr A + short
# Direct Route53 query
aws route53 list- resource- record- sets \
-- hosted- zone- id < hosted- zone- id > \
-- query " ResourceRecordSets[?contains(Name, ' < keyword > ' )] " \
-- output table
Checklist #