Git Product home page Git Product logo

terraform-provider-reqres's Introduction

Reqres(Terraform Custom Provider)


This is a custom provider of terraform based on Golang for an online fake API 'Reqres'

Prerequisites


  • Linux based machine
  • Terraform 0.10.x
  • Go 1.9 (to build the provider plugin)

Building the Provider


Create a directory for GoWorkspace and for the session, set the environmant variable 'GOPATH' pointing to it

$ mkdir ~/goWorkspace; cd ~/goWorkspace
$ export GOPATH=$(pwd)

Clone repository to: $GOPATH/src/github.com/hashicorp/terraform-providers/terraform-provider-reqres

$ mkdir -p $GOPATH/src/github.com/hashicorp/terraform-providers
$ cd $GOPATH/src/github.com/hashicorp/terraform-providers
$ git clone https://github.com/mehrosejethi/terraform-provider-reqres.git

Clone the Terraform library to: `$GOPATH/src/github.com/hashicorp/terraform'

$ cd $GOPATH/src/github.com/hashicorp/
$ git clone https://github.com/hashicorp/terraform.git

Enter the provider directory and build the provider. A plugin by the name of 'terraform-provider-reqres' is created in the same folder

$ cd $GOPATH/src/github.com/hashicorp/terraform-providers/terraform-provider-reqres
$ go build -o terraform-provider-reqres

Using the Provider


Copy the provider build in the last step and place it in the same directory in which the terraform configuration files are written

$ cp $GOPATH/src/github.com/hashicorp/terraform-providers/terraform-provider-reqres/terraform-provider-reqres terraform_config_file_dir

Create configuration files involving the provider 'reqres'

Provider details


Resources

  • reqres_create_user: Provides a resource to call the POST method of the api(/api/users) to create user in reqres.in returing id and creation time.
    • Arguements: The following arguments are supported:
      • request_body(required): It is stringified JSON request for the body of the POST method. Eg. "{"name": "morpheus","job": "leader"}
    • Reference: In addition to all arguments above, the following attributes are exported:
      • id: The id generated for the resource(timestamp)
      • body: The response of the request

Data Sources

  • data_source_single_user: This data source fetches the details of a user on reqres.in based on its ID.

    • Arguements: The following arguments are supported:
      • user_id(required): The user id of which details are to be fetched
    • Reference: In addition to all arguments above, the following attributes are exported:
      • id: The id generated for the data source(timestamp)
      • body: The response of the request
  • data_source_users_per_page: This data source fetches the details of all the users on reqres.in based on the page number.

    • Arguements: The following arguments are supported:
      • page(required): The page number on which details are to be fetched
    • Reference: In addition to all arguments above, the following attributes are exported:
      • id: The id generated for the data source(timestamp)
      • body: The response of the request

Screenshots


Configuration File

Alt text

Terraform Plan

Alt text

Terrafrom Apply(Execution)

Alt text

Output in JSON

Alt text

terraform-provider-reqres's People

Contributors

mehrosejethi avatar

Watchers

James Cloos 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.