Panoramica
Terraform is a tool that allows you to create cloud and on-prem resources with human-readable configuration files that can be reused and shared. They can then be used to provision and manage infrastructure throughout its lifecycle.
How does it work?
Terraform creates and manages resources on cloud platforms and other services through their APIs. Providers enable Terraform to work with platforms or services with accessible APIs.
The Terraform workflow consists of three steps:
Create: you can define resources, which can be across multiple cloud providers and services. For example, you can create a configuration to deploy an application on a virtual machine within a Virtual Private Cloud VPC Plan: Terraform creates an execution plan describing the infrastructure that will be created, updated, or destroyed based on existing infrastructure and your configuration. Apply: after approval, Terraform executes the operations in the correct order, respecting each resource dependency. For example, if you update the properties of a VPC by changing the number of virtual machines in it, Terraform will recreate the VPC before scaling the virtual machines.
Terraform Provider for Seeweb
Configure the Provider
Clone the repository to: $GOPATH/src/github.com/Seeweb/terraform-provider-seeweb
$ mkdir -p $GOPATH/src/github.com/Seeweb; cd $GOPATH/src/github.com/Seeweb
$ git clone git@github.com:Seeweb/terraform-provider-seeweb
Enter the provider folder and configure it
$ cd $GOPATH/src/github.com/Seeweb/terraform-provider-seeweb
$ export GOPRIVATE=github.com/Seeweb/* # This step is only necessary if the modules are private
$ make build
Use the Locally Configured Provider
To test a local version of a Terraform Provider, execute these commands:
go build -o terraform-provider-seeweb
# The next location might be different on your machine, so you need to check first
mv terraform-provider-seeweb ~/.terraform.d/plugins/registry.terraform.io/hashicorp/seeweb/0.0.1/darwin_arm64
You can then require the Seeweb provider, as in the example:
Example
provider "seeweb" {} # Expecting Seeweb auth token in the env var $SEEWEB_TOKEN
resource "seeweb_server" "testacc" {
plan = "ECS1"
location = "it-fr2"
image = "centos-7"
notes = "Created with Terraform"
}
Testing
To test the provider, just execute make test
$make test
To run the full suite of acceptance tests, execute make testacc
. To run the tests, you must set the environment variable SEEWEB_TOKEN to a valid API Token.
Note
Acceptance tests create real resources, and running them is often costly.
$ make testacc
Run a specific subset of tests by name using the option TESTARGS="-run TestName"
which runs all test functions with "TestName" in the name.
$ make testacc TESTARGS="-run TestAccSeewebServer"
Reference
https://registry.terraform.io/providers/Seeweb/seeweb/latest/docs