Giter Club home page Giter Club logo

terraform-provider-dataprocessor's Introduction

terraform-provider-dataprocessor

CI Go Report Card Apache 2 licensed GitHub release (latest SemVer) Terraform regsitry

Avoid ugly terraform logic and code to transform data. This Terraform provider helps you with the data processing in a clean and easy way by using tools like JQ, YQ and Go plugins.

Processors

JQ

The famous and well known JQ processor for your JSON inputs.

YQ

The famous and well known YQ processor for your YAML inputs.

Go plugins v1

Check examples:

  • FS check: Checks files exist on disk. Shows how you can access the FS outside the plugin.
  • Complex validation: Validate Prometheus Rules. Shows how to create advanced logic plugins.
  • Data structure transformation: Transforms a data structure into another. Shows how to transform data for easier consumption by different terraform providers.
  • Filtering: Filters a list of usernames based on a regex. Shows how to filter terraform data to avoid HCL complex logic.
  • Remote plugin: Uses a plugin that is hosted in github. Shows how plugins can be shared and create plugin repos.
  • Simple validation: Validates the length of a string. Shows that simple validation plugins can be powerful (like small functions), perfect to be used as a remote plugin.

The processor for everything ๐ŸŽ‰, is the most powerful of all. You can use almost (e.g unsafe package is banned) all the Go standard library. These are the requirements to create a plugin:

  • Written in Go.
  • No external dependencies, only Go standard library.
  • Implemented in a single file (or string block).
  • Implement the plugin API (Check the examples to know how to do it).
    • The Filter function should be called:ProcessorPluginV1.
    • The Filter function should have this signature: ProcessorPluginV1(ctx context.Context, inputData string, vars map[string]string) (result string, error error).

This is the simplest plugin that you could create, a noop:

package tfplugin

import "context"

func ProcessorPluginV1(ctx context.Context, inputData string, vars map[string]string) (string, error) {
 return inputData, nil
}

However you can do complex things like loading JSON, HTTP requests, using timers, complex regex validations, templating...

Go plugins are implemented with Yaegi, so they are portable and can run anywhere terraform can run.

Use cases

  • Generate, filter, mutate... JSON data.
  • Retrieve JSON data from APIs, process and use it on other Terraform providers resources.
  • Remove ugly HCL code in favor of a more clean and powerful data processing approach.
  • Data validation (including complex cases).

Requirements

  • Terraform >=1.x.

Terraform cloud

The provider its compatible with Terraform cloud workers, its focused on portability and thats why it doesn't require any binary CLI.

Development

To install your plugin locally you can do make install, it will build and install in your ${HOME}/.terraform/plugins/...

Note: The installation is ready for OS_ARCH=linux_amd64, so you make need to change the Makefile if using other OS.

Example:

cd ./examples/local
rm -rf ./.terraform ./.terraform.lock.hcl
cd -
make install
cd -
terraform plan

terraform-provider-dataprocessor's People

Contributors

slok avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.