Terraform

public class Terraform

A Terraform object is a wrapper around the terraform executable. It can be used to perform common operations like planning and applying changes, retrieving provider schemas and retrieving versions

This class is the only object to be instanciated directly by the user.

  • Undocumented

    Declaration

    Swift

    public static let defaultTerraformVersion: String
  • Undocumented

    Declaration

    Swift

    public struct InvocationSettings
  • Undocumented

    See more

    Declaration

    Swift

    public enum TerraformError : Error
  • Configure a new Terraform environment. Terraform will be downloaded if necessary.

    Declaration

    Swift

    public init?(
        configuration: AnyEncodable? = nil,
        workingDirectoryURL : URL? = nil,
        version : String = Terraform.defaultTerraformVersion,
        terraformExecutable: URL? = nil,
        colorMode : ColorMode = .none
    )

    Parameters

    configuration

    An Encodable to be used as Terraform configuration. This object will be encoded using the JSON decoder and saved to a file called main.tf.json

    workingDirectoryURL

    URL of Terraforms working directory. If left empty, a temporary directory will be created

    version

    The version of Terraform to be used

    terraformExecutable

    URL of the Terraform executable to use. If this value is not present TerraformKit will download a suitable release of Terraform

    colorMode

    Whether to emit colored output

  • Remove the temporary working directory of terraform. Calling this function is not allowed, if a working directory was specified in the initializer

    Declaration

    Swift

    public func cleanup()
  • Run terraform init

    Declaration

    Swift

    public func initialize(invocationSettings: InvocationSettings? = nil) throws
  • Run terraform plan

    Declaration

    Swift

    public func plan(destroy: Bool = false,
                     invocationSettings: InvocationSettings? = nil
    ) throws -> Plan
  • Retrieve the current state

    Throws

    Declaration

    Swift

    public func state() throws -> State

    Return Value

    A State Object

  • Run terraform apply

    Declaration

    Swift

    public func apply(plan: Plan, invocationSettings: InvocationSettings? = nil) throws

    Parameters

    plan

    The plan to execute

  • Run terraform destroy

    Declaration

    Swift

    public func destroy(invocationSettings: InvocationSettings? = nil) throws
  • Fetch the current provider schema

    Declaration

    Swift

    public func schema() throws -> SchemaDescription

    Return Value

    The schema description

  • Determine the currenly used version of terraform and the versions of all installed providers

    Declaration

    Swift

    public func version() throws -> VersionDescription

    Return Value

    The current version of terraform and all configured providers