Skip to content

Commit

Permalink
temp staging
Browse files Browse the repository at this point in the history
  • Loading branch information
msambol committed Dec 23, 2023
1 parent b42cb06 commit c583e43
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 56 deletions.
1 change: 1 addition & 0 deletions packages/@aws-cdk-testing/cli-integ/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export * from './integ-test';
export * from './memoize';
export * from './resource-pool';
export * from './with-cli-lib';
export * from './with-cli-lib-no-stacks';
export * from './with-sam';
export * from './shell';
export * from './with-aws';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,18 @@ export class CliLibNoStacksIntegrationTestFixture extends TestFixture {
*/
public async cdk(args: string[], options: CdkCliOptions = {}) {
const action = args[0];
const stackName = args[1];
const ignoreNoStacks = args[1];

const cliOpts: Record<string, any> = {
stacks: stackName ? [stackName] : undefined,
};
const cliOpts: Record<string, any> = {};

if (action === 'deploy') {
cliOpts.requireApproval = options.neverRequireApproval ? 'never' : 'broadening';
}

if (ignoreNoStacks == '--ignore-no-stacks') {
cliOpts.ignoreNoStacks = true;
}

return this.shell(['node', '--input-type=module', `<<__EOS__
import { AwsCdkCli } from '@aws-cdk/cli-lib-alpha';
const cli = AwsCdkCli.fromCdkAppDirectory();
Expand All @@ -125,7 +127,6 @@ __EOS__`], {
modEnv: {
AWS_REGION: this.aws.region,
AWS_DEFAULT_REGION: this.aws.region,
STACK_NAME_PREFIX: this.stackNamePrefix,
PACKAGE_LAYOUT_VERSION: this.packages.majorVersion(),
...options.modEnv,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,6 @@ class BuiltinLambdaStack extends cdk.Stack {
}
}

class StackWithNoResources extends cdk.Stack {}

const app = new cdk.App({
context: {
'@aws-cdk/core:assetHashSalt': process.env.CODEBUILD_BUILD_ID, // Force all assets to be unique, but consistent in one build
Expand Down Expand Up @@ -494,8 +492,7 @@ switch (stackSet) {
stage.synth({ validateOnSynthesis: true });
break;

case 'stage-with-no-resources':
new StackWithNoResources(app, `${stackPrefix}-stage-with-no-resources`);
case 'stage-with-no-stacks':
break;

default:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
const cdk = require('aws-cdk-lib/core');

const stackPrefix = process.env.STACK_NAME_PREFIX;
if (!stackPrefix) {
throw new Error(`the STACK_NAME_PREFIX environment variable is required`);
}

const app = new cdk.App();
new NoStackApp(app, `${stackPrefix}-no-stack-1`);

app.synth();
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { integTest, withCliLibFixture, withCliLibNoStacksFixture } from '../../lib';
import { integTest, withCliLibFixture } from '../../lib';

jest.setTimeout(2 * 60 * 60_000); // Includes the time to acquire locks, worst-case single-threaded runtime

Expand Down Expand Up @@ -47,28 +47,6 @@ integTest('cli-lib deploy', withCliLibFixture(async (fixture) => {
}
}));

integTest('cli-lib deploy no stack', withCliLibNoStacksFixture(async (fixture) => {
const stackName = fixture.fullStackName('no-stack-1');

try {
// deploy the stack
await fixture.cdk(['deploy', stackName], {
options: ['--ignore-no-stacks'],
});

// verify the number of resources in the stack
const expectedStack = await fixture.aws.cloudFormation('describeStackResources', {
StackName: stackName,
});
expect(expectedStack.StackResources?.length).toEqual(0);
} finally {
// delete the stack
await fixture.cdk(['destroy', stackName], {
captureStderr: false,
});
}
}));

integTest('security related changes without a CLI are expected to fail when approval is required', withCliLibFixture(async (fixture) => {
const stdErr = await fixture.cdk(['deploy', fixture.fullStackName('simple-1')], {
onlyStderr: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { promises as fs, existsSync } from 'fs';
import * as os from 'os';
import * as path from 'path';
import { integTest, cloneDirectory, shell, withDefaultFixture, retry, sleep, randomInteger, withSamIntegrationFixture, RESOURCES_DIR, withCDKMigrateFixture } from '../../lib';
import { integTest, cloneDirectory, shell, withDefaultFixture, retry, sleep, randomInteger, withSamIntegrationFixture, RESOURCES_DIR, withCDKMigrateFixture, withCliLibNoStacksFixture } from '../../lib';

jest.setTimeout(2 * 60 * 60_000); // Includes the time to acquire locks, worst-case single-threaded runtime

Expand Down Expand Up @@ -780,17 +780,22 @@ integTest('deploy stack without resource', withDefaultFixture(async (fixture) =>
.rejects.toThrow('conditional-resource does not exist');
}));

integTest('deploy --ignore-no-stacks', withDefaultFixture(async (fixture) => {
const stackArn = await fixture.cdkDeploy('stage-with-no-resources', {
integTest('deploy no stacks with --ignore-no-stacks', withDefaultFixture(async (fixture) => {
// empty array for stack names
await fixture.cdkDeploy([], {
options: ['--ignore-no-stacks'],
modEnv: {
INTEG_STACK_SET: 'stage-with-no-resources',
INTEG_STACK_SET: 'stage-with-no-stacks',
},
});
}));

// verify that we only deployed both stacks (there are 2 ARNs in the output)
/* eslint-disable no-console */
console.log(stackArn);
integTest('deploy no stacks error', withDefaultFixture(async (fixture) => {
await expect(fixture.cdkDeploy([], {
modEnv: {
INTEG_STACK_SET: 'stage-with-no-stacks',
},
})).rejects.toThrow('exited with error');
}));

integTest('IAM diff', withDefaultFixture(async (fixture) => {
Expand Down
1 change: 1 addition & 0 deletions packages/@aws-cdk/cdk-cli-wrapper/lib/cdk-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ export class CdkCliWrapper implements ICdk {
...renderBooleanArg('previous-parameters', options.usePreviousParameters),
...renderBooleanArg('rollback', options.rollback),
...renderBooleanArg('staging', options.staging),
...renderBooleanArg('ignore-no-stacks', options.ignoreNoStacks),
...options.reuseAssets ? renderArrayArg('--reuse-assets', options.reuseAssets) : [],
...options.notificationArns ? renderArrayArg('--notification-arns', options.notificationArns) : [],
...options.parameters ? renderMapArrayArg('--parameters', options.parameters) : [],
Expand Down
7 changes: 7 additions & 0 deletions packages/@aws-cdk/cdk-cli-wrapper/lib/commands/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,13 @@ export interface DeployOptions extends DefaultCdkOptions {
* @default 1
*/
readonly concurrency?: number;

/**
* Whether to deploy if the app contains no stacks.
*
* @default false
*/
readonly ignoreNoStacks?: boolean;
}
export type DeploymentMethod = 'direct' | 'change-set';

Expand Down
2 changes: 2 additions & 0 deletions packages/@aws-cdk/cdk-cli-wrapper/test/cdk-wrapper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ test('deploy with all arguments', () => {
versionReporting: true,
usePreviousParameters: true,
progress: StackActivityProgress.BAR,
ignoreNoStacks: true,
});

// THEN
Expand Down Expand Up @@ -129,6 +130,7 @@ test('deploy with all arguments', () => {
'--previous-parameters',
'--progress', 'bar',
'--app',
'--ignore-no-stacks',
'node bin/my-app.js',
'test-stack1',
]),
Expand Down
6 changes: 3 additions & 3 deletions packages/@aws-cdk/cli-lib-alpha/THIRD_PARTY_LICENSES
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ The @aws-cdk/cli-lib-alpha package includes the following third-party software/l

----------------

** @jsii/check-node@1.92.0 - https://www.npmjs.com/package/@jsii/check-node/v/1.92.0 | Apache-2.0
** @jsii/check-node@1.93.0 - https://www.npmjs.com/package/@jsii/check-node/v/1.93.0 | Apache-2.0
jsii
Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.

Expand Down Expand Up @@ -471,7 +471,7 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH RE

----------------

** aws-sdk@2.1498.0 - https://www.npmjs.com/package/aws-sdk/v/2.1498.0 | Apache-2.0
** aws-sdk@2.1517.0 - https://www.npmjs.com/package/aws-sdk/v/2.1517.0 | Apache-2.0
AWS SDK for JavaScript
Copyright 2012-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.

Expand Down Expand Up @@ -668,7 +668,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI

----------------

** cdk-from-cfn@0.84.0 - https://www.npmjs.com/package/cdk-from-cfn/v/0.84.0 | MIT OR Apache-2.0
** cdk-from-cfn@0.91.0 - https://www.npmjs.com/package/cdk-from-cfn/v/0.91.0 | MIT OR Apache-2.0

----------------

Expand Down
9 changes: 1 addition & 8 deletions packages/aws-cdk/lib/api/deploy-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export interface DeployStackOptions {
* The collection of extra parameters
* (in addition to those used for assets)
* to pass to the deployed template.
* Note that parameters with `undefined` or empty values will be ignored,
* Note that parameters with `undefined` or empty values will be d,
* and not passed to the template.
*
* @default - no additional parameters will be passed to the template
Expand Down Expand Up @@ -205,13 +205,6 @@ export interface DeployStackOptions {
* @default true To remain backward compatible.
*/
readonly assetParallelism?: boolean;

/**
* Whether to deploy if the app contains no stacks.
*
* @default false
*/
ignoreNoStacks?: boolean;
}

export type DeploymentMethod =
Expand Down

0 comments on commit c583e43

Please sign in to comment.