0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

aws-cliのimageにterraformコマンドを利用できる環境を作成する

Posted at

aws-cliのimageにterraformコマンドを利用できる環境を作成する

Motivation

awsの簡易的なlocal開発環境を作成したく、可能な限りterraformで管理をしたいと思った。

TL;DR

amazon/aws-cliのdocker imageに、terraformをinstallして利用可能にする。

Directory構成

tree .
.
├── Makefile
├── README.md
├── local-dev
│   ├── compose.yaml
│   └── tmp.terraform.dockerfile
└── terraform
    └── main.tf
compose.yaml
services:
  terraform:
    container_name: terraform_container
    build:
      context: .
      dockerfile: tmp.terraform.dockerfile
      target: development
      args:
        TERRAFORM_VERSION: "1.10.3"
        AWS_CLI_VERSION: "2.22.27"
    tty: true
    volumes:
      - ../terraform:/usr/terraform
    networks:
      - internal

networks:
  internal: {}
tmp.terraform.dockerfile
ARG AWS_CLI_VERSION

FROM amazon/aws-cli:${AWS_CLI_VERSION} as development

ARG TERRAFORM_VERSION

WORKDIR /usr/terraform

RUN yum install unzip -y

RUN curl https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip -o terraform_${TERRAFORM_VERSION}_linux_amd64.zip &&\
    unzip terraform_${TERRAFORM_VERSION}_linux_amd64.zip && rm terraform_${TERRAFORM_VERSION}_linux_amd64.zip &&\
    mv terraform /usr/bin/terraform

ENTRYPOINT [ "/bin/bash" ]
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?