cd ./infra/dns
terraform init
terraform validate
terraform apply -var="profile=monthly-cs" -var="domain_name=<가비아에서 구매한 도메인 이름>"
terraform destroy -var="profile=monthly-cs" -var="domain_name=<가비아에서 구매한 도메인 이름>"
예)
terraform apply -var="profile=monthly-cs" -var="domain_name=unchaptered.shop"
cd ./infra/ami
packer init .
packer validate .
packer build .
cd ./infra/server
terraform init
terraform validate
terraform apply -var="profile=monthly-cs" -var="domain_name=<가비아에서 구매한 도메인 이름>" -var="ami_id=<Packer로 생성된 AMI ID>"
terraform destroy -var="profile=monthly-cs" -var="domain_name=<가비아에서 구매한 도메인 이름>" -var="ami_id=<Packer로 생성된 AMI ID>"
예)
terraform apply -var="profile=monthly-cs" -var="domain_name=unchaptered.shop" -var="ami_id=ami-0e22b048b09df457f"
terraform destroy -var="profile=monthly-cs" -var="domain_name=unchaptered.shop" -var="ami_id=ami-0e22b048b09df457f"
- Output 출력하기
# Windows
for /f %i in ('terraform output s3_name') do echo s3_name %i
for /f %i in ('terraform output codedeploy_app_name') do echo codedeploy_app_name %i
for /f %i in ('terraform output codedeploy_deployment_name') do echo codedeploy_deployment_name %i
# Mac
echo s3_name $(terraform output s3_name)
echo codedeploy_app_name $(terraform output codedeploy_app_name)
echo codedeploy_deployment_name $(terraform output codedeploy_deployment_name)
- Windows
zip -r next-server.zip ^
./.next ^
./component ^
./public ^
./scripts ^
./src ^
./appspec.yml ^
./ecosystem.config.json ^
./next-env.d.ts ^
./next.config.mjs ^
./package-lock.json ^
./package.json ^
./README.md ^
./tsconfig.json ^
./yarn.lock
- MacOS, Linux
zip -r next-server.zip \
./.next \
./component \
./public \
./scripts \
./src \
./appspec.yml \
./ecosystem.config.json \
./next-env.d.ts \
./next.config.mjs \
./package-lock.json \
./package.json \
./README.md \
./tsconfig.json \
./yarn.lock
cd ./infra/server
terraform output s3_name
- Windows
aws s3 cp ^
--region us-east-1 ^
../../next-server.zip ^
s3://<terraform output s3_name의 결과>/next-server.zip ^
--profile monthly-cs
예)
aws s3 cp ^
--region us-east-1 ^
../../next-server.zip ^
s3://meet-piglet-monthly-cs-s3-bucket/next-server.zip ^
--profile monthly-cs
- MacOS, Linux
aws s3 cp \
--region us-east-1 \
../../next-server.zip \
s3://<terraform output s3_name의 결과>/next-server.zip \
--profile monthly-cs
cd ./infra/server # 만약 이미 server 폴더라면, 제외
terraform output s3_name
terraform output codedeploy_app_name
terraform output codedeploy_deployment_name
aws deploy create-deployment ^
--application-name <출력값 codedeploy_app_name> ^
--deployment-group-name <출력값 codedeploy_deployment_name> ^
--s3-location bucket=<출력값 s3_name>,bundleType=zip,key=next-server.zip ^
--profile monthly-cs
예)
aws deploy create-deployment ^
--application-name monthly-cs-codedeploy-app ^
--deployment-group-name monthly-cs-codedeploy-deployment ^
--s3-location bucket=meet-piglet-monthly-cs-s3-bucket,bundleType=zip,key=next-server.zip ^
--profile monthly-cs
aws s3 rm s3://<출력값 s3_name> --recursive
예)
aws s3 rm s3://meet-piglet-monthly-cs-s3-bucket --recursive --profile monthly-cs
cd ./infra/server
terraform destroy -var="profile=monthly-cs" -var="domain_name=<가비아에서 구매한 도메인 이름>" -var="ami_id=<Packer로 생성된 AMI ID>"
terraform destroy -var="profile=monthly-cs" -var="domain_name=unchaptered.shop" -var="ami_id=ami-0e22b048b09df457f"