This is the example for using go binary to run using terraform
Advantages:
- No need for any dependencies
- You can incluse anything to run in the binary
How to use:
- Put all of the thing that needs to run while doing terrraform apply
- build the main file and store it on /bin/{utils}
- yiou can build the binary using build.sh with current directory as utils
$ ls
bin build.sh src
./build.sh
Dirctory structure
.
├── Readme.md
├── main.tf
├── utils
│ ├── bin
│ │ └── utils
│ ├── build.sh
│ └── src
│ └── main.go
└── variables.tf
Feature ehnacement :
- Use the docker command to build the binary (refer the build file ) #docker run -v $(pwd):/app/ -e CGO_ENABLED=0 -w /app/src/ golang:1.14 go build -a -o /app/bin/utils .