@aws-cdk/toolkit-lib 0.1.6 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import * as cxapi from '@aws-cdk/cx-api';
2
2
  import { CloudFormationStackArtifact } from '@aws-cdk/cx-api';
3
- import { StackEvent } from '@aws-sdk/client-cloudformation';
3
+ import { DescribeChangeSetOutput as DescribeChangeSet, StackEvent } from '@aws-sdk/client-cloudformation';
4
4
 
5
5
  /**
6
6
  * Which stacks should be selected from a cloud assembly
@@ -83,99 +83,85 @@ export interface StackSelector {
83
83
  */
84
84
  failOnEmpty?: boolean;
85
85
  }
86
- /**
87
- * The current action being performed by the CLI. 'none' represents the absence of an action.
88
- */
89
- export type ToolkitAction = "assembly" | "bootstrap" | "synth" | "list" | "diff" | "deploy" | "rollback" | "watch" | "destroy" | "doctor" | "gc" | "import" | "metadata" | "init" | "migrate";
90
- /**
91
- * The reporting level of the message.
92
- * All messages are always reported, it's up to the IoHost to decide what to log.
93
- */
94
- export type IoMessageLevel = "error" | "result" | "warn" | "info" | "debug" | "trace";
95
- /**
96
- * A valid message code.
97
- */
98
- export type IoMessageCode = `CDK_${string}_${"E" | "W" | "I"}${number}${number}${number}${number}`;
99
- /**
100
- * An IO message emitted.
101
- */
102
- export interface IoMessage<T> {
103
- /**
104
- * The time the message was emitted.
105
- */
106
- readonly time: Date;
107
- /**
108
- * The recommended log level of the message.
109
- *
110
- * This is an indicative level and should not be used to explicitly match messages, instead match the `code`.
111
- * The level of a message may change without notice.
112
- */
113
- readonly level: IoMessageLevel;
114
- /**
115
- * The action that triggered the message.
116
- */
117
- readonly action: ToolkitAction;
118
- /**
119
- * A short message code uniquely identifying a message type using the format CDK_[CATEGORY]_[E/W/I][0000-9999].
120
- *
121
- * The level indicator follows these rules:
122
- * - 'E' for error level messages
123
- * - 'W' for warning level messages
124
- * - 'I' for info/debug/trace level messages
125
- *
126
- * Codes ending in 000 0 are generic messages, while codes ending in 0001-9999 are specific to a particular message.
127
- * The following are examples of valid and invalid message codes:
128
- * ```ts
129
- * 'CDK_ASSETS_I0000' // valid: generic assets info message
130
- * 'CDK_TOOLKIT_E0002' // valid: specific toolkit error message
131
- * 'CDK_SDK_W0023' // valid: specific sdk warning message
132
- * ```
133
- *
134
- * @see https://github.com/aws/aws-cdk-cli/blob/main/packages/%40aws-cdk/toolkit-lib/CODE_REGISTRY.md
135
- */
136
- readonly code: IoMessageCode;
137
- /**
138
- * The message text.
139
- * This is safe to print to an end-user.
140
- */
141
- readonly message: string;
86
+ export interface Template {
87
+ Parameters?: Record<string, TemplateParameter>;
88
+ [section: string]: any;
89
+ }
90
+ export interface TemplateParameter {
91
+ Type: string;
92
+ Default?: any;
93
+ Description?: string;
94
+ [key: string]: any;
95
+ }
96
+ export interface NestedStackTemplates {
97
+ readonly physicalName: string | undefined;
98
+ readonly deployedTemplate: Template;
99
+ readonly generatedTemplate: Template;
100
+ readonly nestedStackTemplates: {
101
+ [nestedStackLogicalId: string]: NestedStackTemplates;
102
+ };
103
+ }
104
+ interface IDifference<ValueType> {
105
+ readonly oldValue: ValueType | undefined;
106
+ readonly newValue: ValueType | undefined;
107
+ readonly isDifferent: boolean;
108
+ readonly isAddition: boolean;
109
+ readonly isRemoval: boolean;
110
+ readonly isUpdate: boolean;
111
+ }
112
+ declare class Difference<ValueType> implements IDifference<ValueType> {
113
+ readonly oldValue: ValueType | undefined;
114
+ readonly newValue: ValueType | undefined;
142
115
  /**
143
- * Identifies the message span, this message belongs to.
144
- *
145
- * A message span, groups multiple messages together that semantically related to the same operation.
146
- * This is an otherwise meaningless identifier.
116
+ * Whether this is an actual different or the values are actually the same
147
117
  *
148
- * A message without a `spanId`, does not belong to a span.
118
+ * isDifferent => (isUpdate | isRemoved | isUpdate)
149
119
  */
150
- readonly span?: string;
120
+ isDifferent: boolean;
151
121
  /**
152
- * The data attached to the message.
122
+ * @param oldValue the old value, cannot be equal (to the sense of +deepEqual+) to +newValue+.
123
+ * @param newValue the new value, cannot be equal (to the sense of +deepEqual+) to +oldValue+.
153
124
  */
154
- readonly data: T;
125
+ constructor(oldValue: ValueType | undefined, newValue: ValueType | undefined);
126
+ /** @returns +true+ if the element is new to the template. */
127
+ get isAddition(): boolean;
128
+ /** @returns +true+ if the element was removed from the template. */
129
+ get isRemoval(): boolean;
130
+ /** @returns +true+ if the element was already in the template and is updated. */
131
+ get isUpdate(): boolean;
155
132
  }
156
- /**
157
- * An IO request emitted.
158
- */
159
- export interface IoRequest<T, U> extends IoMessage<T> {
160
- /**
161
- * The default response that will be used if no data is returned.
162
- */
163
- readonly defaultResponse: U;
133
+ declare class PropertyDifference<ValueType> extends Difference<ValueType> {
134
+ changeImpact?: ResourceImpact;
135
+ constructor(oldValue: ValueType | undefined, newValue: ValueType | undefined, args: {
136
+ changeImpact?: ResourceImpact;
137
+ });
164
138
  }
165
- export interface IIoHost {
166
- /**
167
- * Notifies the host of a message.
168
- * The caller waits until the notification completes.
169
- */
170
- notify(msg: IoMessage<unknown>): Promise<void>;
171
- /**
172
- * Notifies the host of a message that requires a response.
173
- *
174
- * If the host does not return a response the suggested
175
- * default response from the input message will be used.
176
- */
177
- requestResponse<T, U>(msg: IoRequest<T, U>): Promise<U>;
139
+ declare enum ResourceImpact {
140
+ /** The existing physical resource will be updated */
141
+ WILL_UPDATE = "WILL_UPDATE",
142
+ /** A new physical resource will be created */
143
+ WILL_CREATE = "WILL_CREATE",
144
+ /** The existing physical resource will be replaced */
145
+ WILL_REPLACE = "WILL_REPLACE",
146
+ /** The existing physical resource may be replaced */
147
+ MAY_REPLACE = "MAY_REPLACE",
148
+ /** The existing physical resource will be destroyed */
149
+ WILL_DESTROY = "WILL_DESTROY",
150
+ /** The existing physical resource will be removed from CloudFormation supervision */
151
+ WILL_ORPHAN = "WILL_ORPHAN",
152
+ /** The existing physical resource will be added to CloudFormation supervision */
153
+ WILL_IMPORT = "WILL_IMPORT",
154
+ /** There is no change in this resource */
155
+ NO_CHANGE = "NO_CHANGE"
178
156
  }
157
+ interface Resource {
158
+ Type: string;
159
+ Properties?: {
160
+ [name: string]: any;
161
+ };
162
+ [key: string]: any;
163
+ }
164
+ type DescribeChangeSetOutput = DescribeChangeSet;
179
165
  interface BootstrapRole {
180
166
  /**
181
167
  * The ARN of the IAM role created as part of bootrapping
@@ -871,29 +857,101 @@ interface KeyContextQuery extends ContextLookupRoleOptions {
871
857
  }
872
858
  interface CcApiContextQuery extends ContextLookupRoleOptions {
873
859
  /**
874
- * The Cloudformation resource type.
860
+ * The CloudFormation resource type.
875
861
  * See https://docs.aws.amazon.com/cloudcontrolapi/latest/userguide/supported-resources.html
876
862
  */
877
863
  readonly typeName: string;
878
864
  /**
879
- * exactIdentifier of the resource.
880
- * Specifying exactIdentifier will return at most one result.
881
- * Either exactIdentifier or propertyMatch should be specified.
882
- * @default - None
865
+ * Identifier of the resource to look up using `GetResource`.
866
+ *
867
+ * Specifying exactIdentifier will return exactly one result, or throw an error
868
+ * unless `ignoreErrorOnMissingContext` is set.
869
+ *
870
+ * @default - Either exactIdentifier or propertyMatch should be specified.
883
871
  */
884
872
  readonly exactIdentifier?: string;
885
873
  /**
886
- * This indicates the property to search for.
887
- * If both exactIdentifier and propertyMatch are specified, then exactIdentifier is used.
888
- * Specifying propertyMatch will return 0 or more results.
889
- * Either exactIdentifier or propertyMatch should be specified.
890
- * @default - None
874
+ * Returns any resources matching these properties, using `ListResources`.
875
+ *
876
+ * By default, specifying propertyMatch will successfully return 0 or more
877
+ * results. To throw an error if the number of results is unexpected (and
878
+ * prevent the query results from being committed to context), specify
879
+ * `expectedMatchCount`.
880
+ *
881
+ * ## Notes on property completeness
882
+ *
883
+ * CloudControl API's `ListResources` may return fewer properties than
884
+ * `GetResource` would, depending on the resource implementation.
885
+ *
886
+ * The resources that `propertyMatch` matches against will *only ever* be the
887
+ * properties returned by the `ListResources` call.
888
+ *
889
+ * @default - Either exactIdentifier or propertyMatch should be specified.
891
890
  */
892
891
  readonly propertyMatch?: Record<string, unknown>;
893
892
  /**
894
893
  * This is a set of properties returned from CC API that we want to return from ContextQuery.
894
+ *
895
+ * If any properties listed here are absent from the target resource, an error will be thrown.
896
+ *
897
+ * The returned object will always include the key `Identifier` with the CC-API returned
898
+ * field `Identifier`.
899
+ *
900
+ * ## Notes on property completeness
901
+ *
902
+ * CloudControl API's `ListResources` may return fewer properties than
903
+ * `GetResource` would, depending on the resource implementation.
904
+ *
905
+ * The returned properties here are *currently* selected from the response
906
+ * object that CloudControl API returns to the CDK CLI.
907
+ *
908
+ * However, if we find there is need to do so, we may decide to change this
909
+ * behavior in the future: we might change it to perform an additional
910
+ * `GetResource` call for resources matched by `propertyMatch`.
895
911
  */
896
912
  readonly propertiesToReturn: string[];
913
+ /**
914
+ * Expected count of results if `propertyMatch` is specified.
915
+ *
916
+ * If the expected result count does not match the actual count,
917
+ * by default an error is produced and the result is not committed to cached
918
+ * context, and the user can correct the situation and try again without
919
+ * having to manually clear out the context key using `cdk context --remove`
920
+ *
921
+ * If the value of * `ignoreErrorOnMissingContext` is `true`, the value of
922
+ * `expectedMatchCount` is `at-least-one | exactly-one` and the number
923
+ * of found resources is 0, `dummyValue` is returned and committed to context
924
+ * instead.
925
+ *
926
+ * @default 'any'
927
+ */
928
+ readonly expectedMatchCount?: "any" | "at-least-one" | "at-most-one" | "exactly-one";
929
+ /**
930
+ * The value to return if the resource was not found and `ignoreErrorOnMissingContext` is true.
931
+ *
932
+ * If supplied, `dummyValue` should be an array of objects.
933
+ *
934
+ * `dummyValue` does not have to have elements, and it may have objects with
935
+ * different properties than the properties in `propertiesToReturn`, but it
936
+ * will be easiest for downstream code if the `dummyValue` conforms to
937
+ * the expected response shape.
938
+ *
939
+ * @default - No dummy value available
940
+ */
941
+ readonly dummyValue?: any;
942
+ /**
943
+ * Ignore an error and return the `dummyValue` instead if the resource was not found.
944
+ *
945
+ * - In case of an `exactIdentifier` lookup, return the `dummyValue` if the resource with
946
+ * that identifier was not found.
947
+ * - In case of a `propertyMatch` lookup, return the `dummyValue` if `expectedMatchCount`
948
+ * is `at-least-one | exactly-one` and the number of resources found was 0.
949
+ *
950
+ * if `ignoreErrorOnMissingContext` is set, `dummyValue` should be set and be an array.
951
+ *
952
+ * @default false
953
+ */
954
+ readonly ignoreErrorOnMissingContext?: boolean;
897
955
  }
898
956
  interface PluginContextQuery {
899
957
  /**
@@ -1904,88 +1962,140 @@ declare class Manifest {
1904
1962
  private static replaceStackTags;
1905
1963
  private constructor();
1906
1964
  }
1907
- export interface BootstrapEnvironmentProgress {
1965
+ /**
1966
+ * The current action being performed by the CLI. 'none' represents the absence of an action.
1967
+ */
1968
+ export type ToolkitAction = "assembly" | "bootstrap" | "synth" | "list" | "diff" | "deploy" | "rollback" | "watch" | "destroy" | "doctor" | "gc" | "import" | "metadata" | "init" | "migrate";
1969
+ /**
1970
+ * The reporting level of the message.
1971
+ * All messages are always reported, it's up to the IoHost to decide what to log.
1972
+ */
1973
+ export type IoMessageLevel = "error" | "result" | "warn" | "info" | "debug" | "trace";
1974
+ /**
1975
+ * A valid message code.
1976
+ */
1977
+ export type IoMessageCode = `CDK_${string}_${"E" | "W" | "I"}${number}${number}${number}${number}`;
1978
+ /**
1979
+ * An IO message emitted.
1980
+ */
1981
+ export interface IoMessage<T> {
1908
1982
  /**
1909
- * The total number of environments being deployed
1983
+ * The time the message was emitted.
1910
1984
  */
1911
- readonly total: number;
1985
+ readonly time: Date;
1912
1986
  /**
1913
- * The count of the environment currently bootstrapped
1987
+ * The recommended log level of the message.
1914
1988
  *
1915
- * This is counting value, not an identifier.
1989
+ * This is an indicative level and should not be used to explicitly match messages, instead match the `code`.
1990
+ * The level of a message may change without notice.
1916
1991
  */
1917
- readonly current: number;
1992
+ readonly level: IoMessageLevel;
1918
1993
  /**
1919
- * The environment that's currently being bootstrapped
1994
+ * The action that triggered the message.
1920
1995
  */
1921
- readonly environment: cxapi.Environment;
1922
- }
1923
- interface IManifestEntry {
1996
+ readonly action: ToolkitAction;
1924
1997
  /**
1925
- * The identifier of the asset and its destination
1998
+ * A short message code uniquely identifying a message type using the format CDK_[CATEGORY]_[E/W/I][0000-9999].
1999
+ *
2000
+ * The level indicator follows these rules:
2001
+ * - 'E' for error level messages
2002
+ * - 'W' for warning level messages
2003
+ * - 'I' for info/debug/trace level messages
2004
+ *
2005
+ * Codes ending in 000 0 are generic messages, while codes ending in 0001-9999 are specific to a particular message.
2006
+ * The following are examples of valid and invalid message codes:
2007
+ * ```ts
2008
+ * 'CDK_ASSETS_I0000' // valid: generic assets info message
2009
+ * 'CDK_TOOLKIT_E0002' // valid: specific toolkit error message
2010
+ * 'CDK_SDK_W0023' // valid: specific sdk warning message
2011
+ * ```
2012
+ *
2013
+ * @see https://github.com/aws/aws-cdk-cli/blob/main/packages/%40aws-cdk/toolkit-lib/CODE_REGISTRY.md
1926
2014
  */
1927
- readonly id: DestinationIdentifier;
2015
+ readonly code: IoMessageCode;
1928
2016
  /**
1929
- * The type of asset
2017
+ * The message text.
2018
+ * This is safe to print to an end-user.
1930
2019
  */
1931
- readonly type: string;
2020
+ readonly message: string;
1932
2021
  /**
1933
- * Type-dependent source data
2022
+ * Identifies the message span, this message belongs to.
2023
+ *
2024
+ * A message span, groups multiple messages together that semantically related to the same operation.
2025
+ * This is an otherwise meaningless identifier.
2026
+ *
2027
+ * A message without a `spanId`, does not belong to a span.
1934
2028
  */
1935
- readonly genericSource: unknown;
2029
+ readonly span?: string;
1936
2030
  /**
1937
- * Type-dependent destination data
2031
+ * The data attached to the message.
1938
2032
  */
1939
- readonly genericDestination: unknown;
2033
+ readonly data: T;
2034
+ }
2035
+ /**
2036
+ * An IO request emitted.
2037
+ */
2038
+ export interface IoRequest<T, U> extends IoMessage<T> {
1940
2039
  /**
1941
- * Return a display name for this asset
1942
- *
1943
- * The `includeDestination` parameter controls whether or not to include the
1944
- * destination ID in the display name.
1945
- *
1946
- * - Pass `false` if you are displaying notifications about building the
1947
- * asset, or if you are describing the work of building the asset and publishing
1948
- * to all destinations at the same time.
1949
- * - Pass `true` if you are displaying notifications about publishing to a
1950
- * specific destination.
2040
+ * The default response that will be used if no data is returned.
1951
2041
  */
1952
- displayName(includeDestination: boolean): string;
2042
+ readonly defaultResponse: U;
1953
2043
  }
1954
- declare class DestinationIdentifier {
2044
+ export interface IIoHost {
1955
2045
  /**
1956
- * Identifies the asset, by source.
2046
+ * Notifies the host of a message.
2047
+ * The caller waits until the notification completes.
2048
+ */
2049
+ notify(msg: IoMessage<unknown>): Promise<void>;
2050
+ /**
2051
+ * Notifies the host of a message that requires a response.
1957
2052
  *
1958
- * The assetId will be the same between assets that represent
1959
- * the same physical file or image.
2053
+ * If the host does not return a response the suggested
2054
+ * default response from the input message will be used.
1960
2055
  */
1961
- readonly assetId: string;
2056
+ requestResponse<T, U>(msg: IoRequest<T, U>): Promise<U>;
2057
+ }
2058
+ interface CodeInfo {
1962
2059
  /**
1963
- * Identifies the destination where this asset will be published
2060
+ * The message code.
1964
2061
  */
1965
- readonly destinationId: string;
1966
- constructor(assetId: string, destinationId: string);
2062
+ readonly code: IoMessageCode;
1967
2063
  /**
1968
- * Return a string representation for this asset identifier
2064
+ * A brief description of the meaning of this IO Message.
1969
2065
  */
1970
- toString(): string;
2066
+ readonly description: string;
2067
+ /**
2068
+ * The name of the payload interface, if applicable.
2069
+ * Some Io Messages include a payload, with a specific interface. The name of
2070
+ * the interface is specified here so that it can be linked with the message
2071
+ * when documentation is generated.
2072
+ *
2073
+ * The interface _must_ be exposed directly from toolkit-lib, so that it will
2074
+ * have a documentation page generated (that can be linked to).
2075
+ */
2076
+ readonly interface?: string;
1971
2077
  }
1972
- /**
1973
- * Different types of permission related changes in a diff
1974
- */
1975
- export declare enum PermissionChangeType {
2078
+ interface MessageInfo extends CodeInfo {
1976
2079
  /**
1977
- * No permission changes
2080
+ * The message level
1978
2081
  */
1979
- NONE = "none",
2082
+ readonly level: IoMessageLevel;
2083
+ }
2084
+ interface IoMessageMaker<T> extends MessageInfo {
1980
2085
  /**
1981
- * Permissions are broadening
2086
+ * Create a message for this code, with or without payload.
1982
2087
  */
1983
- BROADENING = "broadening",
2088
+ msg: [
2089
+ T
2090
+ ] extends [
2091
+ AbsentData
2092
+ ] ? (message: string) => ActionLessMessage<AbsentData> : (message: string, data: T) => ActionLessMessage<T>;
1984
2093
  /**
1985
- * Permissions are changed but not broadening
2094
+ * Returns whether the given `IoMessage` instance matches the current message definition
1986
2095
  */
1987
- NON_BROADENING = "non-broadening"
2096
+ is(x: IoMessage<unknown>): x is IoMessage<T>;
1988
2097
  }
2098
+ type AbsentData = void;
1989
2099
  /**
1990
2100
  * Assembly data returned in the payload of an IO Message.
1991
2101
  */
@@ -2075,6 +2185,183 @@ export interface ConfirmationRequest {
2075
2185
  */
2076
2186
  readonly concurrency?: number;
2077
2187
  }
2188
+ export interface ContextProviderMessageSource {
2189
+ /**
2190
+ * The name of the context provider sending the message
2191
+ */
2192
+ readonly provider: string;
2193
+ }
2194
+ interface SpanEnd {
2195
+ readonly duration: number;
2196
+ }
2197
+ interface SpanDefinition<S extends object, E extends SpanEnd> {
2198
+ readonly name: string;
2199
+ readonly start: IoMessageMaker<S>;
2200
+ readonly end: IoMessageMaker<E>;
2201
+ }
2202
+ type EmptyObject = {
2203
+ [index: string | number | symbol]: never;
2204
+ };
2205
+ type VoidWhenEmpty<T> = T extends EmptyObject ? void : T;
2206
+ type ForceEmpty<T> = T extends EmptyObject ? EmptyObject : T;
2207
+ type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
2208
+ interface ElapsedTime {
2209
+ readonly asMs: number;
2210
+ readonly asSec: number;
2211
+ }
2212
+ interface IMessageSpan<E extends SpanEnd> {
2213
+ /**
2214
+ * Get the time elapsed since the start
2215
+ */
2216
+ elapsedTime(): Promise<ElapsedTime>;
2217
+ /**
2218
+ * Sends a simple, generic message with the current timing
2219
+ * For more complex intermediate messages, get the `elapsedTime` and use `notify`
2220
+ */
2221
+ timing(maker: IoMessageMaker<Duration>, message?: string): Promise<ElapsedTime>;
2222
+ /**
2223
+ * Sends an arbitrary intermediate message as part of the span
2224
+ */
2225
+ notify(message: ActionLessMessage<unknown>): Promise<void>;
2226
+ /**
2227
+ * End the span with a payload
2228
+ */
2229
+ end(payload: VoidWhenEmpty<Omit<E, keyof SpanEnd>>): Promise<ElapsedTime>;
2230
+ /**
2231
+ * End the span with a payload, overwriting
2232
+ */
2233
+ end(payload: VoidWhenEmpty<Optional<E, keyof SpanEnd>>): Promise<ElapsedTime>;
2234
+ /**
2235
+ * End the span with a message and payload
2236
+ */
2237
+ end(message: string, payload: ForceEmpty<Optional<E, keyof SpanEnd>>): Promise<ElapsedTime>;
2238
+ }
2239
+ declare class SpanMaker<S extends object, E extends SpanEnd> {
2240
+ private readonly definition;
2241
+ private readonly ioHelper;
2242
+ constructor(ioHelper: IoHelper, definition: SpanDefinition<S, E>);
2243
+ /**
2244
+ * Starts the span and initially notifies the IoHost
2245
+ * @returns a message span
2246
+ */
2247
+ begin(payload: VoidWhenEmpty<S>): Promise<IMessageSpan<E>>;
2248
+ begin(message: string, payload: S): Promise<IMessageSpan<E>>;
2249
+ }
2250
+ type ActionLessMessage<T> = Omit<IoMessage<T>, "action">;
2251
+ type ActionLessRequest<T, U> = Omit<IoRequest<T, U>, "action">;
2252
+ declare class IoHelper implements IIoHost {
2253
+ static fromIoHost(ioHost: IIoHost, action: ToolkitAction): IoHelper;
2254
+ private readonly ioHost;
2255
+ private readonly action;
2256
+ private constructor();
2257
+ /**
2258
+ * Forward a message to the IoHost, while injection the current action
2259
+ */
2260
+ notify(msg: ActionLessMessage<unknown>): Promise<void>;
2261
+ /**
2262
+ * Forward a request to the IoHost, while injection the current action
2263
+ */
2264
+ requestResponse<T, U>(msg: ActionLessRequest<T, U>): Promise<U>;
2265
+ /**
2266
+ * Create a new marker from a given registry entry
2267
+ */
2268
+ span<S extends object, E extends SpanEnd>(definition: SpanDefinition<S, E>): SpanMaker<S, E>;
2269
+ }
2270
+ export interface BootstrapEnvironmentProgress {
2271
+ /**
2272
+ * The total number of environments being deployed
2273
+ */
2274
+ readonly total: number;
2275
+ /**
2276
+ * The count of the environment currently bootstrapped
2277
+ *
2278
+ * This is counting value, not an identifier.
2279
+ */
2280
+ readonly current: number;
2281
+ /**
2282
+ * The environment that's currently being bootstrapped
2283
+ */
2284
+ readonly environment: cxapi.Environment;
2285
+ }
2286
+ interface IManifestEntry {
2287
+ /**
2288
+ * The identifier of the asset and its destination
2289
+ */
2290
+ readonly id: DestinationIdentifier;
2291
+ /**
2292
+ * The type of asset
2293
+ */
2294
+ readonly type: string;
2295
+ /**
2296
+ * Type-dependent source data
2297
+ */
2298
+ readonly genericSource: unknown;
2299
+ /**
2300
+ * Type-dependent destination data
2301
+ */
2302
+ readonly genericDestination: unknown;
2303
+ /**
2304
+ * Return a display name for this asset
2305
+ *
2306
+ * The `includeDestination` parameter controls whether or not to include the
2307
+ * destination ID in the display name.
2308
+ *
2309
+ * - Pass `false` if you are displaying notifications about building the
2310
+ * asset, or if you are describing the work of building the asset and publishing
2311
+ * to all destinations at the same time.
2312
+ * - Pass `true` if you are displaying notifications about publishing to a
2313
+ * specific destination.
2314
+ */
2315
+ displayName(includeDestination: boolean): string;
2316
+ }
2317
+ declare class DestinationIdentifier {
2318
+ /**
2319
+ * Identifies the asset, by source.
2320
+ *
2321
+ * The assetId will be the same between assets that represent
2322
+ * the same physical file or image.
2323
+ */
2324
+ readonly assetId: string;
2325
+ /**
2326
+ * Identifies the destination where this asset will be published
2327
+ */
2328
+ readonly destinationId: string;
2329
+ constructor(assetId: string, destinationId: string);
2330
+ /**
2331
+ * Return a string representation for this asset identifier
2332
+ */
2333
+ toString(): string;
2334
+ }
2335
+ /**
2336
+ * Different types of permission related changes in a diff
2337
+ */
2338
+ export declare enum PermissionChangeType {
2339
+ /**
2340
+ * No permission changes
2341
+ */
2342
+ NONE = "none",
2343
+ /**
2344
+ * Permissions are broadening
2345
+ */
2346
+ BROADENING = "broadening",
2347
+ /**
2348
+ * Permissions are changed but not broadening
2349
+ */
2350
+ NON_BROADENING = "non-broadening"
2351
+ }
2352
+ /**
2353
+ * Output of the diff command
2354
+ */
2355
+ export interface DiffResult extends Duration {
2356
+ /**
2357
+ * Stack diff formatted as a string
2358
+ */
2359
+ readonly formattedStackDiff: string;
2360
+ /**
2361
+ * Security diff formatted as a string
2362
+ */
2363
+ readonly formattedSecurityDiff: string;
2364
+ }
2078
2365
  export interface StackDeployProgress {
2079
2366
  /**
2080
2367
  * The total number of stacks being deployed
@@ -2198,7 +2485,7 @@ export interface StackDetails {
2198
2485
  dependencies: StackDependency[];
2199
2486
  }
2200
2487
  export interface StackDetailsPayload {
2201
- stacks: StackDetails[];
2488
+ readonly stacks: StackDetails[];
2202
2489
  }
2203
2490
  /**
2204
2491
  * An SDK logging trace.
@@ -2384,66 +2671,6 @@ export interface CloudWatchLogEvent {
2384
2671
  */
2385
2672
  readonly timestamp: Date;
2386
2673
  }
2387
- interface IDifference<ValueType> {
2388
- readonly oldValue: ValueType | undefined;
2389
- readonly newValue: ValueType | undefined;
2390
- readonly isDifferent: boolean;
2391
- readonly isAddition: boolean;
2392
- readonly isRemoval: boolean;
2393
- readonly isUpdate: boolean;
2394
- }
2395
- declare class Difference<ValueType> implements IDifference<ValueType> {
2396
- readonly oldValue: ValueType | undefined;
2397
- readonly newValue: ValueType | undefined;
2398
- /**
2399
- * Whether this is an actual different or the values are actually the same
2400
- *
2401
- * isDifferent => (isUpdate | isRemoved | isUpdate)
2402
- */
2403
- isDifferent: boolean;
2404
- /**
2405
- * @param oldValue the old value, cannot be equal (to the sense of +deepEqual+) to +newValue+.
2406
- * @param newValue the new value, cannot be equal (to the sense of +deepEqual+) to +oldValue+.
2407
- */
2408
- constructor(oldValue: ValueType | undefined, newValue: ValueType | undefined);
2409
- /** @returns +true+ if the element is new to the template. */
2410
- get isAddition(): boolean;
2411
- /** @returns +true+ if the element was removed from the template. */
2412
- get isRemoval(): boolean;
2413
- /** @returns +true+ if the element was already in the template and is updated. */
2414
- get isUpdate(): boolean;
2415
- }
2416
- declare class PropertyDifference<ValueType> extends Difference<ValueType> {
2417
- changeImpact?: ResourceImpact;
2418
- constructor(oldValue: ValueType | undefined, newValue: ValueType | undefined, args: {
2419
- changeImpact?: ResourceImpact;
2420
- });
2421
- }
2422
- declare enum ResourceImpact {
2423
- /** The existing physical resource will be updated */
2424
- WILL_UPDATE = "WILL_UPDATE",
2425
- /** A new physical resource will be created */
2426
- WILL_CREATE = "WILL_CREATE",
2427
- /** The existing physical resource will be replaced */
2428
- WILL_REPLACE = "WILL_REPLACE",
2429
- /** The existing physical resource may be replaced */
2430
- MAY_REPLACE = "MAY_REPLACE",
2431
- /** The existing physical resource will be destroyed */
2432
- WILL_DESTROY = "WILL_DESTROY",
2433
- /** The existing physical resource will be removed from CloudFormation supervision */
2434
- WILL_ORPHAN = "WILL_ORPHAN",
2435
- /** The existing physical resource will be added to CloudFormation supervision */
2436
- WILL_IMPORT = "WILL_IMPORT",
2437
- /** There is no change in this resource */
2438
- NO_CHANGE = "NO_CHANGE"
2439
- }
2440
- interface Resource {
2441
- Type: string;
2442
- Properties?: {
2443
- [name: string]: any;
2444
- };
2445
- [key: string]: any;
2446
- }
2447
2674
  /**
2448
2675
  * A resource affected by a change
2449
2676
  */
@@ -2467,6 +2694,13 @@ export interface AffectedResource {
2467
2694
  * A physical name is not always available, e.g. new resources will not have one until after the deployment
2468
2695
  */
2469
2696
  readonly physicalName?: string;
2697
+ /**
2698
+ * Resource metadata attached to the logical id from the cloud assembly
2699
+ *
2700
+ * This is only present if the resource is present in the current Cloud Assembly,
2701
+ * i.e. resource deletions will not have metadata.
2702
+ */
2703
+ readonly metadata?: ResourceMetadata;
2470
2704
  }
2471
2705
  /**
2472
2706
  * Represents a change in a resource
@@ -2488,6 +2722,13 @@ export interface ResourceChange {
2488
2722
  * The changes made to the resource properties
2489
2723
  */
2490
2724
  readonly propertyUpdates: Record<string, PropertyDifference<unknown>>;
2725
+ /**
2726
+ * Resource metadata attached to the logical id from the cloud assembly
2727
+ *
2728
+ * This is only present if the resource is present in the current Cloud Assembly,
2729
+ * i.e. resource deletions will not have metadata.
2730
+ */
2731
+ readonly metadata?: ResourceMetadata;
2491
2732
  }
2492
2733
  /**
2493
2734
  * A change that can be hotswapped
@@ -2497,11 +2738,118 @@ export interface HotswappableChange {
2497
2738
  * The resource change that is causing the hotswap.
2498
2739
  */
2499
2740
  readonly cause: ResourceChange;
2741
+ /**
2742
+ * A list of resources that are being hotswapped as part of the change
2743
+ */
2744
+ readonly resources: AffectedResource[];
2745
+ }
2746
+ export declare enum NonHotswappableReason {
2747
+ /**
2748
+ * Tags are not hotswappable
2749
+ */
2750
+ TAGS = "tags",
2751
+ /**
2752
+ * Changed resource properties are not hotswappable on this resource type
2753
+ */
2754
+ PROPERTIES = "properties",
2755
+ /**
2756
+ * A stack output has changed
2757
+ */
2758
+ OUTPUT = "output",
2759
+ /**
2760
+ * A dependant resource is not hotswappable
2761
+ */
2762
+ DEPENDENCY_UNSUPPORTED = "dependency-unsupported",
2763
+ /**
2764
+ * The resource type is not hotswappable
2765
+ */
2766
+ RESOURCE_UNSUPPORTED = "resource-unsupported",
2767
+ /**
2768
+ * The resource is created in the deployment
2769
+ */
2770
+ RESOURCE_CREATION = "resource-creation",
2771
+ /**
2772
+ * The resource is removed in the deployment
2773
+ */
2774
+ RESOURCE_DELETION = "resource-deletion",
2775
+ /**
2776
+ * The resource identified by the logical id has its type changed
2777
+ */
2778
+ RESOURCE_TYPE_CHANGED = "resource-type-changed",
2779
+ /**
2780
+ * The nested stack is created in the deployment
2781
+ */
2782
+ NESTED_STACK_CREATION = "nested-stack-creation"
2783
+ }
2784
+ export interface RejectionSubject {
2785
+ /**
2786
+ * The type of the rejection subject, e.g. Resource or Output
2787
+ */
2788
+ readonly type: string;
2789
+ /**
2790
+ * The logical ID of the change that is not hotswappable
2791
+ */
2792
+ readonly logicalId: string;
2793
+ /**
2794
+ * Resource metadata attached to the logical id from the cloud assembly
2795
+ *
2796
+ * This is only present if the resource is present in the current Cloud Assembly,
2797
+ * i.e. resource deletions will not have metadata.
2798
+ */
2799
+ readonly metadata?: ResourceMetadata;
2800
+ }
2801
+ export interface ResourceSubject extends RejectionSubject {
2802
+ /**
2803
+ * A rejected resource
2804
+ */
2805
+ readonly type: "Resource";
2806
+ /**
2807
+ * The type of the rejected resource
2808
+ */
2809
+ readonly resourceType: string;
2810
+ /**
2811
+ * The list of properties that are cause for the rejection
2812
+ */
2813
+ readonly rejectedProperties?: string[];
2814
+ }
2815
+ export interface OutputSubject extends RejectionSubject {
2816
+ /**
2817
+ * A rejected output
2818
+ */
2819
+ readonly type: "Output";
2820
+ }
2821
+ /**
2822
+ * A change that can not be hotswapped
2823
+ */
2824
+ export interface NonHotswappableChange {
2825
+ /**
2826
+ * The subject of the change that was rejected
2827
+ */
2828
+ readonly subject: ResourceSubject | OutputSubject;
2829
+ /**
2830
+ * Why was this change was deemed non-hotswappable
2831
+ */
2832
+ readonly reason: NonHotswappableReason;
2833
+ /**
2834
+ * Tells the user exactly why this change was deemed non-hotswappable and what its logical ID is.
2835
+ * If not specified, `displayReason` default to state that the properties listed in `rejectedChanges` are not hotswappable.
2836
+ */
2837
+ readonly description: string;
2838
+ }
2839
+ export interface HotswapDeploymentAttempt {
2840
+ /**
2841
+ * The stack that's currently being deployed
2842
+ */
2843
+ readonly stack: cxapi.CloudFormationStackArtifact;
2844
+ /**
2845
+ * The mode the hotswap deployment was initiated with.
2846
+ */
2847
+ readonly mode: "hotswap-only" | "fall-back";
2500
2848
  }
2501
2849
  /**
2502
2850
  * Information about a hotswap deployment
2503
2851
  */
2504
- export interface HotswapDeployment {
2852
+ export interface HotswapDeploymentDetails {
2505
2853
  /**
2506
2854
  * The stack that's currently being deployed
2507
2855
  */
@@ -2510,6 +2858,144 @@ export interface HotswapDeployment {
2510
2858
  * The mode the hotswap deployment was initiated with.
2511
2859
  */
2512
2860
  readonly mode: "hotswap-only" | "fall-back";
2861
+ /**
2862
+ * The changes that were deemed hotswappable
2863
+ */
2864
+ readonly hotswappableChanges: HotswappableChange[];
2865
+ /**
2866
+ * The changes that were deemed not hotswappable
2867
+ */
2868
+ readonly nonHotswappableChanges: NonHotswappableChange[];
2869
+ }
2870
+ /**
2871
+ * The result of an attempted hotswap deployment
2872
+ */
2873
+ export interface HotswapResult extends Duration, HotswapDeploymentDetails {
2874
+ /**
2875
+ * Whether hotswapping happened or not.
2876
+ *
2877
+ * `false` indicates that the deployment could not be hotswapped and full deployment may be attempted as fallback.
2878
+ */
2879
+ readonly hotswapped: boolean;
2880
+ }
2881
+ /**
2882
+ * @deprecated
2883
+ */
2884
+ declare enum RequireApproval$1 {
2885
+ /**
2886
+ * Never require any security approvals
2887
+ */
2888
+ NEVER = "never",
2889
+ /**
2890
+ * Any security changes require an approval
2891
+ */
2892
+ ANY_CHANGE = "any-change",
2893
+ /**
2894
+ * Require approval only for changes that are access broadening
2895
+ */
2896
+ BROADENING = "broadening"
2897
+ }
2898
+ interface FormatSecurityDiffOutput {
2899
+ /**
2900
+ * Complete formatted security diff, if it is prompt-worthy
2901
+ */
2902
+ readonly formattedDiff?: string;
2903
+ }
2904
+ interface FormatStackDiffOutput {
2905
+ /**
2906
+ * Number of stacks with diff changes
2907
+ */
2908
+ readonly numStacksWithChanges: number;
2909
+ /**
2910
+ * Complete formatted diff
2911
+ */
2912
+ readonly formattedDiff: string;
2913
+ }
2914
+ interface DiffFormatterProps {
2915
+ /**
2916
+ * Helper for the IoHost class
2917
+ */
2918
+ readonly ioHelper: IoHelper;
2919
+ /**
2920
+ * The old/current state of the stack.
2921
+ */
2922
+ readonly oldTemplate: any;
2923
+ /**
2924
+ * The new/target state of the stack.
2925
+ */
2926
+ readonly newTemplate: cxapi.CloudFormationStackArtifact;
2927
+ }
2928
+ interface FormatSecurityDiffOptions {
2929
+ /**
2930
+ * The approval level of the security diff
2931
+ */
2932
+ readonly requireApproval: RequireApproval$1;
2933
+ /**
2934
+ * The name of the Stack.
2935
+ */
2936
+ readonly stackName?: string;
2937
+ /**
2938
+ * The changeSet for the Stack.
2939
+ *
2940
+ * @default undefined
2941
+ */
2942
+ readonly changeSet?: DescribeChangeSetOutput;
2943
+ }
2944
+ interface FormatStackDiffOptions {
2945
+ /**
2946
+ * do not filter out AWS::CDK::Metadata or Rules
2947
+ *
2948
+ * @default false
2949
+ */
2950
+ readonly strict?: boolean;
2951
+ /**
2952
+ * lines of context to use in arbitrary JSON diff
2953
+ *
2954
+ * @default 3
2955
+ */
2956
+ readonly context?: number;
2957
+ /**
2958
+ * silences \'There were no differences\' messages
2959
+ *
2960
+ * @default false
2961
+ */
2962
+ readonly quiet?: boolean;
2963
+ /**
2964
+ * The name of the stack
2965
+ */
2966
+ readonly stackName?: string;
2967
+ /**
2968
+ * @default undefined
2969
+ */
2970
+ readonly changeSet?: DescribeChangeSetOutput;
2971
+ /**
2972
+ * @default false
2973
+ */
2974
+ readonly isImport?: boolean;
2975
+ /**
2976
+ * @default undefined
2977
+ */
2978
+ readonly nestedStackTemplates?: {
2979
+ [nestedStackLogicalId: string]: NestedStackTemplates;
2980
+ };
2981
+ }
2982
+ /**
2983
+ * Class for formatting the diff output
2984
+ */
2985
+ export declare class DiffFormatter {
2986
+ private readonly ioHelper;
2987
+ private readonly oldTemplate;
2988
+ private readonly newTemplate;
2989
+ constructor(props: DiffFormatterProps);
2990
+ /**
2991
+ * Format the stack diff
2992
+ */
2993
+ formatStackDiff(options: FormatStackDiffOptions): FormatStackDiffOutput;
2994
+ private formatStackDiffHelper;
2995
+ /**
2996
+ * Format the security diff
2997
+ */
2998
+ formatSecurityDiff(options: FormatSecurityDiffOptions): FormatSecurityDiffOutput;
2513
2999
  }
2514
3000
  /**
2515
3001
  * Represents a general toolkit error in the AWS CDK Toolkit.
@@ -2531,6 +3017,10 @@ export declare class ToolkitError extends Error {
2531
3017
  * Determines if a given error is an instance of AssemblyError.
2532
3018
  */
2533
3019
  static isContextProviderError(x: any): x is ContextProviderError;
3020
+ /**
3021
+ * An AssemblyError with an original error as cause
3022
+ */
3023
+ static withCause(message: string, error: unknown): ToolkitError;
2534
3024
  /**
2535
3025
  * The type of the error, defaults to "toolkit".
2536
3026
  */
@@ -2539,7 +3029,11 @@ export declare class ToolkitError extends Error {
2539
3029
  * Denotes the source of the error as the toolkit.
2540
3030
  */
2541
3031
  readonly source: "toolkit" | "user";
2542
- constructor(message: string, type?: string);
3032
+ /**
3033
+ * The specific original cause of the error, if available
3034
+ */
3035
+ readonly cause?: unknown;
3036
+ constructor(message: string, type?: string, cause?: unknown);
2543
3037
  }
2544
3038
  /**
2545
3039
  * Represents an authentication-specific error in the AWS CDK Toolkit.
@@ -2576,10 +3070,6 @@ export declare class AssemblyError extends ToolkitError {
2576
3070
  * Absence indicates synthesis didn't fully complete.
2577
3071
  */
2578
3072
  readonly stacks?: cxapi.CloudFormationStackArtifact[];
2579
- /**
2580
- * The specific original cause of the error, if available
2581
- */
2582
- readonly cause?: unknown;
2583
3073
  private constructor();
2584
3074
  }
2585
3075
  /**
@@ -2593,22 +3083,10 @@ export declare class ContextProviderError extends ToolkitError {
2593
3083
  constructor(message: string);
2594
3084
  }
2595
3085
  /**
2596
- * @deprecated
3086
+ * Removes CDKMetadata and Outputs in the template so that only resources for importing are left.
3087
+ * @returns template with import resources only
2597
3088
  */
2598
- declare enum RequireApproval$1 {
2599
- /**
2600
- * Never require any security approvals
2601
- */
2602
- NEVER = "never",
2603
- /**
2604
- * Any security changes require an approval
2605
- */
2606
- ANY_CHANGE = "any-change",
2607
- /**
2608
- * Require approval only for changes that are access broadening
2609
- */
2610
- BROADENING = "broadening"
2611
- }
3089
+ export declare function removeNonImportResources(stack: CloudFormationStackArtifact): any;
2612
3090
 
2613
3091
  export {
2614
3092
  MissingContext$1 as MissingContext,