In this article we describe how to automate the user entry process over various applications using Terraform. In this example the process creates automatically a user in Bexio using the provided Bexio API.
The solution we choose was to use a custom Terraform provider with Golang. Our WGC Bexio provider is a terraform provider to read, write and search contacts in Bexio. The provider code is not restricted to the Bexio API it can be modified to work with any other REST API.
New employees at WebGate Consulting AG are created through an automatic process controlled by Terraform. As of now, a media break occurred when onboarding employees into our ERP software Bexio.
The employees in Bexio were entered manually, which was error-prone and poor in terms of timing. Since Bexio has a REST API, we wrote a Terraform provider for the API to complete the onboarding process automatically.
In our onboarding process of employees, our objective is to setup the user once and the process creates the user in the required systems automatically. We analysed how to solve this with Terraform using a custom provider. Since there was no solution yet, we built one ourselves.
To learn Go, our approach was a simple GET-call to the Bexio API without Terraform. After this script ran without any problems, we cloned the Hashicups Example Project and modified the read-function to our needs. We connected our simple GET-call to the read function and added additional functions to format the output.
Now that we understood the basics, we started implementing all the specified features. These include create and search data sources. Testcases accompanied our development phase.
How it works
In Terraform (main.tf) search for the code snipped to the right and add your API-Token. This will ensure the authentication to the Bexio API. With the current setup, after you have added your API-Token it should just work out of the Box.
If you want to call a different REST API change the url as well as the API-Token for the corresponding API.
In the code snipped to the right all the search calls to the API are carried out. This is required for the create step in our Terraform file.
The configuration to the right shows, that an id for the salutation, language and country is required. This is used from the calls above. All the remaining configuration elements can be filled with user/contact information. Here you find a list of the required information.
As you can see in the provided information we have the id fields filled with the ids form the search calls.
The Swiss Army knife for SME accounting in Switzerland. Bexio is a Swiss market leader for cloud-based business software for small companies.
About WebGate Consulting AG
We at WebGate Consulting AG have a passion for our customers and their success. Our offer starts with business analysis and consulting and ends with the operation of your solution created by us. We are happy to provide you with our know-how in the areas of DevOps, Terraform/Terragrunt.
Authors: David Bürgler Nathan Fahrni
#thisiswebgate #bexio #terraformprovider #buchhhaltung