A plugin for Terraform to control / integrate with Octopus Deploy.
This is a work in progress. More providers and data-sources are planned, as well as a Provisioner to install the Octopus tentacle.
Tested against Octopus Deploy v3.3.17.
The following resource types are currently supported:
octopus_environment
: Creates and manages an Octopus Deploy environmentoctopus_variable
: Creates and manages an Octopus Deploy variable (currently only project-level variables are supported)Note that variables are matched on both name and combined scopes (Environments, Roles, Machines, Actions). If a variable already exists with the specified name and scopes, the provider will start managing the existing variable.
The following data-source types are currently supported:
octopus_environment
: Tracks an existing Octopus Deploy environmentoctopus_machine
: Tracks an existing Octopus Deploy machineoctopus_project
: Tracks an existing Octopus Deploy projectoctopus_variable
: Tracks an existing Octopus Deploy variable (currently only project-level variables are supported)Data-sources are similar to variables, except they are read-only. The provider will read and track their state but never modify it.
To get started:
$HOME\terraform.rc
~/.terraformrc
And add the following contents:
providers {
octopus = "path-to-the-folder/containing/terraform-provider-octopus"
}
Create a folder containing a single .tf
file:
#
# This configuration will create an Octopus environment called "MyEnvironment" and configure a project-level variable named "MyVariable" to be scoped to it.
#
provider "octopus" {
server_url = "https://my-octopus-server/"
api_key = "my-octopus-api-key"
}
# Projects are a data source - the provider can read from them but not create or manage them.
data "octopus_project" "my_project" {
slug = "terraformtest" # The last segment of the URL in the browser when viewing the project home page.
}
data "octopus_machine" "my_machine" {
slug = "Machines-351" # The last segment of the URL in the browser when viewing the machine details home page.
}
resource "octopus_environment" "my_environment" {
name = "MyEnvironment"
}
resource "octopus_variable" "my_variable" {
# This is the Id (or slug) of the project in which the variable is defined.
project = "${data.octopus_project.my_project.id}"
name = "MyVariable"
value = "Hello World"
# The scopes (environment, role, machine, action) to which the variable applies.
environments = ["${octopus_environment.my_environment.id}"]
}
terraform plan -out tf.plan
.terraform apply tf.plan
terraform show
to inspect the current state.terraform plan -destroy -out tf.plan
terraform apply tf.plan