Last active
November 16, 2017 14:08
-
-
Save lorengordon/b69d0bdf6cb6edfab20ba5162558840a to your computer and use it in GitHub Desktop.
Build Cross-Platform Terraform Plugins
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWS_PROVIDER_REPO=https://github.com/terraform-providers/terraform-provider-aws.git | |
AWS_PROVIDER_BRANCH=master | |
# Pre-req: Have a working go install :-) | |
# Get go: https://golang.org/dl/ | |
# Install go: https://golang.org/doc/install | |
#curl -LO https://redirector.gvt1.com/edgedl/go/go1.9.2.linux-amd64.tar.gz | |
#sudo tar -C /usr/local -xvzf go*.linux-amd64.tar.gz | |
sudo yum -y install git | |
export PATH=$PATH:/usr/local/go/bin | |
export GOPATH=$(go env GOPATH) | |
export PATH=$GOPATH/bin:$PATH | |
# Increase open files limit (macOS default of 256 is too low) | |
ulimit -n 10000 | |
# Save current directory | |
pushd $(pwd) | |
# Get govendor, gox, and stringer | |
go get -u github.com/kardianos/govendor | |
go get -u github.com/mitchellh/gox | |
go get -u golang.org/x/tools/cmd/stringer | |
# Get AWS provider | |
rm -rf $GOPATH/src/github.com/terraform-providers/terraform-provider-aws | |
git clone "$AWS_PROVIDER_REPO" --branch "$AWS_PROVIDER_BRANCH" $GOPATH/src/github.com/terraform-providers/terraform-provider-aws | |
# Get Terraform source that depends on AWS provider | |
rm -rf $GOPATH/src/github.com/terraform-providers/terraform-provider-terraform | |
git clone https://github.com/terraform-providers/terraform-provider-terraform.git $GOPATH/src/github.com/terraform-providers/terraform-provider-terraform | |
rm -rf $GOPATH/src/github.com/hashicorp/terraform | |
git clone https://github.com/hashicorp/terraform.git $GOPATH/src/github.com/hashicorp/terraform | |
# Build AWS provider | |
cd $GOPATH/src/github.com/terraform-providers/terraform-provider-aws | |
mkdir -p scripts | |
cp ${GOPATH}/src/github.com/hashicorp/terraform/scripts/build.sh scripts | |
go generate ./... | |
TF_RELEASE=1 sh -c "scripts/build.sh" | |
#TF_DEV=1 sh -c "scripts/build.sh" # For dev only builds | |
# Build Terraform provider using newly built AWS provider | |
cd $GOPATH/src/github.com/terraform-providers/terraform-provider-terraform | |
govendor update github.com/terraform-providers/terraform-provider-aws/aws/... | |
govendor fetch github.com/aws/aws-sdk-go/[email protected] | |
mkdir -p scripts | |
cp ${GOPATH}/src/github.com/hashicorp/terraform/scripts/build.sh scripts | |
go generate ./... | |
TF_RELEASE=1 sh -c "scripts/build.sh" | |
#TF_DEV=1 sh -c "scripts/build.sh" # For dev only builds | |
# Build Terraform using newly built AWS provider | |
cd $GOPATH/src/github.com/hashicorp/terraform | |
govendor update github.com/terraform-providers/terraform-provider-aws/aws/... | |
govendor fetch github.com/aws/aws-sdk-go/[email protected] | |
make bin | |
#make dev # For dev only builds | |
# Restore pwd | |
popd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Inspired by https://gist.github.com/mikemoate/99776bee1c0b161f5bc2db207c771727