Skip to content

Instantly share code, notes, and snippets.

@lestephane
Created September 10, 2017 19:35
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lestephane/495f35de9a398ad0f613458aaeb9db15 to your computer and use it in GitHub Desktop.
Save lestephane/495f35de9a398ad0f613458aaeb9db15 to your computer and use it in GitHub Desktop.
Dockerized terraform bundler
FROM golang:alpine
RUN apk update && apk upgrade && \
apk add --no-cache git zip
ARG TERRAFORM_VERSION
RUN git clone --single-branch --branch v${TERRAFORM_VERSION} https://github.com/hashicorp/terraform.git /go/src/github.com/hashicorp/terraform
RUN cd $GOPATH/src/github.com/hashicorp/terraform && echo $GOPATH && go install ./tools/terraform-bundle
ADD terraform-version.hcl /
ADD entrypoint.sh /
ENTRYPOINT [ "/entrypoint.sh" ]
#!/bin/sh
terraform-bundle package -os=linux -arch=amd64 /terraform-version.hcl
mv *.zip /output/terraform-bundle.zip
#!/bin/bash
set -euo pipefail
MYDIR=$(readlink -e $(dirname "$0"))
TERRAFORM_VERSION="${TERRAFORM_VERSION:-0.10.4}"
docker build -t terraform-bundle --build-arg "TERRAFORM_VERSION=${TERRAFORM_VERSION}" src/deps/terraform
docker run -v /tmp:/output --rm -it terraform-bundle "$@"
cp /tmp/terraform-bundle.zip "$(dirname "${MYDIR}")"
#
# Configuration used by terraform-bundle to fetch all required plugins ONCE.
#
# (see https://github.com/hashicorp/terraform/tree/master/tools/terraform-bundle)
# (why https://github.com/hashicorp/terraform/issues/15801)
#
terraform {
version = "0.10.4"
}
providers {
aws = ["~> 0.1"]
external = ["~> 0.1"]
null = ["~> 0.1"]
template = ["~> 0.1"]
terraform = ["~> 0.1"]
tls = ["~> 0.1"]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment