Documentation ¶
Overview ¶
Package terraform provides Temporal workflows to work with Terraform as a fault-tolerant integration.
Index ¶
- Constants
- type Config
- type Handler
- func (h *Handler) Close() error
- func (h *Handler) Config() integration.Config
- func (h *Handler) ConfigMap() map[string]any
- func (h *Handler) Init() error
- func (h *Handler) IsReady() bool
- func (h *Handler) ListActivities() []string
- func (h *Handler) ListWorkflows() []string
- func (h *Handler) Register(w worker.Worker) error
- func (h *Handler) String() string
- type InputDeployFromCDK
- type OutputDeployFromCDK
- type Policies
Constants ¶
const Integration string = "terraform"
Integration is the string representation of the Terraform integration.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Integration represents the common config shared across all integrations. Integration integration.Config `json:"integration"` // Version lets you set the Terraform version to download and install. It will // be installed at the PathToBinary set. // // Example: "1.2.0" // // Defaults to "1.2.6". Version string `json:"version"` // PathToBinary is the absolute path where the Terraform binary will be // downloaded to. // // Example: "/usr/local/bin" // // Defaults to OS temp directory. PathToBinary string `json:"path_to_binary"` // PathToFiles is the absolute path where Terraform files for each workflow // will be downloaded and copied to. This includes the tradition files such as // plugins, as well as the plan and manifest files passed in the workflow // input. // // Example: "/tmp/workflows" // // Required. PathToFiles string `json:"path_to_files"` // SkipCleanup allows to skip the cleanup activity which is in charge of // removing Terraform files when a workflow is completed. Skipping this // activity means all Terraform plugins and related files for each workflow // will be stored and kept even after the workflow has completed. This can be // useful in some cases but uses disk storage. SkipCleanup bool `json:"skip_cleanup"` // Policies allows to set activity policies, such as timeouts and retries. Policies Policies `json:"policies"` }
Config is the configuration an end-user should set to configure the Terraform integration.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler handles the Terraform integration and gives access to related workflows and activities.
func New ¶
New returns a new terraform Handler. It applies the configuration passed by the end-user.
func (*Handler) Close ¶
Close closes the integration. An error is returned in case the Handler has already been closed.
func (*Handler) Config ¶ added in v0.12.0
func (h *Handler) Config() integration.Config
Config returns the common integration's Config, which is the Config shared by all integrations.
func (*Handler) Init ¶
Init initializes the integration. An error is returned in case the Handler has already been initialized.
func (*Handler) IsReady ¶
IsReady returns if the integration is ready to be consumed by the end-user. The integration must be initialized and must not be closed.
func (*Handler) ListActivities ¶
ListActivities returns a sorted list of activities' name registered by the integration.
func (*Handler) ListWorkflows ¶
ListWorkflows returns a sorted list of workflows' name registered by the integration.
type InputDeployFromCDK ¶
type InputDeployFromCDK struct { // Policies passed in the input can override the ones set when creating the // specification. It will only apply if allowed in the integration's Config // via AllowPoliciesOverride. Policies *Policies `json:"policies"` // Context represents the event's context, shared across every specifications // and integrations of this ecosystem. Context *event.Context `json:"context,omitempty"` // Provisions is the content of the file generated by Terraform CDK. // // From the root directory of your CDK project, this file should be located at: // "./cdktf.out/stacks/<stack>/cdk.tf.json". // // Required. Provisions []byte `json:"provisions"` // ManifestRoot is the content of the Terraform CDK JSON file at the root // directory of your project. It is not used by the workflow and activities but // allows to add more context about the stack to deploy. // // From the root directory of your CDK project, this file should be located at: // "./cdk.tf.json". ManifestRoot []byte `json:"manifest_root,omitempty"` // ManifestStacks is the content of the Terraform CDK JSON file of the stacks // of your project. It is not used by the workflow and activities but allows // to add more context about the stack to deploy. // // From the root directory of your CDK project, this file should be located at: // "./stacks/manifest.json". ManifestStacks []byte `json:"manifest_stacks,omitempty"` }
InputDeployFromCDK is the input for the "DeployFromCDK" workflow and activities.
func (*InputDeployFromCDK) Validate ¶
func (input *InputDeployFromCDK) Validate(config *Config) error
Validate can be used to validate the workflow/activity's input. It's the validation function used in the local activity activityDeployFromCDKValidation.
type OutputDeployFromCDK ¶
type OutputDeployFromCDK struct { // Status is the status of the workflow or activity. It's one of "success", // "failure". Status lifecycle.Status `json:"status"` // State is the Terraform state returned after Terraform deployed/applied the // infrastructure changes. State *tfjson.State `json:"state"` }
OutputDeployFromCDK is the output for the "DeployFromCDK" workflow and activities.
type Policies ¶
type Policies struct { // TerraformInit is the policy to apply by the activity used to initialize the // Terraform environment, which is also in charge of downloading required // plugins. TerraformInit lifecycle.ActivityPolicy `json:"terraform_init"` // TerraformApply is the policy to apply by the activity used to deploy the // infrastructure managed by Terraform resources. TerraformApply lifecycle.ActivityPolicy `json:"terraform_apply"` // LocalExecs is the policy to apply by the activities used to write and delete // files on local disk. // // Note: Since this is a short-live policy, activity's heartbeat is not used. // Therefore, LocalExecs.HeartbeatTimeout is not applied. We advise to set a // short-live LocalExecs.SingleAttemptTimeout, such as 3 seconds. LocalExecs lifecycle.ActivityPolicy `json:"local_execs"` // contains filtered or unexported fields }
Policies represents the Temporal activity policies to apply within the workflows exposed by this package and the overlying integration.