Skip to content

Commit

Permalink
Merge branch 'main' into add-saiyush
Browse files Browse the repository at this point in the history
  • Loading branch information
Leo10Gama authored Nov 5, 2024
2 parents 3180561 + 9027cd2 commit af32e81
Show file tree
Hide file tree
Showing 55 changed files with 2,643 additions and 642 deletions.
58 changes: 0 additions & 58 deletions .github/workflows/repo-metrics-weekly.yml

This file was deleted.

1 change: 1 addition & 0 deletions lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"packages/@aws-cdk-testing/*",
"packages/@aws-cdk/*/lambda-packages/*",
"tools/@aws-cdk/cdk-build-tools",
"tools/@aws-cdk/yargs-gen",
"tools/@aws-cdk/cdk-release",
"tools/@aws-cdk/node-bundle",
"tools/@aws-cdk/pkglint",
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"packages/@aws-cdk-testing/*",
"packages/@aws-cdk/*/lambda-packages/*",
"tools/@aws-cdk/cdk-build-tools",
"tools/@aws-cdk/yargs-gen",
"tools/@aws-cdk/cdk-release",
"tools/@aws-cdk/node-bundle",
"tools/@aws-cdk/pkglint",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
const cdk = require('aws-cdk-lib');
const lambda = require('aws-cdk-lib/aws-lambda');
const sqs = require('aws-cdk-lib/aws-sqs');
const cr = require('aws-cdk-lib/custom-resources');

/**
* This stack will be deployed in multiple phases, to achieve a very specific effect
*
* It contains resources r1 and r2, where r1 gets deployed first.
* It contains resources r1 and r2, and a queue q, where r1 gets deployed first.
*
* - PHASE = 1: both resources deploy regularly.
* - PHASE = 2a: r1 gets updated, r2 will fail to update
* - PHASE = 2b: r1 gets updated, r2 will fail to update, and r1 will fail its rollback.
* - PHASE = 3: q gets replaced w.r.t. phases 1 and 2
*
* To exercise this app:
*
Expand All @@ -22,7 +24,7 @@ const cr = require('aws-cdk-lib/custom-resources');
* # This will start a rollback that will fail because r1 fails its rollabck
*
* env PHASE=2b npx cdk rollback --force
* # This will retry the rollabck and skip r1
* # This will retry the rollback and skip r1
* ```
*/
class RollbacktestStack extends cdk.Stack {
Expand All @@ -31,6 +33,7 @@ class RollbacktestStack extends cdk.Stack {

let r1props = {};
let r2props = {};
let fifo = false;

const phase = process.env.PHASE;
switch (phase) {
Expand All @@ -46,6 +49,9 @@ class RollbacktestStack extends cdk.Stack {
r1props.FailRollback = true;
r2props.FailUpdate = true;
break;
case '3':
fifo = true;
break;
}

const fn = new lambda.Function(this, 'Fun', {
Expand Down Expand Up @@ -76,6 +82,10 @@ class RollbacktestStack extends cdk.Stack {
properties: r2props,
});
r2.node.addDependency(r1);

new sqs.Queue(this, 'Queue', {
fifo,
});
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2450,6 +2450,103 @@ integTest(
}),
);

integTest(
'automatic rollback if paused and change contains a replacement',
withSpecificFixture('rollback-test-app', async (fixture) => {
let phase = '1';

// Should succeed
await fixture.cdkDeploy('test-rollback', {
options: ['--no-rollback'],
modEnv: { PHASE: phase },
verbose: false,
});
try {
phase = '2a';

// Should fail
const deployOutput = await fixture.cdkDeploy('test-rollback', {
options: ['--no-rollback'],
modEnv: { PHASE: phase },
verbose: false,
allowErrExit: true,
});
expect(deployOutput).toContain('UPDATE_FAILED');

// Do a deployment with a replacement and --force: this will roll back first and then deploy normally
phase = '3';
await fixture.cdkDeploy('test-rollback', {
options: ['--no-rollback', '--force'],
modEnv: { PHASE: phase },
verbose: false,
});
} finally {
await fixture.cdkDestroy('test-rollback');
}
}),
);

integTest(
'automatic rollback if paused and --no-rollback is removed from flags',
withSpecificFixture('rollback-test-app', async (fixture) => {
let phase = '1';

// Should succeed
await fixture.cdkDeploy('test-rollback', {
options: ['--no-rollback'],
modEnv: { PHASE: phase },
verbose: false,
});
try {
phase = '2a';

// Should fail
const deployOutput = await fixture.cdkDeploy('test-rollback', {
options: ['--no-rollback'],
modEnv: { PHASE: phase },
verbose: false,
allowErrExit: true,
});
expect(deployOutput).toContain('UPDATE_FAILED');

// Do a deployment removing --no-rollback: this will roll back first and then deploy normally
phase = '1';
await fixture.cdkDeploy('test-rollback', {
options: ['--force'],
modEnv: { PHASE: phase },
verbose: false,
});
} finally {
await fixture.cdkDestroy('test-rollback');
}
}),
);

integTest(
'automatic rollback if replacement and --no-rollback is removed from flags',
withSpecificFixture('rollback-test-app', async (fixture) => {
let phase = '1';

// Should succeed
await fixture.cdkDeploy('test-rollback', {
options: ['--no-rollback'],
modEnv: { PHASE: phase },
verbose: false,
});
try {
// Do a deployment with a replacement and removing --no-rollback: this will do a regular rollback deploy
phase = '3';
await fixture.cdkDeploy('test-rollback', {
options: ['--force'],
modEnv: { PHASE: phase },
verbose: false,
});
} finally {
await fixture.cdkDestroy('test-rollback');
}
}),
);

integTest(
'test cdk rollback --force',
withSpecificFixture('rollback-test-app', async (fixture) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-kinesisfirehose-alpha/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ encryption with AWS Key Management Service (AWS KMS) for encrypting delivered da
Amazon S3. You can choose to not encrypt the data or to encrypt with a key from the list
of AWS KMS keys that you own. For more information,
see [Protecting Data Using Server-Side Encryption with AWS KMS–Managed Keys (SSE-KMS)](https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingKMSEncryption.html).
Data is not encrypted by default.
By default, encryption isn’t directly enabled on the delivery stream; instead, it uses the default encryption settings of the destination S3 bucket.

```ts
declare const bucket: s3.Bucket;
Expand Down
4 changes: 2 additions & 2 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.103.1 - https://www.npmjs.com/package/@jsii/check-node/v/1.103.1 | Apache-2.0
** @jsii/check-node@1.104.0 - https://www.npmjs.com/package/@jsii/check-node/v/1.104.0 | Apache-2.0
jsii
Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.

Expand Down Expand Up @@ -3562,7 +3562,7 @@ THE SOFTWARE.

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

** tslib@2.7.0 - https://www.npmjs.com/package/tslib/v/2.7.0 | 0BSD
** tslib@2.8.0 - https://www.npmjs.com/package/tslib/v/2.8.0 | 0BSD
Copyright (c) Microsoft Corporation.

Permission to use, copy, modify, and/or distribute this software for any
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/cloudformation-diff/lib/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export class Formatter {
const resourceType = diff.isRemoval ? diff.oldResourceType : diff.newResourceType;

// eslint-disable-next-line max-len
this.print(`${this.formatResourcePrefix(diff)} ${this.formatValue(resourceType, chalk.cyan)} ${this.formatLogicalId(logicalId)} ${this.formatImpact(diff.changeImpact)}`);
this.print(`${this.formatResourcePrefix(diff)} ${this.formatValue(resourceType, chalk.cyan)} ${this.formatLogicalId(logicalId)} ${this.formatImpact(diff.changeImpact)}`.trimEnd());

if (diff.isUpdate) {
const differenceCount = diff.differenceCount;
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk-lib/assertions/lib/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class Template {

private constructor(template: { [key: string]: any }, templateParsingOptions: TemplateParsingOptions = {}) {
this.template = template as TemplateType;
if (!templateParsingOptions?.skipCyclicalDependenciesCheck ?? true) {
if (!templateParsingOptions.skipCyclicalDependenciesCheck) {
checkTemplateForCyclicDependencies(this.template);
}
}
Expand Down
23 changes: 22 additions & 1 deletion packages/aws-cdk-lib/assertions/test/template.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1368,7 +1368,28 @@ describe('Template', () => {
}).toThrow(/dependency cycle/);
});

test('does not throw when given a template with cyclic dependencies if check is skipped', () => {
test('throws when given a template with cyclic dependencies if skipCyclicalDependenciesCheck is false', () => {
expect(() => {
Template.fromJSON({
Resources: {
Res1: {
Type: 'Foo',
Properties: {
Thing: { Ref: 'Res2' },
},
},
Res2: {
Type: 'Foo',
DependsOn: ['Res1'],
},
},
}, {
skipCyclicalDependenciesCheck: false,
});
}).toThrow(/dependency cycle/);
});

test('does not throw when given a template with cyclic dependencies if skipCyclicalDependenciesCheck is true', () => {
expect(() => {
Template.fromJSON({
Resources: {
Expand Down
3 changes: 3 additions & 0 deletions packages/aws-cdk-lib/aws-bedrock/lib/foundation-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ export class FoundationModelIdentifier {
/** Base model "anthropic.claude-3-haiku-20240307-v1:0:48k" */
public static readonly ANTHROPIC_CLAUDE_3_HAIKU_20240307_V1_0_48K = new FoundationModelIdentifier('anthropic.claude-3-haiku-20240307-v1:0:48k');

/** Base model "anthropic.claude-3-5-haiku-20241022-v1:0" */
public static readonly ANTHROPIC_CLAUDE_3_5_HAIKU_20241022_V1_0 = new FoundationModelIdentifier('anthropic.claude-3-5-haiku-20241022-v1:0');

/** Base model "anthropic.claude-3-haiku-20240307-v1:0:200k" */
public static readonly ANTHROPIC_CLAUDE_3_HAIKU_20240307_V1_0_200K = new FoundationModelIdentifier('anthropic.claude-3-haiku-20240307-v1:0:200k');

Expand Down
10 changes: 8 additions & 2 deletions packages/aws-cdk-lib/aws-s3-deployment/lib/bucket-deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@ export interface BucketDeploymentProps {
readonly destinationBucket: s3.IBucket;

/**
* Key prefix in the destination bucket.
* Key prefix in the destination bucket. Must be <=104 characters
*
* Must be <=104 characters
* If it's set with prune: true, it will only prune files with the prefix.
*
* We recommend to always configure the `destinationKeyPrefix` property. This will prevent the deployment
* from accidentally deleting data that wasn't uploaded by it.
*
* @default "/" (unzip to root of the destination bucket)
*/
Expand Down Expand Up @@ -71,6 +74,9 @@ export interface BucketDeploymentProps {
readonly include?: string[];

/**
* By default, files in the destination bucket that don't exist in the source will be deleted
* when the BucketDeployment resource is created or updated.
*
* If this is set to false, files in the destination bucket that
* do not exist in the asset, will NOT be deleted during deployment (create/update).
*
Expand Down
23 changes: 23 additions & 0 deletions packages/aws-cdk/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
## CLI Commands

All CDK CLI Commands are defined in `lib/config.ts`. This file is translated
into a valid `yargs` configuration by `bin/yargs-gen`, which is generated by `@aws-cdk/yargs-gen`.
The `yargs` configuration is generated into the function `parseCommandLineArguments()`,
in `lib/parse-command-line-arguments.ts`, and is checked into git for readability and
inspectability; do not edit this file by hand, as every subsequent `yarn build` will
overwrite any manual edits. If you need to leverage a `yargs` feature not used by
the CLI, you must add support for it to `@aws-cdk/yargs-gen`.

Note that `bin/yargs-gen` is executed by `ts-node`, which allows `config.ts` to
reference functions and other identifiers defined in the CLI before the CLI is
built.

### Dynamic Values

Some values, such as the user's platform, cannot be computed at build time.
Some commands depend on these values, and thus `yargs-gen` must generate the
code to compute these values at build time.

The only way to do this today is to reference a parameter with `DynamicValue.fromParameter`.
The caller of `parseCommandLineArguments()` must pass the parameter.

## Integration Tests

Unit tests are automatically run as part of the regular build. Integration tests
Expand Down
Loading

0 comments on commit af32e81

Please sign in to comment.