Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { ToolkitServices } from '../../../toolkit/private';
import { CODES } from '../../io/private';
import { ActionAwareIoHost } from '../../shared-private';
import { ToolkitError } from '../../shared-public';
import type { AppSynthOptions } from '../source-builder';
import type { AppSynthOptions, LoadAssemblyOptions } from '../source-builder';

export { guessExecutable } from '../../../api/aws-cdk';

Expand Down Expand Up @@ -149,9 +149,11 @@ export async function checkContextOverflowSupport(assembly: cxapi.CloudAssembly,
/**
* Safely create an assembly from a cloud assembly directory
*/
export async function assemblyFromDirectory(assemblyDir: string, ioHost: ActionAwareIoHost) {
export async function assemblyFromDirectory(assemblyDir: string, ioHost: ActionAwareIoHost, loadOptions: LoadAssemblyOptions = {}) {
try {
const assembly = new cxapi.CloudAssembly(assemblyDir, {
skipVersionCheck: !(loadOptions.checkVersion ?? true),
skipEnumCheck: !(loadOptions.checkEnums ?? true),
// We sort as we deploy
topoSort: false,
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as cxapi from '@aws-cdk/cx-api';
import * as fs from 'fs-extra';
import type { AssemblySourceProps, ICloudAssemblySource } from '../';
import type { AssemblyDirectoryProps, AssemblySourceProps, ICloudAssemblySource } from '../';
import { ContextAwareCloudAssembly, ContextAwareCloudAssemblyProps } from './context-aware-source';
import { execInChildProcess } from './exec';
import { assemblyFromDirectory, changeDir, determineOutputDirectory, guessExecutable, prepareDefaultEnvironment, withContext, withEnv } from './prepare-source';
Expand Down Expand Up @@ -52,7 +52,7 @@ export abstract class CloudAssemblySourceBuilder {
return assembly;
}

return new cxapi.CloudAssembly(assembly.directory);
return assemblyFromDirectory(assembly.directory, services.ioHost, props.loadAssemblyOptions);
},
},
contextAssemblyProps,
Expand All @@ -64,7 +64,7 @@ export abstract class CloudAssemblySourceBuilder {
* @param directory the directory of a already produced Cloud Assembly.
* @returns the CloudAssembly source
*/
public async fromAssemblyDirectory(directory: string): Promise<ICloudAssemblySource> {
public async fromAssemblyDirectory(directory: string, props: AssemblyDirectoryProps = {}): Promise<ICloudAssemblySource> {
const services: ToolkitServices = await this.sourceBuilderServices();
const contextAssemblyProps: ContextAwareCloudAssemblyProps = {
services,
Expand All @@ -77,7 +77,7 @@ export abstract class CloudAssemblySourceBuilder {
produce: async () => {
// @todo build
await services.ioHost.notify(CODES.CDK_ASSEMBLY_I0150.msg('--app points to a cloud assembly, so we bypass synth'));
return assemblyFromDirectory(directory, services.ioHost);
return assemblyFromDirectory(directory, services.ioHost, props.loadAssemblyOptions);
},
},
contextAssemblyProps,
Expand Down Expand Up @@ -136,7 +136,7 @@ export abstract class CloudAssemblySourceBuilder {
extraEnv: envWithContext,
cwd: props.workingDirectory,
});
return assemblyFromDirectory(outdir, services.ioHost);
return assemblyFromDirectory(outdir, services.ioHost, props.loadAssemblyOptions);
});
} finally {
await lock?.release();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ export interface AssemblyBuilderProps {

export type AssemblyBuilder = (props: AssemblyBuilderProps) => Promise<cxschema.ICloudAssembly>;

/**
* Configuration for creating a CLI from an AWS CDK App directory
*/
export interface AssemblyDirectoryProps {
/**
* Options to configure loading of the assembly after it has been synthesized
*/
readonly loadAssemblyOptions?: LoadAssemblyOptions;
}

/**
* Configuration for creating a CLI from an AWS CDK App directory
*/
Expand Down Expand Up @@ -59,6 +69,11 @@ export interface AssemblySourceProps {
* Options that are passed through the context to a CDK app on synth
*/
readonly synthOptions?: AppSynthOptions;

/**
* Options to configure loading of the assembly after it has been synthesized
*/
readonly loadAssemblyOptions?: LoadAssemblyOptions;
}

/**
Expand Down Expand Up @@ -123,3 +138,28 @@ export interface AppSynthOptions {
*/
readonly bundlingForStacks?: string;
}

/**
* Options to configure loading of the assembly after it has been synthesized
*/
export interface LoadAssemblyOptions {
/**
* Check the Toolkit supports the Cloud Assembly Schema version
*
* When disabled, allows to Toolkit to read a newer cloud assembly than the CX API is designed
* to support. Your application may not be aware of all features that in use in the Cloud Assembly.
*
* @default true
*/
readonly checkVersion?: boolean;

/**
* Validate enums to only have known values
*
* When disabled, the Toolkit may read enum values it doesn't know about yet.
* You will have to make sure to always check the values of enums you encounter in the manifest.
*
* @default true
*/
readonly checkEnums?: boolean;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"version": "39.0.0",
"files": {
"6cf0c6d5d33f7914e048b4435b7ffc1909cdec43efb95fcde227762c2f0effd1": {
"source": {
"path": "Stack1.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "6cf0c6d5d33f7914e048b4435b7ffc1909cdec43efb95fcde227762c2f0effd1.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
}
},
"dockerImages": {}
}
Loading