Skip to content
Draft
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
1 change: 1 addition & 0 deletions packages/@aws-cdk/toolkit-lib/lib/api/io/toolkit-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export type ToolkitAction =
| 'synth'
| 'list'
| 'diff'
| 'publish'
| 'deploy'
| 'drift'
| 'rollback'
Expand Down
37 changes: 37 additions & 0 deletions packages/aws-cdk/lib/cli/cdk-toolkit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,30 @@ export class CdkToolkit {
return diffs && options.fail ? 1 : 0;
}

public async publish(options: PublishOptions) {
const buildAsset = async (assetNode: AssetBuildNode) => {
await this.props.deployments.buildSingleAsset(
assetNode.assetManifestArtifact,
assetNode.assetManifest,
assetNode.asset,
{
stack: assetNode.parentStack,
roleArn: options.roleArn,
stackName: assetNode.parentStack.stackName,
},
);
};

const publishAsset = async (assetNode: AssetPublishNode) => {
await this.props.deployments.publishSingleAsset(assetNode.assetManifest, assetNode.asset, {
stack: assetNode.parentStack,
roleArn: options.roleArn,
stackName: assetNode.parentStack.stackName,
forcePublish: options.force,
});
};
}

public async deploy(options: DeployOptions) {
if (options.watch) {
return this.watch(options);
Expand Down Expand Up @@ -1679,6 +1703,19 @@ interface WatchOptions extends Omit<CfnDeployOptions, 'execute'> {
readonly concurrency?: number;
}

export interface PublishOptions {
/**
* Role to pass to CloudFormation for asset publishing
*/
roleArn?: string;

/**
* Always publish, even if it already exists
* @default false
*/
force?: boolean;
}

export interface DeployOptions extends CfnDeployOptions, WatchOptions {
/**
* ARNs of SNS topics that CloudFormation will notify with stack related events
Expand Down
6 changes: 6 additions & 0 deletions packages/aws-cdk/lib/cli/cli-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ export async function makeConfig(): Promise<CliConfig> {
concurrency: { type: 'number', alias: ['n'], desc: 'Maximum number of simultaneous synths to execute.', default: 4, requiresArg: true },
},
},
'publish': {
description: 'Publishes synthesized assets (e.g. Docker images, Lambda ZIPs, S3 files) to their destinations',
options: {
force: { alias: 'f', type: 'boolean', desc: 'Always publish, even if it already exists', default: false },
},
},
'deploy': {
description: 'Deploys the stack(s) named STACKS into your AWS account',
options: {
Expand Down
11 changes: 11 additions & 0 deletions packages/aws-cdk/lib/cli/cli-type-registry.json
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,17 @@
}
}
},
"publish": {
"description": "Publishes synthesized assets (e.g. Docker images, Lambda ZIPs, S3 files) to their destinations",
"options": {
"force": {
"alias": "f",
"type": "boolean",
"desc": "Always publish, even if it already exists",
"default": false
}
}
},
"deploy": {
"description": "Deploys the stack(s) named STACKS into your AWS account",
"options": {
Expand Down
7 changes: 7 additions & 0 deletions packages/aws-cdk/lib/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,13 @@ export async function exec(args: string[], synthesizer?: Synthesizer): Promise<n
},
});

case 'publish':
ioHost.currentAction = 'publish';
return cli.publish({
roleArn: args.roleArn,
force: args.force,
});

case 'deploy':
ioHost.currentAction = 'deploy';
const parameterMap: { [name: string]: string | undefined } = {};
Expand Down
10 changes: 10 additions & 0 deletions packages/aws-cdk/lib/cli/convert-to-user-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ export function convertYargsToUserInput(args: any): UserInput {
};
break;

case 'publish':
commandOptions = {
force: args.force,
};
break;

case 'deploy':
commandOptions = {
all: args.all,
Expand Down Expand Up @@ -399,6 +405,9 @@ export function convertConfigToUserInput(config: any): UserInput {
safe: config.flags?.safe,
concurrency: config.flags?.concurrency,
};
const publishOptions = {
force: config.publish?.force,
};
const deployOptions = {
all: config.deploy?.all,
buildExclude: config.deploy?.buildExclude,
Expand Down Expand Up @@ -536,6 +545,7 @@ export function convertConfigToUserInput(config: any): UserInput {
bootstrap: bootstrapOptions,
gc: gcOptions,
flags: flagsOptions,
publish: publishOptions,
deploy: deployOptions,
rollback: rollbackOptions,
import: importOptions,
Expand Down
8 changes: 8 additions & 0 deletions packages/aws-cdk/lib/cli/parse-command-line-arguments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,14 @@ export function parseCommandLineArguments(args: Array<string>): any {
requiresArg: true,
}),
)
.command('publish', 'Publishes synthesized assets (e.g. Docker images, Lambda ZIPs, S3 files) to their destinations', (yargs: Argv) =>
yargs.option('force', {
default: false,
alias: 'f',
type: 'boolean',
desc: 'Always publish, even if it already exists',
}),
)
.command('deploy [STACKS..]', 'Deploys the stack(s) named STACKS into your AWS account', (yargs: Argv) =>
yargs
.option('all', {
Expand Down
1 change: 1 addition & 0 deletions packages/aws-cdk/lib/cli/user-configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export enum Command {
LIST = 'list',
DIFF = 'diff',
BOOTSTRAP = 'bootstrap',
PUBLISH = 'publish',
DEPLOY = 'deploy',
DESTROY = 'destroy',
SYNTHESIZE = 'synthesize',
Expand Down
21 changes: 21 additions & 0 deletions packages/aws-cdk/lib/cli/user-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ export interface UserInput {
*/
readonly flags?: FlagsOptions;

/**
* Publishes synthesized assets (e.g. Docker images, Lambda ZIPs, S3 files) to their destinations
*/
readonly publish?: PublishOptions;

/**
* Deploys the stack(s) named STACKS into your AWS account
*/
Expand Down Expand Up @@ -710,6 +715,22 @@ export interface FlagsOptions {
readonly FLAGNAME?: Array<string>;
}

/**
* Publishes synthesized assets (e.g. Docker images, Lambda ZIPs, S3 files) to their destinations
*
* @struct
*/
export interface PublishOptions {
/**
* Always publish, even if it already exists
*
* aliases: f
*
* @default - false
*/
readonly force?: boolean;
}

/**
* Deploys the stack(s) named STACKS into your AWS account
*
Expand Down
1 change: 1 addition & 0 deletions packages/aws-cdk/test/cli/cli-arguments.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ describe('config', () => {
}),
context: expect.anything(),
acknowledge: expect.anything(),
publish: expect.anything(),
deploy: expect.anything(),
destroy: expect.anything(),
diff: expect.anything(),
Expand Down
Loading