terraform-provider-cleura

command module
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2024 License: MPL-2.0 Imports: 5 Imported by: 0

README

Terraform Provider Cleura (Terraform Plugin Framework)

Built on https://github.com/hashicorp/terraform-provider-scaffolding-framework template repository.

Requirements

Developing the Provider

Installing

If you wish to work on the provider, you'll first need Go installed on your machine (see Requirements above).

To compile the provider, run go install. This will build the provider and put the provider binary in the $GOPATH/bin directory.

Run go env GOPATH to find our $GOPATH

To generate or update documentation, run go generate.

Testing local provider version

In order to create resources with dev version of cleura provider, you have to setup terraform to run local version of the provider:

  1. Create/modify ~/.terraformrc file with the following content:

     provider_installation {
    
         dev_overrides {
             "app.terraform.io/accelerate-at-iver/cleura" = "$GOPATH/bin" # set path to provider binary here
         }
    
         # For all other providers, install them directly from their origin provider
         # registries as normal. If you omit this, Terraform will _only_ use
         # the dev_overrides block, and so no other providers will be available.
         direct {}
    
     }
    
    
  2. Configure provider:

     #provider.tf
    
     terraform {
         required_providers {
             cleura = {
                 source = "app.terraform.io/accelerate-at-iver/cleura"
             }
         }
     }
    
     provider "cleura" {
         host     = "https://rest.cleura.cloud" # CLEURA_API_HOST
         username = "<username>" # CLEURA_API_USERNAME
         token = "<token>" # CLEURA_API_TOKEN
     }
    
    
  3. Refer to example resource declaration under examples folder

Running automated tests

In order to run the full suite of Acceptance tests, run make testacc.

Note: Acceptance tests create real resources, and often cost money to run.

make testacc

Check test configuration code under internal/provider/testdata//

Using the published version of the provider

The accelerate-at-iver/cleura provider is published in the private terraform registry on the Terraform cloud. To use it, you would need to add the following snippet to the ~/.terrformrc file:

credentials "app.terraform.io" {
  # valid user API token:
  token =<USER_TOKEN>
}

where USER_TOKEN is the token generated in terraform cloud. Refer to the official documentation

Make sure that you comment out the provider_installation{} section if you are switching from development mode.

Getting CLEURA_API_TOKEN

Instead of curling Cleura API directly to get user token, you could try a helper cli tool. Install via :

go install github.com/aztekas/cleura-client-go/cmd/cleura@v0.0.1

To get token use cleura token get command. It supports several methods to supply your Cleura credentials:

❯ cl token get -h
NAME:
   cleura token get - Receive token from Cleura API using username and password                                                                                                                                                                 USAGE:
   cleura token get [command options] [arguments...]                                                                                                                                                                                            DESCRIPTION:
   Receive token from Cleura API using username and password

OPTIONS:
   --username value, -u value      Username for token request [$CLEURA_API_USERNAME]
   --password value, -p value      Password for token request. [$CLEURA_API_PASSWORD]
   --api-host value, --host value  Cleura API host (default: "https://rest.cleura.cloud") [$CLEURA_API_HOST]
   --update-config                 Save token to active configuration. NB: token saved in open text (default: false)
   --config-path value             Path to configuration file. $HOME/.config/cleura/config if not set
   --interactive, -i               Interactive mode. Input username and password in interactive mode (default: false)
   --two-factor, --2fa             Set this flag if two-factor authentication (sms) is enabled in your cleura profile  (default: false)
   --help, -h                      show help

On successful authentication you will get an output in the following format:

export CLEURA_API_TOKEN=<GENERATED TOKEN>
export CLEURA_API_USERNAME=<YOUR EMAIL>
export CLEURA_API_HOST=https://rest.cleura.cloud

Check latest cli version: https://github.com/aztekas/cleura-client-go

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL