728x90 반응형 전체 글115 Terraform: AWS 서버구축 Using Terraform for AWS NCP 로 staging 과 productions 을 구축하고 써봤다. 이제 AWS 에서 staging 환경까지 구축해보자. 사실 클라우드 서비스를 제공하는 회사에 따라 적용해야될 부분이 크게 다르지 않기 때문에 어렵지않게 적용시킬 수 있다. 단지 어떻게 공식문서를 확인해가면서 필요한 부분들을 찾아가는지 고민해야하는 부분이다. netwrok → db server → be server → loadbalancer 순서로 구현해보자. Modules 구조나 필요한 리소스는 NCP 와 다를게 없다. 공식문서를 잘 확인해서 필요한 부분들을 구현하자. network variables.tf # staing 에서 network 모듈로 전달하는 변수들 정리 env region m.. Dev./Terraform 2023. 9. 8. Terraform: Status 가 꼬이는 현상 가끔 모듈 정보를 바꿔야 할 때가 있다. module "servers" { >>>>> module "be" { terraform 으로 생성한 인스턴스가 운영중인데 무심코 module 정보를 바꾸고 init 을 했다면 terraform status 가 꼬여 문제가 발생하게 된다. apply 를 하든, destroy 를 하든, plan 을 하든 이미 status 가 쌓여 있는 시점에서는 새로운 모듈을 삽입해서 사용해서는 안되는 것 같다. (venv) kimminhyeok@Ivans-Mac staging % terraform state list data.ncloud_server_products.sm ncloud_public_ip.be ncloud_public_ip.db module.be.data.ncloud_.. Dev./Terraform 2023. 9. 7. Terraform: Separating Server 모듈에서 하나의 서버만 만들도록 변경 명령어를 이용하여 따로 따로 실행 가능하게 하기 위함 Modules 안 server 폴더 안쪽에 하위 폴더를 만들면 테라폼에서 접근을 하지 않음 이 작업의 접근 방식은 server 에 있는 main 을 분할은 하되, staging 에서 module 접근자로 해결 previous code staging/main.tf # servers module "servers" { source = "../modules/server" # going to variabels.tf env = local.env region = var.region site = var.site support_vpc = var.support_vpc username = var.username passw.. Dev./Terraform 2023. 9. 6. Terraform: Modules Staging code refactoring 기존에는 코드를 하나의 main.tf 파일에 담아서 동작시켰지만 실제로는 기능별로 분리해서 관리하는게 가독성이 좋다. hasicorp 의 제공하는 문서에 의하면, The standard module structure is a file and directory layout we recommend for reusable modules distributed in separate repositories. Terraform tooling is built to understand the standard module structure and use that structure to generate documentation, index modules for the module.. Dev./Terraform 2023. 9. 5. Terraform: LoadBalancer Load balance 앱을 지원하는 리소스 풀 전체에 네트워크 트래픽을 균등하게 배포한다. 애플리케이션 가동 중지 없이 애플리케이션 서버 유지 관리 또는 업그레이드 실행 Health check 을 수행하고 가동 중지를 유발할 수 있는 문제를 방지 서브넷 -> 로드벨런스 리소스 -> 타겟 그룹 -> 리스너 -> 적용 인스턴스 설정 ## Load Balancer 생성 시작 # Load Balancer resource "ncloud_lb" "lion-lb-tf" { name = "be-lb-staging" network_type = "PUBLIC" type = "NETWORK_PROXY" # 로드 밸런서는 구분지어진 하나의 서브넷을 받기 때문에 따로 설정해준다. subnet_no_list = [ ncloud.. Dev./Terraform 2023. 9. 5. 이전 1 ··· 6 7 8 9 10 11 12 ··· 23 다음 728x90 반응형