package
3.55.1-dev.0
Repository: https://github.com/mrod-io/pulumi.git
Documentation: pkg.go.dev

# README

Automation API

Programmatic infrastructure.

Godocs

See the full godocs for the most extensive and up to date information including full examples coverage:

https://pkg.go.dev/github.com/pulumi/pulumi/sdk/v3/go/auto?tab=doc

Examples

Multiple full working examples with detailed walkthroughs can be found in this repo:

https://github.com/pulumi/automation-api-examples

Overview

Package auto contains the Pulumi Automation API, the programmatic interface for driving Pulumi programs without the CLI. Generally this can be thought of as encapsulating the functionality of the CLI (pulumi up, pulumi preview, pulumi destroy, pulumi stack init, etc.) but with more flexibility. This still requires a CLI binary to be installed and available on your $PATH.

In addition to fine-grained building blocks, Automation API provides three out of the box ways to work with Stacks:

  1. Programs locally available on-disk and addressed via a filepath (NewStackLocalSource)
    stack, err := NewStackLocalSource(ctx, "myOrg/myProj/myStack", filepath.Join("..", "path", "to", "project"))
  1. Programs fetched from a Git URL (NewStackRemoteSource)
	stack, err := NewStackRemoteSource(ctx, "myOrg/myProj/myStack", GitRepo{
		URL:         "https:github.com/pulumi/test-repo.git",
		ProjectPath: filepath.Join("project", "path", "repo", "root", "relative"),
    })
  1. Programs defined as a function alongside your Automation API code (NewStackInlineSource)
	 stack, err := NewStackInlineSource(ctx, "myOrg/myProj/myStack", "myProj", func(pCtx *pulumi.Context) error {
		bucket, err := s3.NewBucket(pCtx, "bucket", nil)
		if err != nil {
			return err
		}
		pCtx.Export("bucketName", bucket.Bucket)
		return nil
     })

Each of these creates a stack with access to the full range of Pulumi lifecycle methods (up/preview/refresh/destroy), as well as methods for managing config, stack, and project settings.

	 err := stack.SetConfig(ctx, "key", ConfigValue{ Value: "value", Secret: true })
	 preRes, err := stack.Preview(ctx)
	 detailed info about results
     fmt.Println(preRes.prev.Steps[0].URN)

The Automation API provides a natural way to orchestrate multiple stacks, feeding the output of one stack as an input to the next as shown in the package-level example below. The package can be used for a number of use cases:

  • Driving pulumi deployments within CI/CD workflows
  • Integration testing
  • Multi-stage deployments such as blue-green deployment patterns
  • Deployments involving application code like database migrations
  • Building higher level tools, custom CLIs over pulumi, etc
  • Using pulumi behind a REST or GRPC API
  • Debugging Pulumi programs (by using a single main entrypoint with "inline" programs)

To enable a broad range of runtime customization the API defines a Workspace interface. A Workspace is the execution context containing a single Pulumi project, a program, and multiple stacks. Workspaces are used to manage the execution environment, providing various utilities such as plugin installation, environment configuration ($PULUMI_HOME), and creation, deletion, and listing of Stacks. Every Stack including those in the above examples are backed by a Workspace which can be accessed via:

	 w = stack.Workspace()
     err := w.InstallPlugin("aws", "v3.2.0")

Workspaces can be explicitly created and customized beyond the three Stack creation helpers noted above:

	 w, err := NewLocalWorkspace(ctx, WorkDir(filepath.Join(".", "project", "path"), PulumiHome("~/.pulumi"))
     s := NewStack(ctx, "org/proj/stack", w)

A default implementation of workspace is provided as LocalWorkspace. This implementation relies on Pulumi.yaml and Pulumi..yaml as the intermediate format for Project and Stack settings. Modifying ProjectSettings will alter the Workspace Pulumi.yaml file, and setting config on a Stack will modify the Pulumi..yaml file. This is identical to the behavior of Pulumi CLI driven workspaces. Custom Workspace implementations can be used to store Project and Stack settings as well as Config in a different format, such as an in-memory data structure, a shared persistent SQL database, or cloud object storage. Regardless of the backing Workspace implementation, the Pulumi SaaS Console will still be able to display configuration applied to updates as it does with the local version of the Workspace today.

The Automation API also provides error handling utilities to detect common cases such as concurrent update conflicts:

	uRes, err :=stack.Up(ctx)
	if err != nil && IsConcurrentUpdateError(err) { /* retry logic here */ }

Developing the Godocs

This repo has extensive examples and godoc content. To test out your changes locally you can do the following:

  1. enlist in the appropriate pulumi branch:
  2. cd $GOPATH/src/github.com/pulumi/pulumi/sdk/go/auto
  3. godoc -http=:6060
  4. Navigate to http://localhost:6060/pkg/github.com/pulumi/pulumi/sdk/v3/go/auto/

Known Issues

Please upvote issues, add comments, and open new ones to help prioritize our efforts: https://github.com/pulumi/pulumi/issues?q=is%3Aissue+is%3Aopen+label%3Aarea%2Fautomation-api

# Packages

No description provided by the author
No description provided by the author
Package optdestroy contains functional options to be used with stack destroy operations github.com/sdk/v2/go/x/auto Stack.Destroy(...optdestroy.Option).
Package opthistory contains functional options to be used with stack history operations github.com/sdk/v3/go/x/auto Stack.History(ctx, pageSize, page, ...opthistory.Option).
Package optpreview contains functional options to be used with stack preview operations github.com/sdk/v2/go/x/auto Stack.Preview(...optpreview.Option).
Package optrefresh contains functional options to be used with stack refresh operations github.com/sdk/v2/go/x/auto Stack.Refresh(...optrefresh.Option).
Package optremotedestroy contains functional options to be used with remote stack destroy operations github.com/sdk/v3/go/auto RemoteStack.Destroy(...optremotedestroy.Option).
Package optremotepreview contains functional options to be used with remote stack preview operations github.com/sdk/v3/go/auto RemoteStack.Preview(...optremotepreview.Option).
Package optremoterefresh contains functional options to be used with remote stack refresh operations github.com/sdk/v3/go/auto RemoteStack.Refresh(...optremoterefresh.Option).
Package optremoteup contains functional options to be used with remote stack updates github.com/sdk/v3/go/auto RemoteStack.Up(...optremoteup.Option).
Package optremove contains functional options to be used with workspace stack remove operations github.com/sdk/v2/go/x/auto workspace.RemoveStack(stackName, ...optremove.Option).
Package optup contains functional options to be used with stack updates github.com/sdk/v2/go/x/auto Stack.Up(...optup.Option).

# Functions

EnvVars is a map of environment values scoped to the workspace.
FullyQualifiedStackName returns a stack name formatted with the greatest possible specificity: org/project/stack or user/project/stack Using this format avoids ambiguity in stack identity guards creating or selecting the wrong stack.
GetPermalink returns the permalink URL in the Pulumi Console for the update or refresh operation.
IsCompilationError returns true if the program failed at the build/run step (only Typescript, Go, .NET).
IsConcurrentUpdateError returns true if the error was a result of a conflicting update locking the stack.
IsCreateStack409Error returns true if the error was a result of creating a stack that already exists.
IsRuntimeError returns true if there was an error in the user program at during execution.
IsSelectStack404Error returns true if the error was a result of selecting a stack that does not exist.
IsUnexpectedEngineError returns true if the pulumi core engine encountered an error (most likely a bug).
NewLocalWorkspace creates and configures a LocalWorkspace.
PREVIEW: NewRemoteStackGitSource creates a Stack backed by a RemoteWorkspace with source code from the specified GitRepo.
NewStack creates a new stack using the given workspace, and stack name.
NewStackInlineSource creates a Stack backed by a LocalWorkspace created on behalf of the user, with the specified program.
NewStackLocalSource creates a Stack backed by a LocalWorkspace created on behalf of the user, from the specified WorkDir.
NewStackRemoteSource creates a Stack backed by a LocalWorkspace created on behalf of the user, with source code cloned from the specified GitRepo.
Program is the Pulumi Program to execute.
Project sets project settings for the workspace.
PulumiHome overrides the metadata directory for pulumi commands.
RemoteEnvVars is a map of environment values scoped to the remote workspace.
RemotePreRunCommands is an optional list of arbitrary commands to run before the remote Pulumi operation is invoked.
RemoteSkipInstallDependencies sets whether to skip the default dependency installation step.
Repo is a git repo with a Pulumi Project to clone into the WorkDir.
SecretsProvider is the secrets provider to use with the current workspace when interacting with a stack.
PREVIEW: SelectRemoteStackGitSource selects an existing Stack backed by a RemoteWorkspace with source code from the specified GitRepo.
SelectStack selects stack using the given workspace, and stack name.
SelectStackInlineSource selects an existing Stack backed by a new LocalWorkspace created on behalf of the user, with the specified program.
SelectStackLocalSource selects an existing Stack backed by a LocalWorkspace created on behalf of the user, from the specified WorkDir.
SelectStackRemoteSource selects an existing Stack backed by a LocalWorkspace created on behalf of the user, with source code cloned from the specified GitRepo.
Stacks is a list of stack settings objects to seed the workspace.
PREVIEW: UpsertRemoteStackGitSource creates a Stack backed by a RemoteWorkspace with source code from the specified GitRepo.
UpsertStack tries to select a stack using the given workspace and stack name, or falls back to trying to create the stack if it does not exist.
UpsertStackInlineSource creates a Stack backed by a LocalWorkspace created on behalf of the user, with the specified program.
UpsertStackLocalSource creates a Stack backed by a LocalWorkspace created on behalf of the user, from the specified WorkDir.
UpsertStackRemoteSource creates a Stack backed by a LocalWorkspace created on behalf of the user, with source code cloned from the specified GitRepo.
WorkDir is the directory to execute commands from and store state.

# Variables

ErrParsePermalinkFailed occurs when the the generated permalink URL can't be found in the op result.

# Structs

ConfigValue is a configuration value used by a Pulumi program.
DestroyResult is the output of a successful Stack.Destroy operation.
EnvVarValue represents the value of an envvar.
GitAuth is the authentication details that can be specified for a private Git repo.
GitRepo contains info to acquire and setup a Pulumi program from a git repository.
LocalWorkspace is a default implementation of the Workspace interface.
OutputValue models a Pulumi Stack output, providing the plaintext value and a boolean indicating secretness.
PreviewResult is the output of Stack.Preview() describing the expected set of changes from the next Stack.Up().
PreviewStep is a summary of the expected state transition of a given resource based on running the current program.
PropertyDiff contains information about the difference in a single property value.
RefreshResult is the output of a successful Stack.Refresh operation.
RemoteStack is an isolated, independently configurable instance of a Pulumi program that is operated on remotely (up/preview/refresh/destroy).
Stack is an isolated, independently configurable instance of a Pulumi program.
StackSummary is a description of a stack and its current status.
UpdateSummary provides a summary of a Stack lifecycle operation (up/preview/refresh/destroy).
UpResult contains information about a Stack.Up operation, including Outputs, and a summary of the deployed changes.

# Interfaces

LocalWorkspaceOption is used to customize and configure a LocalWorkspace at initialization time.
LocalWorkspaceOption is used to customize and configure a LocalWorkspace at initialization time.
Workspace is the execution context containing a single Pulumi project, a program, and multiple stacks.

# Type aliases

ConfigMap is a map of ConfigValue used by Pulumi programs.
OutputMap is the output result of running a Pulumi program.
SetupFn is a function to execute after enlisting in a git repo.