cli

package
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInitRequired = errors.New("the Terraform AWS provider is not installed")

ErrInitRequired indicates the Terraform AWS provider is not installed — typically because `terraform init` has not been run yet. Detected with errors.Is; the actionable next-step is carried by the error event, not here.

Functions

func DeactivateAccessKey

func DeactivateAccessKey(accessKey string) string

DeactivateAccessKey neutralizes a real-looking AWS access key id so a live credential is never baked into the generated override file nor sent to LocalStack (where it could be captured by analytics by accident).

AWS access key ids begin with an "A" (e.g. "AKIA…" for long-term keys, "ASIA…" for temporary session keys). Replacing that leading "A" with "L" renders the key inert while leaving obviously-mock values (e.g. "test", or a 12-digit account id) untouched. This mirrors tflocal's deactivate_access_key safeguard — see https://docs.localstack.cloud/references/credentials/.

func EndpointKeys

func EndpointKeys(ctx context.Context, tfBin, workdir string) ([]string, error)

EndpointKeys returns the AWS service endpoint keys to write into the generated `endpoints {}` block, discovered from the installed provider schema via `<tfBin> providers schema -json`. It supports the AWS provider 4.0+.

There is no fallback list. If the schema cannot be retrieved (provider not installed, e.g. before `terraform init`) it returns ErrInitRequired; if the schema is present but exposes no endpoint keys it returns a plain error. In both cases the caller must fail rather than generate an override.

func IsUnproxied

func IsUnproxied(args []string) bool

IsUnproxied reports whether the terraform invocation described by args is one of the unproxied subcommands. The subcommand is the first argument that is not a flag (terraform's global options, e.g. -chdir, precede the subcommand).

func Run

func Run(ctx context.Context, endpointURL, region, account, chdir string, sink output.Sink, logger log.Logger, args []string) error

Run proxies a terraform invocation against LocalStack. For proxied commands it discovers the AWS provider's endpoint keys from the schema, generates a provider-override file pointing every aws provider/alias block at the resolved endpoint, runs terraform, and removes the generated file afterward. Unproxied subcommands (fmt/validate/version) run terraform directly without an override and do not require a resolved endpoint.

endpointURL is the resolved LocalStack endpoint (http://host:port); it may be empty for unproxied commands. region and account are encoded into each generated provider block. chdir is terraform's -chdir=DIR value ("" when absent); when set, lstk anchors all of its directory-relative work (schema discovery, override generation, cleanup) to that directory rather than the process working directory, mirroring the switch terraform itself makes.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL