cloudformation

package
v1.233.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildSyntheticBackendConfig

func BuildSyntheticBackendConfig(s3cfg *targetS3Config, componentConfig map[string]any, authContext *schema.AuthContext) map[string]any

BuildSyntheticBackendConfig builds a componentConfig-shaped map matching what pkg/provisioner/backend.ProvisionBackend and pkg/provisioner.ProvisionWithParams expect from a Terraform component's own stack manifest (top-level `backend_type`/`backend`, plus `provision.backend.enabled`) — letting the CFN backend verbs reuse the already-registered S3 backend type (pkg/provisioner/backend/s3.go's backendTypeS3) instead of introducing a second one for CFN's `kind: aws/s3` provision-target vocabulary. This is the "narrow seam" adapter: it lives entirely in this package, and pkg/provisioner/provisioner.go and pkg/provisioner/backend/*.go are untouched.

Region falls back through the target's own `region`, then `settings.aws_cloudformation.region` (resolveRegion — the same source apply/delete honor), then the active identity's resolved AWS region: pkg/provisioner/backend/s3.go's extractS3Config requires a non-empty region up front, before any AWS call is attempted.

Prefix is intentionally omitted from the returned `backend` block: pkg/provisioner/backend/s3.go's extractS3Config never reads a `prefix` key (it is specific to the aws/s3 artifact store used for template packaging, packaging.go's uploadPackage), so including it here would be misleading.

func Execute

func Execute(ctx *component.ExecutionContext, operation Operation) error

Execute runs a single aws/cloudformation component operation.

func FindS3BackendTargets

func FindS3BackendTargets(provisionSection map[string]any) map[string]*targetS3Config

FindS3BackendTargets enumerates every `kind: aws/s3` provision target as a resolved targetS3Config, keyed by target name, for `backend list`. Targets missing a required `bucket` are silently skipped rather than failing the whole listing — s3ConfigFromTarget's error is only actionable when a single target was selected (ResolveS3BackendTarget), not while enumerating many.

func ProvisionS3BackendTarget

func ProvisionS3BackendTarget(ctx context.Context, params *ProvisionS3BackendParams) error

ProvisionS3BackendTarget creates the target's bucket, or reconciles an existing one to the secure defaults (versioning, encryption, public-access block, tags). It backs the explicit `backend create`/`backend update` verbs. Unlike provisioner.ProvisionWithParams (which prints its success line before the warnings it collected), it prints the "settings will be replaced" warnings first, so the final line reports the completed result.

func RenderDeployedStacksList

func RenderDeployedStacksList(stacks []DeployedStackSummary)

RenderDeployedStacksList writes the list to the data channel (stdout) as a simple table with a header row: one line per stack, with a "managed"/"unmanaged" marker.

func ResolveS3BackendTarget

func ResolveS3BackendTarget(provisionSection map[string]any, flagTarget string) (*targetS3Config, error)

ResolveS3BackendTarget finds the `kind: aws/s3` provision target that `atmos aws cloudformation backend` commands manage: the single declared target, or the one named by flagTarget when more than one is declared. Mirrors resolveStackSetTarget's (stackset.go) explicit-when-ambiguous resolution — there is no default among several aws/s3 targets, and reuses ErrInvalidAwsCloudFormationSettings rather than a bespoke sentinel, matching resolvePackagingTarget's (provision.go) identical no-target/ambiguous-target cases.

func ResolveTargetAuth

func ResolveTargetAuth(atmosConfig *schema.AtmosConfiguration, info *schema.ConfigAndStacksInfo, targetName string, targetConfig map[string]any, requestedIdentity string) (*schema.ConfigAndStacksInfo, error)

ResolveTargetAuth authenticates one CFN delivery target without modifying its parent. The target name only labels diagnostics and the --identity=false warning.

func S3BackendDryRunSummary

func S3BackendDryRunSummary(componentConfig map[string]any, flagTarget, action string) (string, error)

S3BackendDryRunSummary resolves the `kind: aws/s3` target a backend verb would act on, from the component's static configuration alone (no AWS calls), and describes what the verb would do. The action argument is the verb phrase, for example "create" or "delete". It returns a wrapped ErrInvalidAwsCloudFormationSettings when no single target can be selected.

func ValidateStackStatusFilter

func ValidateStackStatusFilter(statusFilter []string) error

ValidateStackStatusFilter reports whether every --status value names a known CloudFormation stack status (case-insensitive). The CLI layer calls it before authenticating or describing stacks so a typo fails immediately.

Types

type CloudFormationClient

type CloudFormationClient interface {
	CreateChangeSet(ctx context.Context, params *cloudformation.CreateChangeSetInput, optFns ...func(*cloudformation.Options)) (*cloudformation.CreateChangeSetOutput, error)
	DescribeChangeSet(ctx context.Context, params *cloudformation.DescribeChangeSetInput, optFns ...func(*cloudformation.Options)) (*cloudformation.DescribeChangeSetOutput, error)
	DeleteChangeSet(ctx context.Context, params *cloudformation.DeleteChangeSetInput, optFns ...func(*cloudformation.Options)) (*cloudformation.DeleteChangeSetOutput, error)
	ExecuteChangeSet(ctx context.Context, params *cloudformation.ExecuteChangeSetInput, optFns ...func(*cloudformation.Options)) (*cloudformation.ExecuteChangeSetOutput, error)
	ListChangeSets(ctx context.Context, params *cloudformation.ListChangeSetsInput, optFns ...func(*cloudformation.Options)) (*cloudformation.ListChangeSetsOutput, error)
	DescribeStacks(ctx context.Context, params *cloudformation.DescribeStacksInput, optFns ...func(*cloudformation.Options)) (*cloudformation.DescribeStacksOutput, error)
	DescribeStackEvents(ctx context.Context, params *cloudformation.DescribeStackEventsInput, optFns ...func(*cloudformation.Options)) (*cloudformation.DescribeStackEventsOutput, error)
	DeleteStack(ctx context.Context, params *cloudformation.DeleteStackInput, optFns ...func(*cloudformation.Options)) (*cloudformation.DeleteStackOutput, error)
	ValidateTemplate(ctx context.Context, params *cloudformation.ValidateTemplateInput, optFns ...func(*cloudformation.Options)) (*cloudformation.ValidateTemplateOutput, error)
	UpdateTerminationProtection(ctx context.Context, params *cloudformation.UpdateTerminationProtectionInput, optFns ...func(*cloudformation.Options)) (*cloudformation.UpdateTerminationProtectionOutput, error)
	SetStackPolicy(ctx context.Context, params *cloudformation.SetStackPolicyInput, optFns ...func(*cloudformation.Options)) (*cloudformation.SetStackPolicyOutput, error)
	GetTemplate(ctx context.Context, params *cloudformation.GetTemplateInput, optFns ...func(*cloudformation.Options)) (*cloudformation.GetTemplateOutput, error)
	GetStackPolicy(ctx context.Context, params *cloudformation.GetStackPolicyInput, optFns ...func(*cloudformation.Options)) (*cloudformation.GetStackPolicyOutput, error)
	ListStacks(ctx context.Context, params *cloudformation.ListStacksInput, optFns ...func(*cloudformation.Options)) (*cloudformation.ListStacksOutput, error)
	DetectStackDrift(ctx context.Context, params *cloudformation.DetectStackDriftInput, optFns ...func(*cloudformation.Options)) (*cloudformation.DetectStackDriftOutput, error)
	DescribeStackDriftDetectionStatus(ctx context.Context, params *cloudformation.DescribeStackDriftDetectionStatusInput, optFns ...func(*cloudformation.Options)) (*cloudformation.DescribeStackDriftDetectionStatusOutput, error)
	DescribeStackResourceDrifts(ctx context.Context, params *cloudformation.DescribeStackResourceDriftsInput, optFns ...func(*cloudformation.Options)) (*cloudformation.DescribeStackResourceDriftsOutput, error)
	DescribeStackSet(ctx context.Context, params *cloudformation.DescribeStackSetInput, optFns ...func(*cloudformation.Options)) (*cloudformation.DescribeStackSetOutput, error)
	CreateStackSet(ctx context.Context, params *cloudformation.CreateStackSetInput, optFns ...func(*cloudformation.Options)) (*cloudformation.CreateStackSetOutput, error)
	UpdateStackSet(ctx context.Context, params *cloudformation.UpdateStackSetInput, optFns ...func(*cloudformation.Options)) (*cloudformation.UpdateStackSetOutput, error)
	DeleteStackSet(ctx context.Context, params *cloudformation.DeleteStackSetInput, optFns ...func(*cloudformation.Options)) (*cloudformation.DeleteStackSetOutput, error)
	CreateStackInstances(ctx context.Context, params *cloudformation.CreateStackInstancesInput, optFns ...func(*cloudformation.Options)) (*cloudformation.CreateStackInstancesOutput, error)
	DeleteStackInstances(ctx context.Context, params *cloudformation.DeleteStackInstancesInput, optFns ...func(*cloudformation.Options)) (*cloudformation.DeleteStackInstancesOutput, error)
	ListStackInstances(ctx context.Context, params *cloudformation.ListStackInstancesInput, optFns ...func(*cloudformation.Options)) (*cloudformation.ListStackInstancesOutput, error)
	DescribeStackSetOperation(ctx context.Context, params *cloudformation.DescribeStackSetOperationInput, optFns ...func(*cloudformation.Options)) (*cloudformation.DescribeStackSetOperationOutput, error)
	ListStackResources(ctx context.Context, params *cloudformation.ListStackResourcesInput, optFns ...func(*cloudformation.Options)) (*cloudformation.ListStackResourcesOutput, error)
}

CloudFormationClient is the subset of the AWS SDK v2 CloudFormation API used by this component type. Phase 1 covered the core lifecycle (changeset-driven apply/deploy, delete, validate, describe); Phase 2 added explicit changeset management, drift detection, template/policy retrieval, and account-wide listing. Phase 3 adds stack sets and nested-stack observability (tree/logs).

type ComponentProvider

type ComponentProvider struct{}

ComponentProvider implements the component.ComponentProvider interface for native aws/cloudformation components.

func (*ComponentProvider) Execute

Execute runs the requested subcommand for an aws/cloudformation component.

func (*ComponentProvider) GenerateArtifacts

func (p *ComponentProvider) GenerateArtifacts(_ *component.ExecutionContext) error

GenerateArtifacts is a no-op for aws/cloudformation components (the template is self-contained; no codegen-artifact output like Terraform's `generate`).

func (*ComponentProvider) GetAvailableCommands

func (p *ComponentProvider) GetAvailableCommands() []string

GetAvailableCommands returns the subcommands aws/cloudformation components support, derived from subCommandOperations so this list can never drift out of sync with what Execute actually dispatches.

func (*ComponentProvider) GetBasePath

func (p *ComponentProvider) GetBasePath(atmosConfig *schema.AtmosConfiguration) string

GetBasePath returns the base directory for aws/cloudformation components.

func (*ComponentProvider) GetGroup

func (p *ComponentProvider) GetGroup() string

GetGroup returns the component group for categorization.

func (*ComponentProvider) GetType

func (p *ComponentProvider) GetType() string

GetType returns the component type identifier.

func (*ComponentProvider) ListComponents

func (p *ComponentProvider) ListComponents(_ context.Context, _ string, stackConfig map[string]any) ([]string, error)

ListComponents discovers all aws/cloudformation components in a stack.

func (*ComponentProvider) ValidateComponent

func (p *ComponentProvider) ValidateComponent(config map[string]any) error

ValidateComponent validates aws/cloudformation component configuration.

type Config

type Config struct {
	BasePath string `yaml:"base_path" json:"base_path" mapstructure:"base_path"`
}

Config holds the resolved global configuration for aws/cloudformation components.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the built-in defaults for aws/cloudformation components.

type DeployedStackSummary

type DeployedStackSummary struct {
	StackName string
	Status    string
	Managed   bool
}

DeployedStackSummary is one entry in `atmos aws cloudformation list`'s output: a live CloudFormation stack, annotated with whether its name matches an aws/cloudformation component's stack_name configured in the queried Atmos stack.

func ListDeployedStacks

func ListDeployedStacks(
	ctx context.Context,
	info *schema.ConfigAndStacksInfo,
	region string,
	statusFilter []string,
	configuredStackNames map[string]bool,
) ([]DeployedStackSummary, error)

ListDeployedStacks resolves credentials for the active identity, fetches the account's deployed CloudFormation stacks, and annotates each one with whether it matches a configured aws/cloudformation component's stack_name (configuredStackNames — built by the CLI layer from the queried Atmos stack's components, since matching stack_name against Atmos configuration is outside this SDK-only package's concern).

type Operation

type Operation string

Operation is an aws/cloudformation component lifecycle operation.

const (
	// OperationRender renders the local template client-side (no API calls).
	OperationRender Operation = "render"
	// OperationDiff creates (or reuses) a changeset and previews the changes an apply would make.
	OperationDiff Operation = "diff"
	// OperationApply executes the changeset, creating or updating the stack.
	OperationApply Operation = "apply"
	// OperationDelete deletes the stack.
	OperationDelete Operation = "delete"
	// OperationValidate calls the server-side ValidateTemplate API.
	OperationValidate Operation = "validate"
	// OperationOutput renders the deployed stack's Outputs.
	OperationOutput Operation = "output"
	// OperationChangesetCreate creates a changeset and leaves it for manual review/execution.
	OperationChangesetCreate Operation = "changeset-create"
	// OperationChangesetExecute executes a previously-created, named changeset.
	OperationChangesetExecute Operation = "changeset-execute"
	// OperationChangesetList lists a stack's changesets.
	OperationChangesetList Operation = "changeset-list"
	// OperationChangesetDelete deletes a named changeset.
	OperationChangesetDelete Operation = "changeset-delete"
	// OperationDriftDetect starts drift detection against the deployed stack.
	OperationDriftDetect Operation = "drift-detect"
	// OperationDriftDescribe renders the results of the most recent drift detection.
	OperationDriftDescribe Operation = "drift-describe"
	// OperationGetTemplate fetches the deployed stack's template.
	OperationGetTemplate Operation = "get-template"
	// OperationGetPolicy fetches the deployed stack's policy.
	OperationGetPolicy Operation = "get-policy"
	// OperationFmt formats the local template in place (or checks formatting with --check).
	OperationFmt Operation = "fmt"
	// OperationStackSetCreate creates a StackSet and, when accounts/regions are
	// configured on the selected target, its initial stack instances.
	OperationStackSetCreate Operation = "stackset-create"
	// OperationStackSetUpdate updates a StackSet's template/parameters/capabilities.
	OperationStackSetUpdate Operation = "stackset-update"
	// OperationStackSetDelete deletes every stack instance, then the StackSet itself.
	OperationStackSetDelete Operation = "stackset-delete"
	// OperationStackSetInstances lists a StackSet's stack instances.
	OperationStackSetInstances Operation = "stackset-instances"
	// OperationTree renders the nested-stack dependency tree for a component.
	OperationTree Operation = "tree"
	// OperationLogs renders the combined event log across a stack and its nested stacks.
	OperationLogs Operation = "logs"
	// OperationWatch attaches to a stack's in-progress (or already-terminal) operation and streams events.
	OperationWatch Operation = "watch"
)

type ProvisionS3BackendParams

type ProvisionS3BackendParams struct {
	AtmosConfig     *schema.AtmosConfiguration
	Target          *targetS3Config
	ComponentConfig map[string]any
	AuthContext     *schema.AuthContext
	Component       string
	Stack           string
}

ProvisionS3BackendParams are the inputs to ProvisionS3BackendTarget. Target must come from ResolveS3BackendTarget.

type S3BackendStatus

type S3BackendStatus struct {
	Target *targetS3Config `json:"target" yaml:"target"`
	Region string          `json:"region" yaml:"region"`
	Exists bool            `json:"exists" yaml:"exists"`
	Error  string          `json:"error,omitempty" yaml:"error,omitempty"`
}

S3BackendStatus is the result of checking whether a `kind: aws/s3` backend target's bucket exists, for `backend describe`/`backend list`.

The yaml/json tags give the machine-readable output the snake_case keys the rest of this component type's JSON/YAML output uses.

Error is set (and Exists is meaningless) when the target could not be inspected — for example because its identity failed to authenticate — so `backend list` can still render every other target.

func DescribeS3BackendTarget

func DescribeS3BackendTarget(
	ctx context.Context,
	atmosConfig *schema.AtmosConfiguration,
	s3cfg *targetS3Config,
	componentConfig map[string]any,
	authContext *schema.AuthContext,
) (*S3BackendStatus, error)

DescribeS3BackendTarget reports whether an aws/s3 backend target's bucket currently exists, calling pkg/provisioner/backend.S3BackendExists directly — a real (non-stub) implementation, unlike pkg/provisioner/provisioner.go's own DescribeBackend/ListBackends, which remain ErrNotImplemented stubs for Terraform today. CFN's describe/list need is narrower than Terraform's broader backend-type matrix (existence only), so it's implemented here rather than by fixing that pre-existing Terraform gap, which is out of scope for this change.

func NewS3BackendStatusError

func NewS3BackendStatusError(s3cfg *targetS3Config, cause error) *S3BackendStatus

NewS3BackendStatusError builds the status row for a target that could not be inspected, recording the cause so it can be rendered next to healthy targets.

type S3BackendTarget

type S3BackendTarget = targetS3Config

S3BackendTarget is the exported name of a resolved `kind: aws/s3` provision target, so callers outside this package can pass targets between helpers.

Directories

Path Synopsis
Package manifest validates stack manifest sections that are specific to aws/cloudformation components.
Package manifest validates stack manifest sections that are specific to aws/cloudformation components.

Jump to

Keyboard shortcuts

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