No description
Find a file
Bitor Tonixa Balenca e0d6c4b526
Clean makefile
2023-12-20 20:28:45 +00:00
api Added go backend for testing purposes 2023-12-19 23:31:45 +00:00
example Added go backend for testing purposes 2023-12-19 23:31:45 +00:00
internal/provider Added go backend for testing purposes 2023-12-19 23:31:45 +00:00
.gitignore Added makefile 2023-12-20 20:01:56 +00:00
go.mod More on the receitas resource 2023-12-19 23:31:43 +00:00
go.sum More on the receitas resource 2023-12-19 23:31:43 +00:00
main.go More on the receitas resource 2023-12-19 23:31:43 +00:00
Makefile Clean makefile 2023-12-20 20:28:45 +00:00
README.md More on documentation 2023-12-20 20:27:20 +00:00

Receita terraform example provider

What?

This is a terraform provider to serve as example. This will give an API to generate receipts based on a terraform provider.

Building?

First step in this journey was to install go language. For that you can just follow something like this.

Next we need to init this as a go module this is basically to help us to manage go dependencies.

For this first step we ended with

go mod init balhau.net/receita-provider 

the output of this command was the creation of the go.mod file.

Since the goal here is to build a terraform provider we must add the terraform libraries needed for that. This can be achieved with

go get

To be able to use this terraform plugin you'll need to build this go project with

go build

And then move the binary into your terraform plugin directory, something like this

~/.terraform.d/plugins/terraform.local/balhau/receita/1.0.0/darwin_amd64/terraform-provider-receita

Running?

Setting the http mock server

After previous steps were taken of we are ready to run the receita terraform provider. The provider will do some http calls to the endpoint defined in the provider definition. This means that we should put a service running that matches the description in the endpoint definition

provider "receita" {
  endpoint = "http://localhost:9999"
}

Running this

Managing terraform providers involves a bit of typing in the command line. To avoid typing to much we have here a Makefile with most of the command line instructions we need.

To figure out how to use this makefile just type

make help

help:                    Show this help.
clean-bin:               Clean all the generated binaries
clean-terraform-state:   Clean all the terraform state generated by terraform-init/terraform-apply
clean:                   Clean all the generated resources
terraform-init:          Execute terraform-init on example terraform directory
terraform-apply:         Execute terraform-apply on example directory
build:                   Build binaries, both the backed dummy server as the terraform provider binary
install-provider:        Install provider in the terraform plugin directory
run-backend:             Start the backend web server