I'm provisioning resources on AWS as well as on a 3rd party system via a custom provider. On my local environment, it works fine (as I have downloaded and compiled the 3rd party provider).
As a next step, I’m trying to run a Gitlab pipeline with Terraform.The AWS part works because it's a Terrafrom registered provider, however the 3rd party part fails (because it's not a registered Terraform provider).
When I try to run a Gitlab pipeline, it complains with an error and advises the following
In the latter case, the plugin must be installed manually by locating and downloading a suitable distribution package and placing the plugin’s executable file in the following directory: terraform.d/plugins/linux_amd64
The .gitlab-ci.yml file I have is the following:
image:
name: hashicorp/terraform:light
entrypoint:
- '/usr/bin/env'
- 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
before_script:
- rm -rf .terraform
- terraform --version
- export AWS_ACCESS_KEY
- export AWS_SECRET_KEY
- terraform init
stages:
- validate
- plan
- apply
validate:
stage: validate
script:
- terraform validate
plan:
stage: plan
script:
- terraform plan -out "planfile"
dependencies:
- validate
artifacts:
paths:
- planfile
apply:
stage: apply
script:
- terraform apply -input=false "planfile"
dependencies:
- plan
when: manual
I see an image is used called 'hashicorp/terraform:light'. Should I create a docker image based on this image with the 3rd party provider already in?
EDIT1
It's clear a custom image is required. I used the idea from rflume below and used the following Dockerfile to build the image.
# Multi-Stage builds require Docker Engine 17.05 or higher
# Build ACI provider
FROM ubuntu:bionic-20190515 as builder
ENV HOME /root
ENV GOPATH $HOME/go
ENV GOBIN $GOPATH/bin
RUN apt update &&\
apt install -yqq software-properties-common \
git \
wget \
unzip \
gcc \
perl \
go-dep \
make \
build-essential &&\
add-apt-repository ppa:longsleep/golang-backports &&\
apt-get update &&\
apt-get install -y golang-go &&\
mkdir -p $GOPATH/src/github.com/terraform-providers &&\
wget -O $HOME/terraform-provider-aci.zip https://github.com/ciscoecosystem/terraform-provider-aci/archive/master.zip &&\
cd $GOPATH/src/github.com/terraform-providers/ &&\
unzip $HOME/terraform-provider-aci.zip -d . &&\
mv terraform-provider-aci-master \
terraform-provider-aci-v1.0.0
WORKDIR $GOPATH/src/github.com/terraform-providers/terraform-provider-aci-v1.0.0
RUN dep ensure
RUN make build
# Build the actual image
FROM hashicorp/terraform:0.11.14
ENV GOBIN /root/go/bin
ENV PATH $GOBIN:$PATH
RUN mkdir -p /root/.terraform.d/plugins
COPY --from=builder /root/go/bin/terraform-provider-aci-v1.0.0 $GOBIN/terraform-provider-aci-v1.0.0
ENTRYPOINT ["/bin/sh", "-c"]
