docker terraform 실행 환경을 만들어 동료의 terraform 실행 환경을 존중

소개하는 내용


  • terraform의 環境別HOMEパス/.aws/credentials에서 aws profile을 얻는 설정을 이용합니다.
  • gitignore와 docker의 volumes를 이용해 terraform 실행 환경을 만듭니다.
  • 참고: htps //w w. 테라후 rm. 이오/도 cs/p로ㅔぃ로 rs/아ws/그리고 x. html # 멋쟁이 dc
  • 주로 MAC에 terraform 설치한 동료와 docker로 terraform 사용하고 싶은 사람(필자) 상황을 상정했습니다



  • 결론



  • 동일한 aws profile 이름을 설정하는 규칙 만 준수하면 MAC에서 terraform을 설치 한 사람과 docker로 terraform을 설치 한 사람은 서로의 환경에 신경 쓰지 않고 terraform을 실행할 수 있다고 생각합니다.
  • docker 컨테이너에서 생성된 aws profile 정보를 docker의 볼륨으로 마운트했습니다.
  • 마운트 된 디렉토리를 지우지 않는 한 aws profile을 계속 사용할 수 있습니다.

  • gitignore했기 때문에 aws profile 정보는 git push되지 않습니다


  • 소개 시작



    디렉토리 구성



    전체 소스 코드는 htps : // 기주 b. 코 m / 치에 ky 코 r d / 쿠에타 에에 mp에서 확인할 수 있습니다.
  • 전체도
  • aws profile의 정보를 마운트하는 디렉토리
    docker 컨테이너 안에서 생성한 aws profile의 정보를 마운트하는 곳입니다.
  • terraform 파일이 있는 디렉토리
    aws profile 이름 my-demo

  • 시험 순서입니다.


  • docker compose가 있는 디렉터리 이동으로 이동합니다.
  • cd qitta-example/terraform/aws-account-management

  • docker 컨테이너를 백그라운드에서 시작합니다.
  • DOCKER_UID=$(id -u $USER) DOCKER_GID=$(id -g $USER) docker-compose up -d

  • docker 컨테이너로 들어갑니다.
  • docker exec -it aws-account-management /bin/sh


  • aws profile 설정
  • 한 번이면 충분합니다. HOST 기계에 영향을주지 않습니다.
  • profile 이름이 my-demo로 설정되었습니다. terraform에서 참조하십시오
  • aws configure --profile my-demo 실행 전 이미지

  • aws configure --profile my-demo 실행 중인 이미지

  • aws configure --profile my-demo 실행 후 이미지



  • terraform 디렉터리로 이동
  • cd ~/terraform/demo


  • terraform init합니다
  • terraform init


  • terraform을 실행합니다.
  • terraform apply


  • terraform의 profile 참조 이름을 변경하여 오류가 발생하는지 확인합니다.
  • main.tf를 일시적으로 수정합니다.
  • terraform apply


  • 좋은 웹페이지 즐겨찾기