IT/Terraform

    [Terraform] Terragrunt 란? (Terragrunt 사용법과 활용방법)

    Intro terragrunt는 테라폼 소스코드를 DRY(Don't Repeat Yourself) 하게 만들어주는 툴 입니다. DRY 란 프로그래밍을 할때 반복작업을 하지 않는 것을 말하는데요. 자세한 내용은 다음 링크를 참고 바랍니다. ( DRY원칙이란?: https://kim-dragon.tistory.com/256) 테라폼 소스코드의 레이아웃은 폴더 레벨로 구분되어 집니다. 레이아웃은 규모에 따라서 달라집니다만 그 얘기를 하면 너무 길어질거 같으니 DRY에 대한 얘기만 해보겠습니다. 아래 레이아웃을 보면 반복되어지는 파일 backend.tf provider.tf main.tf 을 볼 수 있는데요. 오늘 주인공 terrgrunt를 하용하여 반복되는 파일들을 생성 해보도록 하겠습니다. ├── R..

    [Terraform] EKS Cluster 삭제시 aws-auth 에러 해결하기

    아래와 같이 aws-auth 관련 메시지 나올 때 해결책 Error: Get "http://localhost/api/v1/namespaces/kube-system/configmaps/aws-auth": dial tcp [::1]:80: connect: connection refused │ │ with module.eks.kubernetes_config_map_v1_data.aws_auth[0], │ on ../../../../../../../../aws/modules/eks/main.tf line 431, in resource "kubernetes_config_map_v1_data" "aws_auth": │ 431: resource "kubernetes_config_map_v1_data" "aws_aut..

    [Terraform] slice 사용하여 리스트의 startindex, endindex값 가져오기

    Intro 테라폼 코딩을 하면서 count나 for_each로 여러개의 리소스를 생성하는 경우가 있습니다. 이 리소스는 output으로 출력할때 list가 됩니다. 리스트 값을 특정 범위에 있는 리스트만 가져올 수 있는 방법이 바로 slice function입니다. python에서는 list의 값을 list[0:3] 이런식으로 리스트의 범위를 잡아줄 수 있기 때문에 당연히(?) 리스트의 인덱스 범위를 지정할 수 있을 줄 알았는데, python과 같이 범위설정이 되지 않았으며 이것도 안돼나? 싶어서 list[0-3] 이렇게 해도 먹히지 않았습니다. 앞서 설명드린 것과 같이 이 경우 slice 를 사용해야합니다. slice 는? 리스트의 값들을 연속적인 값으로 추출할 수 있는 function 입니다. sli..

    [Terraform] terraform init Error 해결

    terraform init을 할때 backend로 설정한 s3 버킷이 없거나 버킷명이 잘못 되었을 경우 아래와 같은 메시지가 발생합니다. Initializing the backend... Successfully configured the backend "s3"! Terraform will automatically use this backend unless the backend configuration changes. Error refreshing state: BucketRegionError: incorrect region, the bucket is not in 'ap-northeast-2' region at endpoint '' status code: 301, request ..