Documentation
¶
Overview ¶
Package cloudassembly reads cloud assemblies, the cdk.out directories a CDK app synthesizes: the manifest and artifact types, loading, stack selection, and the construct tree.
It tracks the cloud assembly schema version pinned in docs/getting-started/upstream-baseline.md, SchemaVersion.
Loading ¶
Load reads an assembly and every assembly nested in it into an Assembly, which holds the Artifact of each manifest entry: stacks, asset manifests, the construct tree and nested assemblies. It mirrors upstream's CloudAssembly, as toolkit-lib loads it, with these differences:
- Nested assemblies load with their parent, not on first use, so every accessor is free of errors and a broken nested assembly fails Load. So does a second construct tree, which upstream reports only when asked for the tree.
- The version check's message leaves out upstream's "You need at least CLI version X", which names a version of the TypeScript CLI.
- There is no option to skip enum checks: upstream's only applies to schema validation, which it never runs in production.
Artifacts keep the order toolkit-lib sees them in, which is not sorted by dependency: the manifest's order, except that IDs that are JavaScript array indexes come first. Loading sends no IO messages; the toolkit reports what it loads.
Stack selection ¶
Assembly.SelectStacks chooses the stacks an action works on, as upstream's stack selection does: by strategy, by patterns matched against each stack's hierarchical ID, and with the stacks they depend on or that depend on them. It sends no IO messages: Selection.Added lists the stacks the expansion added, for the toolkit to report.
Patterns are matched with the standard library's path.Match, one "/"-separated segment at a time, and a "**" segment matches any number of segments. Upstream matches them with picomatch, and the two agree on "*", "**", "?", classes such as "[a-z]" and "[^a]", escapes, and leading "!"s. A class written "[!a]" is not a negation in either: picomatch compiles it to a regular expression class that includes "!", and path.Match reads it the same way, so "[!A-Z]*" matches IDs that start with a capital or a "!". They differ where picomatch has syntax path.Match lacks:
- A brace expansion, such as "{Dev,Prod}/*", or an extglob, such as "!(Canary)", is an error. Matched literally, it would match nothing, and as an exclusion it would exclude nothing.
- A POSIX class, such as "[[:alpha:]]", is not one.
- "*" and "?" match a leading ".", which picomatch's do not; a stack's ID does not start with one.
Upstream's StackCollection is a plain []*Stack.
The construct tree ¶
Assembly.ReadTree reads the construct tree, upstream's tree.json, on demand rather than at load, because it can be large and only some actions use it. It returns its error, where upstream logs at trace level and carries on without a tree; a caller that only uses the tree to improve its messages should do the same. ConstructLibraryVersion finds the version of aws-cdk-lib an app was built with.
Stack.ResourceMetadata finds the construct that defines a resource, from the stack's metadata rather than the tree, as upstream does.
Placeholders ¶
A stack's role ARNs and an asset's destinations can hold ${AWS::Region}, ${AWS::AccountId} and ${AWS::Partition}, which only the deployment knows. ResolvePlaceholders replaces them, looking up only the values a string needs. It fixes an upstream defect: upstream misses a placeholder at the start of a string, or one character in, and writes "WONTHAPPEN" in its place. FileDestination.Resolve and DockerImageDestination.Resolve resolve an asset destination, whose own region, when it has one, stands for ${AWS::Region}.
Asset entries ¶
AssetManifest.Entries expands an asset manifest into one AssetEntry per asset and destination, as upstream's cdk-assets AssetManifest.entries does: the unit the toolkit builds, publishes and reports on (EH-1). Upstream's select, DestinationPattern and list, which only the cdk-assets command line uses, are not ported (H.1-D5).
Wire types ¶
Manifest and AssetManifest, and the types they contain, are the manifests exactly as they are on disk: upstream's cloud-assembly-schema interfaces. They decode and encode with encoding/json/v2.
- An optional field is the Go zero value when upstream leaves it out, and is left out again when encoding. Upstream treats an absent field and its zero value alike, with one exception: a stack's notification ARNs, where absent and empty differ, and so do a nil and an empty Go slice.
- Where the schema lets a field take one of several shapes, told apart only by a sibling field, the field keeps its raw JSON (jsontext.Value). Accessors decode it on demand: ArtifactManifest.StackProperties and the like for an artifact's properties, and MetadataEntry.Message and the like for a metadata entry's data. A context provider's query stays raw for the provider to decode. Values of a type this package does not know, such as metadata a construct library invented, survive a decode and encode untouched.
- Objects whose member order upstream depends on, such as the artifacts, are an OrderedMap.
The types are written by hand, following upstream's. A test checks them against upstream's JSON Schemas, copied into testdata/schema by `./walle upstream schema`: every property of every schema definition must have a Go field, and every Go field a property.
Index ¶
- Constants
- func ConstructLibraryVersion(tree *ConstructNode) string
- func FormatEnvironment(account, region string) string
- func ReplacePlaceholders[T any](value T, v PlaceholderValues) T
- func ResolvePlaceholders[T any](ctx context.Context, value T, r PlaceholderResolver) (T, error)
- type AWSDestination
- type Artifact
- type ArtifactInfo
- type ArtifactManifest
- func (a ArtifactManifest) AssetManifestProperties() (AssetManifestProperties, error)
- func (a ArtifactManifest) FeatureFlagReportProperties() (FeatureFlagReportProperties, error)
- func (a ArtifactManifest) NestedAssemblyProperties() (NestedAssemblyProperties, error)
- func (a ArtifactManifest) StackProperties() (StackProperties, error)
- func (a ArtifactManifest) TreeProperties() (TreeProperties, error)
- type ArtifactType
- type Assembly
- func (a *Assembly) Artifact(id string) (Artifact, bool)
- func (a *Assembly) AssetManifests() []*AssetManifestArtifact
- func (a *Assembly) FeatureFlagReports() ([]FeatureFlagReportProperties, error)
- func (a *Assembly) NestedAssemblies() []*NestedAssemblyArtifact
- func (a *Assembly) ReadTree() (*ConstructNode, error)
- func (a *Assembly) SelectStacks(sel Selector, opts SelectOptions) (Selection, error)
- func (a *Assembly) StackByID(id string) (*Stack, error)
- func (a *Assembly) StackByName(name string) (*Stack, error)
- func (a *Assembly) Stacks() []*Stack
- func (a *Assembly) StacksForValidation() []*Stack
- func (a *Assembly) StacksRecursively() []*Stack
- func (a *Assembly) Tree() *TreeArtifact
- func (a *Assembly) ValidationReport() (ValidationReport, bool, error)
- type AssetDestinationID
- type AssetEntry
- type AssetManifest
- type AssetManifestArtifact
- type AssetManifestProperties
- type AssetMetadata
- type BootstrapRole
- type CloudFormationResource
- type ConstructInfo
- type ConstructNode
- type ContextProvider
- type DockerCacheOption
- type DockerImageAsset
- type DockerImageAssetEntry
- type DockerImageDestination
- type DockerImageSource
- type Environment
- type Expand
- type FeatureFlag
- type FeatureFlagReportProperties
- type FileAsset
- type FileAssetEntry
- type FileAssetPackaging
- type FileDestination
- type FileSource
- type LoadOptions
- type Manifest
- type MetadataEntry
- type MissingContext
- type NestedAssemblyArtifact
- type NestedAssemblyProperties
- type OrderedMap
- func (m OrderedMap[V]) All() iter.Seq2[string, V]
- func (m OrderedMap[V]) Get(key string) (V, bool)
- func (m OrderedMap[V]) Keys() iter.Seq[string]
- func (m OrderedMap[V]) Len() int
- func (m OrderedMap[V]) MarshalJSONTo(enc *jsontext.Encoder) error
- func (m *OrderedMap[V]) Set(key string, v V)
- func (m *OrderedMap[V]) UnmarshalJSONFrom(dec *jsontext.Decoder) error
- type PlaceholderResolver
- type PlaceholderValues
- type PluginReport
- type PolicyViolation
- type ResourceMetadata
- type RuntimeInfo
- type SelectOptions
- type Selection
- type Selector
- type Stack
- type StackProperties
- type StacksError
- type Strategy
- type SuppressedViolation
- type SynthesisMessage
- type SynthesisMessageLevel
- type Tag
- type TreeArtifact
- type TreeProperties
- type UnconfiguredBehavesLike
- type ValidationReport
- type ViolatingConstruct
Constants ¶
const ( UnknownAccount = "unknown-account" UnknownRegion = "unknown-region" )
The account and region of an environment-agnostic stack, which deploys to whatever account and region the credentials give.
const ( // MetadataTypeAsset is an asset the stack uses; [MetadataEntry.Asset] decodes it. MetadataTypeAsset = "aws:cdk:asset" // MetadataTypeInfo is an informational annotation; [MetadataEntry.Message] decodes it. MetadataTypeInfo = "aws:cdk:info" // MetadataTypeWarning is a warning annotation; [MetadataEntry.Message] decodes it. MetadataTypeWarning = "aws:cdk:warning" // MetadataTypeError is an error annotation, which fails synthesis; [MetadataEntry.Message] decodes it. MetadataTypeError = "aws:cdk:error" // MetadataTypeLogicalID is the logical ID of the construct's CloudFormation resource; [MetadataEntry.LogicalID] decodes it. MetadataTypeLogicalID = "aws:cdk:logicalId" // MetadataTypeStackTags are tags for the stack; [MetadataEntry.StackTags] decodes them. // Stack tags are now in the stack's properties, and upstream no longer reads these. MetadataTypeStackTags = "aws:cdk:stack-tags" // MetadataTypeDoNotRefactor marks a resource that refactoring must leave alone. MetadataTypeDoNotRefactor = "aws:cdk:do-not-refactor" // MetadataTypeCreationStack is the stack trace of the code that created the construct. MetadataTypeCreationStack = "aws:cdk:creationStack" // MetadataTypePropertyAssignment is the stack trace of the code that set one of the construct's properties. MetadataTypePropertyAssignment = "aws:cdk:propertyAssignment" )
The metadata entry types upstream defines. Constructs may add entries of any other type.
const ( PlaceholderRegion = "${AWS::Region}" PlaceholderAccountID = "${AWS::AccountId}" PlaceholderPartition = "${AWS::Partition}" )
The placeholders a cloud assembly uses for values only known at deployment, such as in role ARNs and asset destinations.
const ( ConclusionSuccess = "success" ConclusionFailure = "failure" )
The conclusions of a plugin report.
const ( ViolationFatal = "fatal" ViolationError = "error" ViolationWarning = "warning" ViolationInfo = "info" ViolationCustom = "custom" )
The severities of a policy violation.
const ManifestFile = "manifest.json"
ManifestFile is the name of a cloud assembly's manifest, in the assembly directory.
const SchemaVersion = "55.0.0"
SchemaVersion is the cloud assembly schema version this package reads: the version of upstream's schema at the pinned commit, as it appears in a manifest's version field. Every change to the schema increments the major version.
const ValidationReportFile = "validation-report.json"
ValidationReportFile is the name of the file, in an assembly's directory, where a CDK app writes the results of its policy validation plugins.
Variables ¶
This section is empty.
Functions ¶
func ConstructLibraryVersion ¶
func ConstructLibraryVersion(tree *ConstructNode) string
ConstructLibraryVersion returns the version of the CDK library an app was built with, found in its construct tree: the version of the first construct from aws-cdk-lib, or from @aws-cdk/core for CDK v1. It returns the empty string if the tree records none, or records the development version 0.0.0.
func FormatEnvironment ¶
FormatEnvironment returns the environment of account and region in the form aws://account/region.
func ReplacePlaceholders ¶
func ReplacePlaceholders[T any](value T, v PlaceholderValues) T
ReplacePlaceholders returns value with every placeholder replaced by its value in v. The value is a string, a []string or map[string]string, or a JSON-shaped value made of map[string]any and []any, whose strings are replaced wherever they are; it is copied, not changed. Values of other types, such as numbers or structs, are returned as they are.
func ResolvePlaceholders ¶
func ResolvePlaceholders[T any](ctx context.Context, value T, r PlaceholderResolver) (T, error)
ResolvePlaceholders is ReplacePlaceholders with the values looked up by r, and only those value holds. It returns the first error r returns.
Upstream looks for a placeholder with indexOf(...) > 1, so it misses one at the start of a string, or one character in, and replaces it with "WONTHAPPEN". This finds a placeholder wherever it is.
Types ¶
type AWSDestination ¶
type AWSDestination struct {
// Region is the destination's region.
Region string `json:"region,omitzero"`
// AssumeRoleARN is the role to assume to publish.
AssumeRoleARN string `json:"assumeRoleArn,omitzero"`
// AssumeRoleExternalID is the external ID to use when assuming AssumeRoleARN.
AssumeRoleExternalID string `json:"assumeRoleExternalId,omitzero"`
// AssumeRoleAdditionalOptions are further options for assuming AssumeRoleARN, as STS AssumeRole parameters.
AssumeRoleAdditionalOptions map[string]any `json:"assumeRoleAdditionalOptions,omitzero"`
}
AWSDestination is the account and role a destination is reached with, common to every kind of destination.
type Artifact ¶
type Artifact interface {
// Info returns what every artifact has.
Info() *ArtifactInfo
// contains filtered or unexported methods
}
Artifact is one artifact of an Assembly: a *Stack, *AssetManifestArtifact, *TreeArtifact or *NestedAssemblyArtifact. Use a type switch to tell them apart.
type ArtifactInfo ¶
type ArtifactInfo struct {
// Assembly is the assembly the artifact belongs to.
Assembly *Assembly
// ID is the artifact's ID, its key in the manifest.
ID string
// Manifest is the artifact's entry in the manifest, as it is on disk.
Manifest ArtifactManifest
// Dependencies are the artifacts, in the same assembly, that this one depends on.
Dependencies []Artifact
// Metadata are the metadata entries of the artifact's constructs, keyed by construct path: those in the manifest's AdditionalMetadataFile first, then those in the manifest itself.
Metadata OrderedMap[[]MetadataEntry]
// Messages are the annotations among the Metadata, in order.
Messages []SynthesisMessage
}
ArtifactInfo is what every artifact has: upstream's CloudArtifact. Each artifact type embeds it.
func (*ArtifactInfo) HierarchicalID ¶
func (a *ArtifactInfo) HierarchicalID() string
HierarchicalID returns the artifact's display name, or its ID if it has none. Stack selection matches patterns against it.
type ArtifactManifest ¶
type ArtifactManifest struct {
// Type is the artifact's type, which determines what its Properties are.
Type ArtifactType `json:"type"`
// Environment is the environment the artifact belongs to, in the form aws://account/region.
Environment string `json:"environment,omitzero"`
// Metadata are the metadata entries of the artifact's constructs, keyed by construct path, in manifest order.
// Entries may also be in the file AdditionalMetadataFile names; the loaded model merges the two.
Metadata OrderedMap[[]MetadataEntry] `json:"metadata,omitzero"`
// AdditionalMetadataFile is a file in the assembly directory holding more metadata entries, in the same form as Metadata.
AdditionalMetadataFile string `json:"additionalMetadataFile,omitzero"`
// Dependencies are the IDs of the artifacts this one depends on.
Dependencies []string `json:"dependencies,omitzero"`
// Properties are the type-specific properties, as raw JSON.
// Decode them with the accessor for the artifact's Type, such as [ArtifactManifest.StackProperties].
Properties jsontext.Value `json:"properties,omitzero"`
// DisplayName is the artifact's display name, which upstream calls its hierarchical ID when set.
DisplayName string `json:"displayName,omitzero"`
}
ArtifactManifest is one artifact in a Manifest.
func (ArtifactManifest) AssetManifestProperties ¶
func (a ArtifactManifest) AssetManifestProperties() (AssetManifestProperties, error)
AssetManifestProperties decodes the properties of an ArtifactTypeAssetManifest artifact, as ArtifactManifest.StackProperties does.
func (ArtifactManifest) FeatureFlagReportProperties ¶
func (a ArtifactManifest) FeatureFlagReportProperties() (FeatureFlagReportProperties, error)
FeatureFlagReportProperties decodes the properties of an ArtifactTypeFeatureFlagReport artifact, as ArtifactManifest.StackProperties does.
func (ArtifactManifest) NestedAssemblyProperties ¶
func (a ArtifactManifest) NestedAssemblyProperties() (NestedAssemblyProperties, error)
NestedAssemblyProperties decodes the properties of an ArtifactTypeNestedAssembly artifact, as ArtifactManifest.StackProperties does.
func (ArtifactManifest) StackProperties ¶
func (a ArtifactManifest) StackProperties() (StackProperties, error)
StackProperties decodes the properties of an ArtifactTypeStack artifact. Like upstream, it does not check the artifact's type, and an artifact without properties has the zero value.
func (ArtifactManifest) TreeProperties ¶
func (a ArtifactManifest) TreeProperties() (TreeProperties, error)
TreeProperties decodes the properties of an ArtifactTypeTree artifact, as ArtifactManifest.StackProperties does.
type ArtifactType ¶
type ArtifactType string
ArtifactType is the type of an artifact.
const ( // ArtifactTypeNone exists only because of a jsii limitation upstream; no artifact has it. ArtifactTypeNone ArtifactType = "none" // ArtifactTypeStack is a CloudFormation stack; its properties are [StackProperties]. ArtifactTypeStack ArtifactType = "aws:cloudformation:stack" // ArtifactTypeTree is the construct tree; its properties are [TreeProperties]. ArtifactTypeTree ArtifactType = "cdk:tree" // ArtifactTypeAssetManifest is an asset manifest; its properties are [AssetManifestProperties]. ArtifactTypeAssetManifest ArtifactType = "cdk:asset-manifest" // ArtifactTypeNestedAssembly is a nested cloud assembly, such as a Stage; its properties are [NestedAssemblyProperties]. ArtifactTypeNestedAssembly ArtifactType = "cdk:cloud-assembly" // ArtifactTypeFeatureFlagReport is the report of the app's feature flags; its properties are [FeatureFlagReportProperties]. ArtifactTypeFeatureFlagReport ArtifactType = "cdk:feature-flag-report" )
The artifact types.
type Assembly ¶
type Assembly struct {
// Dir is the assembly's directory.
Dir string
// Manifest is the assembly's manifest, as it is on disk.
Manifest Manifest
// Runtime describes the libraries the app was synthesized with; its Libraries are empty when the manifest has none.
Runtime RuntimeInfo
// Artifacts are the artifacts of the four types this package models, in upstream's order: the manifest's order, except that IDs that are array indexes, such as "3", come first in ascending order, as JavaScript orders an object's keys.
// Artifacts of other types, such as the feature flag report, are only in the Manifest, as upstream drops them too; [Assembly.FeatureFlagReports] reads the feature flag reports from there.
Artifacts []Artifact
// contains filtered or unexported fields
}
Assembly is a loaded cloud assembly: upstream's CloudAssembly. It never changes after Load returns, so it is safe for concurrent use.
func Load ¶
func Load(dir string, opts LoadOptions) (*Assembly, error)
Load reads the cloud assembly in dir, and every assembly nested in it.
It returns a cdkerr.Error of Kind cdkerr.KindToolkit and Code cdkerr.CodeAssemblyVersionMismatch when the assembly's schema version is newer than SchemaVersion, unless opts.SkipVersionCheck is set, and one of Kind cdkerr.KindAssembly when the assembly cannot be read or is malformed. An older schema version is always accepted.
Load only reads the directory: taking the lock that stops another process writing the assembly is the caller's job.
func (*Assembly) Artifact ¶
Artifact returns the artifact of this assembly with the given ID, not looking in nested assemblies.
func (*Assembly) AssetManifests ¶
func (a *Assembly) AssetManifests() []*AssetManifestArtifact
AssetManifests returns this assembly's asset manifest artifacts, in artifact order.
func (*Assembly) FeatureFlagReports ¶
func (a *Assembly) FeatureFlagReports() ([]FeatureFlagReportProperties, error)
FeatureFlagReports returns the properties of this assembly's feature flag reports, not those of nested assemblies, in the order toolkit-lib sees its artifacts, as upstream's flags action reads them. Each report's flags are in the order upstream's Object.entries gives them: the manifest's, except that names that are JavaScript array indexes come first, as for the artifacts.
It returns a cdkerr.Error of Kind cdkerr.KindAssembly when a report's properties cannot be decoded, have no flags object, or hold a flag that is null, where upstream's flags action throws a TypeError.
func (*Assembly) NestedAssemblies ¶
func (a *Assembly) NestedAssemblies() []*NestedAssemblyArtifact
NestedAssemblies returns the assemblies nested in this one, in artifact order.
func (*Assembly) ReadTree ¶
func (a *Assembly) ReadTree() (*ConstructNode, error)
ReadTree reads the construct tree of the assembly, or returns nil if the assembly has no tree artifact. It returns a cdkerr.Error of Kind cdkerr.KindAssembly if the tree cannot be read.
Upstream carries on without a tree when it cannot read one, and so should a caller that only uses the tree to improve its messages.
func (*Assembly) SelectStacks ¶
func (a *Assembly) SelectStacks(sel Selector, opts SelectOptions) (Selection, error)
SelectStacks selects stacks from the assembly and the assemblies nested in it: upstream's selectStacksWithSuggestions.
It returns a cdkerr.Error of Kind cdkerr.KindToolkit when the selector is invalid, when the assembly has no stacks, unless sel.AllowEmpty is set, and when the strategy's condition is not met. Those errors carry upstream's codes: "NoStacksInApp", "NoStackInMainAssembly", "MultipleStacksWithoutSelector", "NoStacksMatched" and "AmbiguousStackSelection".
func (*Assembly) StackByID ¶
StackByID returns the stack with the given artifact ID, from this assembly or any nested in it. It returns a cdkerr.Error of Kind cdkerr.KindAssembly if there is none.
func (*Assembly) StackByName ¶
StackByName returns the stack of this assembly, not of those nested in it, with the given stack name. It returns a cdkerr.Error of Kind cdkerr.KindAssembly if there is not exactly one.
func (*Assembly) Stacks ¶
Stacks returns the stacks of this assembly, not those of nested assemblies, in artifact order.
func (*Assembly) StacksForValidation ¶
StacksForValidation returns the stacks, those in nested assemblies included, whose ValidateOnSynth is set: upstream's selectStacksForValidation.
func (*Assembly) StacksRecursively ¶
StacksRecursively returns the stacks of this assembly and of every assembly nested in it, breadth first: this assembly's stacks, then those of each nested assembly in turn, then theirs.
func (*Assembly) Tree ¶
func (a *Assembly) Tree() *TreeArtifact
Tree returns the construct tree artifact, or nil if the assembly has none.
func (*Assembly) ValidationReport ¶
func (a *Assembly) ValidationReport() (ValidationReport, bool, error)
ValidationReport reads the assembly's validation report, and reports whether it has one: upstream's Manifest.loadValidationReport.
As upstream, it checks only the report's version: unknown members are ignored. It returns a cdkerr.Error of Kind cdkerr.KindAssembly when the report cannot be read or decoded, when its version is missing, invalid or newer than SchemaVersion reads, or when it has no plugin reports.
type AssetDestinationID ¶
type AssetDestinationID struct {
// AssetID identifies the asset; destinations of the same asset share it, and the asset is built once for all of them.
AssetID string
// DestinationID identifies the destination within the asset.
DestinationID string
}
AssetDestinationID identifies an asset and one of its destinations: upstream's DestinationIdentifier. It doesn't identify an entry across manifests: two manifests can give the same asset and destination IDs different buckets, so the work graph keys its nodes on a hash of the source and destination instead (I.1-D2).
func (AssetDestinationID) String ¶
func (id AssetDestinationID) String() string
String returns the ID as upstream writes it: "assetID:destinationID", or the asset ID alone when the destination ID is empty.
type AssetEntry ¶
type AssetEntry interface {
// Identifier returns the entry's asset and destination.
Identifier() AssetDestinationID
// Label returns a name for the entry in messages: upstream's displayName.
// With withDestination, it names the destination too, for messages about publishing to it; without, it names only the asset, for messages about building it, or about publishing it everywhere.
Label(withDestination bool) string
// contains filtered or unexported methods
}
AssetEntry is one asset with one of its destinations, as an asset manifest lists them: upstream's IManifestEntry. It is a *FileAssetEntry or a *DockerImageAssetEntry; use a type switch to tell them apart.
type AssetManifest ¶
type AssetManifest struct {
// Version is the schema version the manifest was written with.
Version string `json:"version"`
// Files are the file assets, keyed by asset ID, in manifest order.
Files OrderedMap[FileAsset] `json:"files,omitzero"`
// DockerImages are the container image assets, keyed by asset ID, in manifest order.
DockerImages OrderedMap[DockerImageAsset] `json:"dockerImages,omitzero"`
}
AssetManifest is an asset manifest, the file an asset manifest artifact names: upstream's AssetManifest. It lists the assets a stack needs and where to publish each.
func (AssetManifest) Entries ¶
func (m AssetManifest) Entries() []AssetEntry
Entries returns one entry for each asset and destination in the manifest: the file assets first, then the container images, each in manifest order, as upstream's AssetManifest.entries does. Each call returns new entries.
type AssetManifestArtifact ¶
type AssetManifestArtifact struct {
ArtifactInfo
// File is the asset manifest's path: the manifest's, resolved against the assembly directory unless it is absolute.
File string
// RequiresBootstrapStackVersion is the lowest bootstrap stack version the assets can be published with, or 0 for any.
RequiresBootstrapStackVersion int
// BootstrapStackVersionSSMParameter is the SSM parameter that holds the bootstrap stack version.
BootstrapStackVersionSSMParameter string
}
AssetManifestArtifact is an asset manifest artifact: upstream's AssetManifestArtifact.
func (*AssetManifestArtifact) ReadManifest ¶
func (a *AssetManifestArtifact) ReadManifest() (AssetManifest, error)
ReadManifest reads and decodes the asset manifest.
type AssetManifestProperties ¶
type AssetManifestProperties struct {
// File is the asset manifest, a file in the assembly directory.
File string `json:"file"`
// RequiresBootstrapStackVersion is the lowest bootstrap stack version the assets can be published with.
RequiresBootstrapStackVersion int `json:"requiresBootstrapStackVersion,omitzero"`
// BootstrapStackVersionSSMParameter is the SSM parameter that holds the bootstrap stack version.
BootstrapStackVersionSSMParameter string `json:"bootstrapStackVersionSsmParameter,omitzero"`
}
AssetManifestProperties are the properties of an asset manifest artifact.
type AssetMetadata ¶
type AssetMetadata struct {
// Packaging is how the asset is packaged: "file" or "zip" for a file asset, or "container-image" for an image.
Packaging string `json:"packaging"`
// ID is the asset's logical identifier.
ID string `json:"id"`
// SourceHash is the hash of the asset's source.
SourceHash string `json:"sourceHash"`
// Path is the asset's source, relative to the assembly directory.
Path string `json:"path"`
// S3BucketParameter, S3KeyParameter and ArtifactHashParameter name the template parameters that receive a file asset's bucket, key and hash.
S3BucketParameter string `json:"s3BucketParameter,omitzero"`
S3KeyParameter string `json:"s3KeyParameter,omitzero"`
ArtifactHashParameter string `json:"artifactHashParameter,omitzero"`
// ImageNameParameter names the template parameter that receives the image's name.
ImageNameParameter string `json:"imageNameParameter,omitzero"`
// RepositoryName is the ECR repository to push the image to.
RepositoryName string `json:"repositoryName,omitzero"`
// ImageTag is the tag to push the image with.
ImageTag string `json:"imageTag,omitzero"`
BuildArgs map[string]string `json:"buildArgs,omitzero"`
BuildContexts map[string]string `json:"buildContexts,omitzero"`
BuildSSH string `json:"buildSsh,omitzero"`
BuildSecrets map[string]string `json:"buildSecrets,omitzero"`
Target string `json:"target,omitzero"`
File string `json:"file,omitzero"`
NetworkMode string `json:"networkMode,omitzero"`
Platform string `json:"platform,omitzero"`
Outputs []string `json:"outputs,omitzero"`
CacheFrom []DockerCacheOption `json:"cacheFrom,omitzero"`
CacheTo *DockerCacheOption `json:"cacheTo,omitzero"`
CacheDisabled bool `json:"cacheDisabled,omitzero"`
}
AssetMetadata is the data of an asset metadata entry: upstream's FileAssetMetadataEntry or ContainerImageAssetMetadataEntry, told apart by Packaging. These entries are how assemblies described assets before asset manifests; the toolkit still reads them from stacks that have them.
type BootstrapRole ¶
type BootstrapRole struct {
// ARN is the role's ARN.
ARN string `json:"arn"`
// AssumeRoleExternalID is the external ID to use when assuming the role.
AssumeRoleExternalID string `json:"assumeRoleExternalId,omitzero"`
// AssumeRoleAdditionalOptions are further options for assuming the role, as STS AssumeRole parameters.
AssumeRoleAdditionalOptions map[string]any `json:"assumeRoleAdditionalOptions,omitzero"`
// RequiresBootstrapStackVersion is the lowest bootstrap stack version that has the role.
RequiresBootstrapStackVersion int `json:"requiresBootstrapStackVersion,omitzero"`
// BootstrapStackVersionSSMParameter is the SSM parameter that holds the bootstrap stack version.
BootstrapStackVersionSSMParameter string `json:"bootstrapStackVersionSsmParameter,omitzero"`
}
BootstrapRole is a role from the bootstrap stack.
type CloudFormationResource ¶
type CloudFormationResource struct {
// TemplatePath is the template's path.
TemplatePath string `json:"templatePath"`
// LogicalID is the resource's logical ID.
LogicalID string `json:"logicalId"`
// PropertyPaths are the paths of the properties that break the rule.
PropertyPaths []string `json:"propertyPaths,omitzero"`
}
CloudFormationResource locates a resource in a template: the schema's CloudFormationResourceJson.
type ConstructInfo ¶
type ConstructInfo struct {
// FQN is the class's fully qualified name, such as "aws-cdk-lib.aws_s3.Bucket".
FQN string `json:"fqn"`
// Version is the version of the library the class is in.
Version string `json:"version"`
}
ConstructInfo names the class of a construct: upstream's ConstructInfo.
type ConstructNode ¶
type ConstructNode struct {
// ID is the construct's ID, unique among its siblings.
ID string `json:"id"`
// Path is the construct's path from the root, such as "MyStack/MyBucket/Resource"; the root's is empty.
Path string `json:"path"`
// Children are the construct's children, keyed by ID.
Children OrderedMap[*ConstructNode] `json:"children,omitzero"`
// Attributes are the construct's attributes, such as the CloudFormation type and properties of a resource.
Attributes map[string]any `json:"attributes,omitzero"`
// ConstructInfo names the construct's class, when the tree records it.
ConstructInfo *ConstructInfo `json:"constructInfo,omitzero"`
}
ConstructNode is a node of the construct tree, the tree.json an app writes when it synthesizes: upstream's ConstructTreeNode.
func ReadTreeFile ¶
func ReadTreeFile(file string) (*ConstructNode, error)
ReadTreeFile reads a construct tree from a tree.json file. It returns a cdkerr.Error of Kind cdkerr.KindAssembly if the file cannot be read.
func (*ConstructNode) Walk ¶
func (n *ConstructNode) Walk() iter.Seq[*ConstructNode]
Walk returns the nodes of the tree rooted at n, depth first, each node before its children. Children come in the order JavaScript gives an object's keys, the order upstream walks them in. A nil n has no nodes.
type ContextProvider ¶
type ContextProvider string
ContextProvider names a context provider.
const ( ContextProviderAMI ContextProvider = "ami" ContextProviderAvailabilityZones ContextProvider = "availability-zones" ContextProviderHostedZone ContextProvider = "hosted-zone" ContextProviderSSMParameter ContextProvider = "ssm" ContextProviderVPC ContextProvider = "vpc-provider" ContextProviderEndpointServiceAvailabilityZones ContextProvider = "endpoint-service-availability-zones" ContextProviderLoadBalancer ContextProvider = "load-balancer" ContextProviderLoadBalancerListener ContextProvider = "load-balancer-listener" ContextProviderSecurityGroup ContextProvider = "security-group" ContextProviderKey ContextProvider = "key-provider" ContextProviderCloudControlAPI ContextProvider = "cc-api-provider" ContextProviderPlugin ContextProvider = "plugin" )
The context providers.
type DockerCacheOption ¶
type DockerCacheOption struct {
// Type is the cache's type, such as "registry".
Type string `json:"type"`
// Params are the cache's parameters.
Params map[string]string `json:"params,omitzero"`
}
DockerCacheOption is a Docker build cache import or export: docker build's --cache-from and --cache-to.
type DockerImageAsset ¶
type DockerImageAsset struct {
// DisplayName names the asset in messages.
DisplayName string `json:"displayName,omitzero"`
// Source is what to build.
Source DockerImageSource `json:"source"`
// Destinations are where to publish it, keyed by destination ID, in manifest order.
Destinations OrderedMap[DockerImageDestination] `json:"destinations"`
}
DockerImageAsset is a container image asset: a Docker build context, or a command that produces an image, and where to publish it.
type DockerImageAssetEntry ¶
type DockerImageAssetEntry struct {
ID AssetDestinationID
// DisplayName is the asset's display name, if it has one.
DisplayName string
Source DockerImageSource
Destination DockerImageDestination
}
DockerImageAssetEntry is a container image asset with one of its destinations: upstream's DockerImageManifestEntry.
func (*DockerImageAssetEntry) Identifier ¶
func (e *DockerImageAssetEntry) Identifier() AssetDestinationID
func (*DockerImageAssetEntry) Label ¶
func (e *DockerImageAssetEntry) Label(withDestination bool) string
type DockerImageDestination ¶
type DockerImageDestination struct {
AWSDestination `json:",inline"`
// RepositoryName is the ECR repository.
RepositoryName string `json:"repositoryName"`
// ImageTag is the tag to push the image with.
ImageTag string `json:"imageTag"`
}
DockerImageDestination is where to publish a container image asset: an ECR repository and tag.
func (DockerImageDestination) Resolve ¶
func (d DockerImageDestination) Resolve(ctx context.Context, r PlaceholderResolver) (DockerImageDestination, error)
Resolve returns d with the placeholders in its strings replaced, as FileDestination.Resolve does.
type DockerImageSource ¶
type DockerImageSource struct {
// Directory is the build context, relative to the manifest's directory.
Directory string `json:"directory,omitzero"`
// Executable is a command whose standard output is the name of an image it built.
Executable []string `json:"executable,omitzero"`
DockerFile string `json:"dockerFile,omitzero"`
DockerBuildTarget string `json:"dockerBuildTarget,omitzero"`
DockerBuildArgs map[string]string `json:"dockerBuildArgs,omitzero"`
DockerBuildContexts map[string]string `json:"dockerBuildContexts,omitzero"`
DockerBuildSSH string `json:"dockerBuildSsh,omitzero"`
DockerBuildSecrets map[string]string `json:"dockerBuildSecrets,omitzero"`
NetworkMode string `json:"networkMode,omitzero"`
Platform string `json:"platform,omitzero"`
DockerOutputs []string `json:"dockerOutputs,omitzero"`
CacheFrom []DockerCacheOption `json:"cacheFrom,omitzero"`
CacheTo *DockerCacheOption `json:"cacheTo,omitzero"`
CacheDisabled bool `json:"cacheDisabled,omitzero"`
}
DockerImageSource is the source of a container image asset, and how to build it. Its fields are the options of docker build.
type Environment ¶
type Environment struct {
// Name is the environment in the form aws://account/region.
Name string
Account string
Region string
}
Environment is an AWS account and region, as a stack artifact names it.
func MakeEnvironment ¶
func MakeEnvironment(account, region string) Environment
MakeEnvironment returns the environment of account and region.
func ParseEnvironment ¶
func ParseEnvironment(s string) (Environment, error)
ParseEnvironment parses an environment in the form aws://account/region. It returns a cdkerr.Error of Kind cdkerr.KindAssembly if s is not one.
type Expand ¶
type Expand string
Expand says which other stacks Assembly.SelectStacks adds to the ones it selects, because of their dependencies: upstream's ExpandStackSelection. The zero value is ExpandNone.
const ( // ExpandNone adds no stacks. ExpandNone Expand = "none" // ExpandUpstream adds every stack the selected stacks depend on, directly or not. ExpandUpstream Expand = "upstream" // ExpandDownstream adds every stack that depends on a selected stack, directly or not. ExpandDownstream Expand = "downstream" )
The expansions.
type FeatureFlag ¶
type FeatureFlag struct {
// RecommendedValue is the value upstream recommends.
RecommendedValue jsontext.Value `json:"recommendedValue,omitzero"`
// UserValue is the value the app configured.
UserValue jsontext.Value `json:"userValue,omitzero"`
// Explanation describes the flag.
Explanation string `json:"explanation,omitzero"`
// UnconfiguredBehavesLike is how the flag behaves when the app does not configure it.
UnconfiguredBehavesLike *UnconfiguredBehavesLike `json:"unconfiguredBehavesLike,omitzero"`
}
FeatureFlag describes one feature flag in a feature flag report. Its values are raw JSON, because a flag can take any JSON value.
type FeatureFlagReportProperties ¶
type FeatureFlagReportProperties struct {
// Module is the library whose feature flags these are, such as "aws-cdk-lib".
Module string `json:"module"`
// Flags maps each feature flag's name to its details, in manifest order, which upstream returns them in.
Flags OrderedMap[FeatureFlag] `json:"flags"`
}
FeatureFlagReportProperties are the properties of a feature flag report artifact.
type FileAsset ¶
type FileAsset struct {
// DisplayName names the asset in messages.
DisplayName string `json:"displayName,omitzero"`
// Source is what to publish.
Source FileSource `json:"source"`
// Destinations are where to publish it, keyed by destination ID, in manifest order.
Destinations OrderedMap[FileDestination] `json:"destinations"`
}
FileAsset is a file asset: a file or a directory to zip, and where to publish it.
type FileAssetEntry ¶
type FileAssetEntry struct {
ID AssetDestinationID
// DisplayName is the asset's display name, if it has one.
DisplayName string
Source FileSource
Destination FileDestination
}
FileAssetEntry is a file asset with one of its destinations: upstream's FileManifestEntry.
func (*FileAssetEntry) Identifier ¶
func (e *FileAssetEntry) Identifier() AssetDestinationID
func (*FileAssetEntry) Label ¶
func (e *FileAssetEntry) Label(withDestination bool) string
type FileAssetPackaging ¶
type FileAssetPackaging string
FileAssetPackaging is how a file asset is packaged.
const ( // FileAssetPackagingFile publishes the file as it is. FileAssetPackagingFile FileAssetPackaging = "file" // FileAssetPackagingZipDirectory publishes the directory as a zip file. FileAssetPackagingZipDirectory FileAssetPackaging = "zip" )
The file asset packagings.
type FileDestination ¶
type FileDestination struct {
AWSDestination `json:",inline"`
// BucketName is the S3 bucket.
BucketName string `json:"bucketName"`
// ObjectKey is the object's key.
ObjectKey string `json:"objectKey"`
}
FileDestination is where to publish a file asset: an S3 object.
func (FileDestination) Resolve ¶
func (d FileDestination) Resolve(ctx context.Context, r PlaceholderResolver) (FileDestination, error)
Resolve returns d with the placeholders in its strings replaced, as upstream's replaceAwsPlaceholders does before publishing: d's own region, when it has one, stands for ${AWS::Region}, and r gives the rest. It looks up only the values d needs, once each.
Upstream's publisher resolves ${AWS::AccountId} in a destination to the base credentials' default account, though role ARNs resolve it to the stack's environment; the toolkit passes the stack's environment's resolver for both, which agrees wherever the CDK writes the placeholder, in the destinations of environment-agnostic stacks (H.1-D3).
type FileSource ¶
type FileSource struct {
// Executable is a command whose standard output is the path of the file to publish.
Executable []string `json:"executable,omitzero"`
// Path is the file or directory to publish, relative to the manifest's directory.
Path string `json:"path,omitzero"`
// Packaging is how to package Path; upstream publishes the file as it is when it is empty.
Packaging FileAssetPackaging `json:"packaging,omitzero"`
}
FileSource is the source of a file asset: a path, or a command that produces it.
type LoadOptions ¶
type LoadOptions struct {
// SkipVersionCheck loads an assembly even if its schema version is newer than [SchemaVersion].
// This package may then not understand everything in it.
SkipVersionCheck bool
}
LoadOptions are the options for Load. The zero value is upstream's default.
type Manifest ¶
type Manifest struct {
// Version is the schema version the assembly was written with, such as "54.0.0".
Version string `json:"version"`
// MinimumCLIVersion is the lowest version of upstream's TypeScript CDK CLI that can read the assembly.
MinimumCLIVersion string `json:"minimumCliVersion,omitzero"`
// Artifacts are the assembly's artifacts, keyed by artifact ID, in manifest order.
Artifacts OrderedMap[ArtifactManifest] `json:"artifacts,omitzero"`
// Missing are the context values synthesis needed but did not have.
Missing []MissingContext `json:"missing,omitzero"`
// Runtime describes the libraries the app was synthesized with.
Runtime *RuntimeInfo `json:"runtime,omitzero"`
}
Manifest is a cloud assembly's manifest.json, exactly as it is on disk: upstream's AssemblyManifest.
type MetadataEntry ¶
type MetadataEntry struct {
// Type is the entry's type, which determines what its Data is: one of the MetadataType constants, or a type a construct library defines.
Type string `json:"type"`
// Data is the entry's data, as raw JSON.
// Decode it with the accessor for the entry's Type, such as [MetadataEntry.Message].
Data jsontext.Value `json:"data,omitzero"`
// Trace is the stack trace of the code that added the entry.
Trace []string `json:"trace,omitzero"`
}
MetadataEntry is one metadata entry of a construct.
func (MetadataEntry) Asset ¶
func (e MetadataEntry) Asset() (AssetMetadata, error)
Asset decodes the data of a MetadataTypeAsset entry.
func (MetadataEntry) LogicalID ¶
func (e MetadataEntry) LogicalID() (string, error)
LogicalID decodes the data of a MetadataTypeLogicalID entry.
func (MetadataEntry) Message ¶
func (e MetadataEntry) Message() (string, error)
Message decodes the data of a MetadataTypeInfo, MetadataTypeWarning or MetadataTypeError entry: the annotation's text.
func (MetadataEntry) StackTags ¶
func (e MetadataEntry) StackTags() ([]Tag, error)
StackTags decodes the data of a MetadataTypeStackTags entry. Early versions of the CDK wrote each tag as {"Key", "Value"}, so it accepts either casing, as upstream does when it reads a manifest.
type MissingContext ¶
type MissingContext struct {
// Key is the context key the value belongs under.
Key string `json:"key"`
// Provider is the context provider that can look it up.
Provider ContextProvider `json:"provider"`
// Props is the provider's query, as raw JSON; each provider decodes its own.
Props jsontext.Value `json:"props"`
}
MissingContext is a context value synthesis needed but did not have, which a context provider can look up.
type NestedAssemblyArtifact ¶
type NestedAssemblyArtifact struct {
ArtifactInfo
// DirectoryName is the nested assembly's directory, relative to the parent assembly's.
DirectoryName string
// DisplayName is the nested assembly's display name, or the artifact ID when the manifest has none.
DisplayName string
// Nested is the nested assembly, loaded with the same options as its parent.
Nested *Assembly
}
NestedAssemblyArtifact is an assembly nested in another, such as a Stage: upstream's NestedCloudAssemblyArtifact.
type NestedAssemblyProperties ¶
type NestedAssemblyProperties struct {
// DirectoryName is the nested assembly's directory, relative to this assembly's.
DirectoryName string `json:"directoryName"`
// DisplayName is the nested assembly's display name.
DisplayName string `json:"displayName,omitzero"`
}
NestedAssemblyProperties are the properties of a nested cloud assembly artifact.
type OrderedMap ¶
type OrderedMap[V any] struct { // contains filtered or unexported fields }
OrderedMap is a JSON object that keeps its members in order. The manifests use it where upstream's behaviour depends on the order of an object's members, such as the artifacts, which the toolkit lists and selects in manifest order.
It decodes from a JSON object, or null for an empty map, and encodes as a JSON object in the same order. Like a Go map, it rejects duplicate member names when decoding. The zero value is an empty map, ready to use.
func (OrderedMap[V]) All ¶
func (m OrderedMap[V]) All() iter.Seq2[string, V]
All returns the members in order.
func (OrderedMap[V]) Get ¶
func (m OrderedMap[V]) Get(key string) (V, bool)
Get returns the value of the member named key, and whether there is one.
func (OrderedMap[V]) Keys ¶
func (m OrderedMap[V]) Keys() iter.Seq[string]
Keys returns the member names in order.
func (OrderedMap[V]) MarshalJSONTo ¶
func (m OrderedMap[V]) MarshalJSONTo(enc *jsontext.Encoder) error
MarshalJSONTo encodes m as a JSON object with its members in order. It has a value receiver, like time.Time.MarshalJSON, so that an OrderedMap inside a value that is not addressable still encodes as an object.
func (*OrderedMap[V]) Set ¶
func (m *OrderedMap[V]) Set(key string, v V)
Set sets the value of the member named key: in place if there is one, or as a new last member if not.
func (*OrderedMap[V]) UnmarshalJSONFrom ¶
func (m *OrderedMap[V]) UnmarshalJSONFrom(dec *jsontext.Decoder) error
UnmarshalJSONFrom decodes a JSON object into m, replacing its contents, or empties m for a JSON null.
type PlaceholderResolver ¶
type PlaceholderResolver interface {
Region(ctx context.Context) (string, error)
AccountID(ctx context.Context) (string, error)
Partition(ctx context.Context) (string, error)
}
PlaceholderResolver looks up the values that replace the placeholders, such as by asking STS which account the credentials belong to. ResolvePlaceholders calls only the methods for the placeholders a value holds.
type PlaceholderValues ¶
PlaceholderValues are the values that replace the placeholders.
type PluginReport ¶
type PluginReport struct {
// PluginName names the plugin.
PluginName string `json:"pluginName"`
// PluginVersion is the plugin's version, if it reported one.
PluginVersion string `json:"pluginVersion,omitzero"`
// Conclusion is [ConclusionSuccess] or [ConclusionFailure].
Conclusion string `json:"conclusion"`
// Metadata is whatever else the plugin reported; "error" holds the error of a plugin that failed to run.
Metadata map[string]string `json:"metadata,omitzero"`
// Preamble is text the plugin puts before its violations.
Preamble string `json:"preamble,omitzero"`
// Violations are the rules the app broke.
Violations []PolicyViolation `json:"violations"`
// SuppressedViolations are the violations the app acknowledged.
SuppressedViolations []SuppressedViolation `json:"suppressedViolations,omitzero"`
}
PluginReport is one plugin's report: the schema's PluginReportJson.
type PolicyViolation ¶
type PolicyViolation struct {
// RuleName names the rule.
RuleName string `json:"ruleName"`
// Description says what is wrong.
Description string `json:"description"`
// SuggestedFix says how to fix it.
SuggestedFix string `json:"suggestedFix,omitzero"`
// Severity is one of the Violation constants.
Severity string `json:"severity"`
// CustomSeverity is the plugin's own label for a [ViolationCustom] violation.
CustomSeverity string `json:"customSeverity,omitzero"`
// RuleMetadata is whatever else the plugin says about the rule.
RuleMetadata map[string]string `json:"ruleMetadata,omitzero"`
// ViolatingConstructs are the constructs that break the rule.
ViolatingConstructs []ViolatingConstruct `json:"violatingConstructs"`
}
PolicyViolation is one rule the app broke: the schema's PolicyViolationJson.
type ResourceMetadata ¶
type ResourceMetadata struct {
// Entry is the [MetadataTypeLogicalID] entry; its Trace is the stack trace of the code that created the construct, when synthesis recorded one.
Entry MetadataEntry
// ConstructPath is the path of the construct, simplified for display: without the leading "/", the stack's name, or a final "/Resource", as in "MyBucket".
ConstructPath string
}
ResourceMetadata is the metadata entry that maps a resource's logical ID to the construct that defines it: upstream's ResourceMetadata.
type RuntimeInfo ¶
type RuntimeInfo struct {
// Libraries maps each library's name to its version.
Libraries map[string]string `json:"libraries"`
}
RuntimeInfo describes the libraries an app was synthesized with.
type SelectOptions ¶
type SelectOptions struct {
// SuggestPatternMatches fills in [Selection.Suggestions], for the pattern strategies.
SuggestPatternMatches bool
}
SelectOptions are the options for Assembly.SelectStacks.
type Selection ¶
type Selection struct {
// Stacks are the selected stacks, in the order of [Assembly.StacksRecursively].
Stacks []*Stack
// Added are the hierarchical IDs of the stacks the expansion added, in the order it added them.
// The toolkit reports them, as "Including dependency stacks" or "Including depending stacks".
Added []string
// Suggestions has an entry for each pattern that matched no stack, when [SelectOptions.SuggestPatternMatches] is set: the hierarchical IDs of the stacks it matches when case is ignored, which may be none.
// For an exclusion, a pattern with a "!", it is the stacks it would have excluded.
Suggestions map[string][]string
}
Selection is the result of Assembly.SelectStacks.
type Selector ¶
type Selector struct {
// Strategy says how to select.
// It has no default: the zero value is an error.
Strategy Strategy
// Patterns are globs matched against each stack's hierarchical ID, for the pattern strategies.
//
// - "*" matches only top-level stacks, and none in a Stage.
// - "**" matches any number of levels, so it matches every stack, those in Stages included.
// - "MyStage/*" matches every stack in one Stage.
// - "!MyStack" matches every stack but MyStack.
//
// The stacks selected are those any pattern without a "!" matches, less those any pattern with one excludes.
// Patterns that are all exclusions start from every stack, and no patterns at all select nothing.
// The order of the patterns makes no difference.
Patterns []string
// Expand says which stacks to add because of their dependencies.
Expand Expand
// AllowEmpty makes selection from an assembly with no stacks select none, whatever the strategy, rather than fail.
// A selection from an assembly that has stacks can still fail for selecting none.
AllowEmpty bool
}
Selector says which stacks to select: upstream's StackSelector.
type Stack ¶
type Stack struct {
ArtifactInfo
// StackName is the name of the stack in CloudFormation: the manifest's, or the artifact ID when the manifest has none.
StackName string
// DisplayName names the stack in messages: its hierarchical ID, followed by the stack name in parentheses when the two differ, as in "Prod/Service (prod-service)".
DisplayName string
// Environment is the account and region the stack deploys to.
Environment Environment
// TemplateFile is the stack's template, a file in the assembly directory.
TemplateFile string
// Parameters are the values of the template's parameters.
Parameters map[string]string
// Tags are the tags to apply to the stack.
// Upstream reads them only from the stack's properties, never from stack-tags metadata.
Tags map[string]string
// NotificationARNs are the SNS topics to notify of stack events.
// Nil and empty differ, as in [StackProperties].
NotificationARNs []string
// AssumeRoleARN is the role to assume to deploy the stack, and AssumeRoleExternalID and AssumeRoleAdditionalOptions how to assume it.
// The ARN may hold placeholders for the environment; see [ResolvePlaceholders].
AssumeRoleARN string
AssumeRoleExternalID string
AssumeRoleAdditionalOptions map[string]any
// CloudFormationExecutionRoleARN is the role CloudFormation assumes to deploy the stack.
CloudFormationExecutionRoleARN string
// LookupRole is the role to assume for context lookups in the stack's environment, or nil for none.
LookupRole *BootstrapRole
// StackTemplateAssetObjectURL is where the template is published as an asset, as an S3 URL.
StackTemplateAssetObjectURL string
// RequiresBootstrapStackVersion is the lowest bootstrap stack version the stack can deploy with, or 0 for any, and BootstrapStackVersionSSMParameter the SSM parameter that holds the version.
RequiresBootstrapStackVersion int
BootstrapStackVersionSSMParameter string
// TerminationProtection reports whether to turn on termination protection.
TerminationProtection bool
// ValidateOnSynth reports whether to validate the template when the app is synthesized.
ValidateOnSynth bool
// Assets are the stack's asset metadata entries, in metadata order: how assemblies described assets before asset manifests.
Assets []AssetMetadata
}
Stack is a CloudFormation stack artifact: upstream's CloudFormationStackArtifact. Its fields are the stack's properties from the manifest, with upstream's defaults applied.
func (*Stack) ReadTemplate ¶
ReadTemplate reads and decodes the stack's template. It reads the file on every call; a caller that needs the template more than once keeps it.
func (*Stack) ResourceMetadata ¶
func (s *Stack) ResourceMetadata(logicalID string) (ResourceMetadata, bool)
ResourceMetadata returns the metadata of the stack's resource with the given logical ID, if the stack's metadata has its MetadataTypeLogicalID entry. Synthesis writes those entries unless path metadata is turned off.
func (*Stack) TemplatePath ¶
TemplatePath returns the path of the stack's template.
type StackProperties ¶
type StackProperties struct {
// TemplateFile is the stack's template, a file in the assembly directory.
TemplateFile string `json:"templateFile"`
// Parameters are the values of the template's parameters.
Parameters map[string]string `json:"parameters,omitzero"`
// Tags are the tags to apply to the stack.
Tags map[string]string `json:"tags,omitzero"`
// NotificationARNs are the SNS topics to notify of stack events.
// Absent and empty differ: upstream sends an empty list to CloudFormation, clearing the stack's topics, but sends nothing when the field is absent.
NotificationARNs []string `json:"notificationArns,omitzero"`
// StackName is the name of the stack; upstream uses the artifact ID when it is empty.
StackName string `json:"stackName,omitzero"`
// TerminationProtection reports whether to turn on termination protection.
TerminationProtection bool `json:"terminationProtection,omitzero"`
// AssumeRoleARN is the role to assume to deploy the stack.
AssumeRoleARN string `json:"assumeRoleArn,omitzero"`
// AssumeRoleExternalID is the external ID to use when assuming AssumeRoleARN.
AssumeRoleExternalID string `json:"assumeRoleExternalId,omitzero"`
// AssumeRoleAdditionalOptions are further options for assuming AssumeRoleARN, as STS AssumeRole parameters.
AssumeRoleAdditionalOptions map[string]any `json:"assumeRoleAdditionalOptions,omitzero"`
// CloudFormationExecutionRoleARN is the role CloudFormation assumes to deploy the stack.
CloudFormationExecutionRoleARN string `json:"cloudFormationExecutionRoleArn,omitzero"`
// LookupRole is the role to assume for context lookups in the stack's environment.
LookupRole *BootstrapRole `json:"lookupRole,omitzero"`
// StackTemplateAssetObjectURL is where the template is published as an asset, as an S3 URL.
StackTemplateAssetObjectURL string `json:"stackTemplateAssetObjectUrl,omitzero"`
// RequiresBootstrapStackVersion is the lowest bootstrap stack version the stack can deploy with.
RequiresBootstrapStackVersion int `json:"requiresBootstrapStackVersion,omitzero"`
// BootstrapStackVersionSSMParameter is the SSM parameter that holds the bootstrap stack version.
BootstrapStackVersionSSMParameter string `json:"bootstrapStackVersionSsmParameter,omitzero"`
// ValidateOnSynth reports whether to validate the template when the app is synthesized.
ValidateOnSynth bool `json:"validateOnSynth,omitzero"`
}
StackProperties are the properties of a CloudFormation stack artifact: upstream's AwsCloudFormationStackProperties.
type StacksError ¶
type StacksError struct {
Stacks []*Stack
}
StacksError names the stacks a failure is about, such as those whose annotations failed synthesis: what upstream's AssemblyError carries as its stacks. The toolkit wraps it as the cause of the cdkerr.Error it returns; reach it with errors.As.
type Strategy ¶
type Strategy string
Strategy says which stacks Assembly.SelectStacks selects: upstream's StackSelectionStrategy.
const ( // StrategyAllStacks selects every stack, those in nested assemblies included, and ignores the patterns. StrategyAllStacks Strategy = "all-stacks" // StrategyMainAssembly selects the stacks of the top-level assembly, and fails if it has none. StrategyMainAssembly Strategy = "main-assembly" // StrategyOnlySingle selects the top-level assembly's only stack, and fails unless it has exactly one. // It ignores the patterns and the expansion. StrategyOnlySingle Strategy = "only-single" // StrategyPatternMatch selects the stacks the patterns match, which may be none. StrategyPatternMatch Strategy = "pattern-match" // StrategyPatternMustMatch selects the stacks the patterns match, and fails if they match none. StrategyPatternMustMatch Strategy = "pattern-must-match" // StrategyPatternMustMatchSingle selects the stacks the patterns match, and fails unless the selection, once expanded, is exactly one stack. StrategyPatternMustMatchSingle Strategy = "pattern-must-match-single" )
The selection strategies.
type SuppressedViolation ¶
type SuppressedViolation struct {
PolicyViolation
// AcknowledgedID is the ID it was acknowledged with.
AcknowledgedID string `json:"acknowledgedId"`
// Reason says why.
Reason string `json:"reason,omitzero"`
// AcknowledgedAt is the path of the construct the acknowledgement is on.
AcknowledgedAt string `json:"acknowledgedAt,omitzero"`
// AcknowledgedStackTrace is where the acknowledgement was made.
AcknowledgedStackTrace string `json:"acknowledgedStackTrace,omitzero"`
}
SuppressedViolation is a violation the app acknowledged: the schema's SuppressedViolationJson.
type SynthesisMessage ¶
type SynthesisMessage struct {
Level SynthesisMessageLevel
// ID is the path of the construct the annotation is on.
ID string
Entry MetadataEntry
}
SynthesisMessage is an annotation a construct added during synthesis: a metadata entry of type MetadataTypeInfo, MetadataTypeWarning or MetadataTypeError.
type SynthesisMessageLevel ¶
type SynthesisMessageLevel string
SynthesisMessageLevel is the level of an annotation.
const ( SynthesisMessageInfo SynthesisMessageLevel = "info" SynthesisMessageWarning SynthesisMessageLevel = "warning" SynthesisMessageError SynthesisMessageLevel = "error" )
The annotation levels.
type TreeArtifact ¶
type TreeArtifact struct {
ArtifactInfo
// File is the construct tree, a file in the assembly directory.
File string
}
TreeArtifact is the construct tree artifact: upstream's TreeCloudArtifact.
type TreeProperties ¶
type TreeProperties struct {
// File is the construct tree, a file in the assembly directory.
File string `json:"file"`
}
TreeProperties are the properties of a construct tree artifact.
type UnconfiguredBehavesLike ¶
type UnconfiguredBehavesLike struct {
// V1 is the behaviour in version 1.
V1 jsontext.Value `json:"v1,omitzero"`
// V2 is the behaviour in version 2.
V2 jsontext.Value `json:"v2,omitzero"`
}
UnconfiguredBehavesLike is how an unconfigured feature flag behaves, in each major version of the library.
type ValidationReport ¶
type ValidationReport struct {
// Version is the report's schema version, the cloud assembly schema's.
Version string `json:"version"`
// Title is the report's title, if it has one.
Title string `json:"title,omitzero"`
// PluginReports are the reports of the plugins.
PluginReports []PluginReport `json:"pluginReports"`
}
ValidationReport is the results of an app's policy validation plugins: the schema's PolicyValidationReportJson.
type ViolatingConstruct ¶
type ViolatingConstruct struct {
// ConstructPath is the construct's path, such as "MyStack/MyBucket/Resource"; it may be empty.
ConstructPath string `json:"constructPath"`
// ConstructFqn is the construct's fully qualified type name.
ConstructFqn string `json:"constructFqn,omitzero"`
// LibraryVersion is the version of the construct's library.
LibraryVersion string `json:"libraryVersion,omitzero"`
// CloudFormationResource is the resource the construct made, if any.
CloudFormationResource *CloudFormationResource `json:"cloudFormationResource,omitzero"`
// StackTraces are where the construct was made.
StackTraces []string `json:"stackTraces,omitzero"`
}
ViolatingConstruct is a construct that breaks a rule: the schema's ViolatingConstructJson.