Skip to content

Commit

Permalink
Merge branch 'main' into mrgrain/chore/upgrade-pacmak-and-other-jsii
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Jan 22, 2025
2 parents 121f554 + 6677b33 commit dbfdcd4
Show file tree
Hide file tree
Showing 22 changed files with 1,688 additions and 55 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ When approved this pushes the PR to the testing pipeline,
thus starting the cli integ test build.
Owner: Core CDK team

### Initial Priority Assignment

[project-prioritization-assignment.yml](project-prioritization-assignment.yml): GitHub action for automatically adding PR's with priorities to the project priority board based on their labels.
Owner: CDK Support team

## Issue Triggered

### Closed Issue Message
Expand Down Expand Up @@ -103,3 +108,13 @@ Owner: Core CDK team

[update-contributors.yml](update-contributors.yml): GitHub action that runs monthly to create a pull request for updating a CONTRIBUTORS file with the top contributors.
Owner: Core CDK team

### R2 Priority Assignment

[project-prioritization-r2-assignment.yml](project-prioritization-r2-assignment.yml): GitHub action that runs every 6 hours to add PR's to the priority project board that satisfies R2 Priority.
Owner: CDK Support team

### R5 Priority Assignment

[project-prioritization-r5-assignment.yml](project-prioritization-r5-assignment.yml): GitHub action that runs every day to add PR's to the priority project board that satisfies R5 Priority.
Owner: CDK Support team
22 changes: 22 additions & 0 deletions .github/workflows/project-prioritization-assignment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: PR Prioritization
on:
pull_request_target:
types:
- labeled
- opened
- reopened
- synchronize
- ready_for_review

jobs:
prioritize:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Add PR to Project & Set Priority
uses: actions/github-script@v7
with:
github-token: ${{ secrets.PROJEN_GITHUB_TOKEN }}
script: |
const script = require('./scripts/prioritization/assign-priority.js')
await script({github, context})
19 changes: 19 additions & 0 deletions .github/workflows/project-prioritization-r2-assignment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: PR Prioritization R2 Check
on:
schedule:
- cron: '0 */6 * * 1-5' # Runs every 6 hours during weekdays
workflow_dispatch: # Manual trigger

jobs:
update_project_status:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Check and assign R2 Priority to PRs
uses: actions/github-script@v7
with:
github-token: ${{ secrets.PROJEN_GITHUB_TOKEN }}
script: |
const script = require('./scripts/prioritization/assign-r2-priority.js')
await script({github})
18 changes: 18 additions & 0 deletions .github/workflows/project-prioritization-r5-assignment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: PR Prioritization R5 Check
on:
schedule:
- cron: '0 6 * * 1-5' # Runs at 6AM every day during weekdays
workflow_dispatch: # Manual trigger

jobs:
update_project_status:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check and Assign R5 Priority to PRs
uses: actions/github-script@v7
with:
github-token: ${{ secrets.PROJEN_GITHUB_TOKEN }}
script: |
const script = require('./scripts/prioritization/assign-r5-priority.js')
await script({github})
2 changes: 1 addition & 1 deletion packages/@aws-cdk-testing/cli-integ/lib/with-cdk-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ export class TestFixture extends ShellHelper {
* Since we go striping across regions, it's going to suck doing this
* by hand so let's just mass-automate it.
*/
async function ensureBootstrapped(fixture: TestFixture) {
export async function ensureBootstrapped(fixture: TestFixture) {
// Always use the modern bootstrap stack, otherwise we may get the error
// "refusing to downgrade from version 7 to version 0" when bootstrapping with default
// settings using a v1 CLI.
Expand Down
10 changes: 8 additions & 2 deletions packages/@aws-cdk-testing/cli-integ/lib/with-cli-lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import * as path from 'path';
import { TestContext } from './integ-test';
import { RESOURCES_DIR } from './resources';
import { AwsContext, withAws } from './with-aws';
import { cloneDirectory, installNpmPackages, TestFixture, DEFAULT_TEST_TIMEOUT_S, CdkCliOptions } from './with-cdk-app';
import { cloneDirectory, installNpmPackages, TestFixture, DEFAULT_TEST_TIMEOUT_S, CdkCliOptions, DisableBootstrapContext, ensureBootstrapped } from './with-cdk-app';
import { withTimeout } from './with-timeout';

/**
* Higher order function to execute a block with a CliLib Integration CDK app fixture
*/
export function withCliLibIntegrationCdkApp<A extends TestContext & AwsContext>(block: (context: CliLibIntegrationTestFixture) => Promise<void>) {
export function withCliLibIntegrationCdkApp<A extends TestContext & AwsContext & DisableBootstrapContext>(
block: (context: CliLibIntegrationTestFixture) => Promise<void>) {
return async (context: A) => {
const randy = context.randomString;
const stackNamePrefix = `cdktest-${randy}`;
Expand Down Expand Up @@ -44,6 +45,10 @@ export function withCliLibIntegrationCdkApp<A extends TestContext & AwsContext>(
'constructs': '^10',
});

if (!context.disableBootstrap) {
await ensureBootstrapped(fixture);
}

await block(fixture);
} catch (e: any) {
// We survive certain cases involving gopkg.in
Expand Down Expand Up @@ -132,3 +137,4 @@ __EOS__`], {
}

}

14 changes: 12 additions & 2 deletions packages/aws-cdk-lib/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,19 @@ baseConfig.rules['import/no-extraneous-dependencies'] = [


// no-throw-default-error
const modules = ['aws-s3', 'aws-lambda', 'aws-rds', 'aws-sns'];
const enableNoThrowDefaultErrorIn = [
'aws-lambda',
'aws-rds',
'aws-s3',
'aws-sns',
'aws-sqs',
'aws-ssm',
'aws-ssmcontacts',
'aws-ssmincidents',
'aws-ssmquicksetup',
];
baseConfig.overrides.push({
files: modules.map(m => `./${m}/lib/**`),
files: enableNoThrowDefaultErrorIn.map(m => `./${m}/lib/**`),
rules: { "@cdklabs/no-throw-default-error": ['error'] },
});

Expand Down
3 changes: 2 additions & 1 deletion packages/aws-cdk-lib/aws-sqs/lib/policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { IQueue } from './queue-base';
import { CfnQueuePolicy } from './sqs.generated';
import { PolicyDocument } from '../../aws-iam';
import { Resource } from '../../core';
import { ValidationError } from '../../core/lib/errors';

/**
* Properties to associate SQS queues with a policy
Expand Down Expand Up @@ -51,6 +52,6 @@ export class QueuePolicy extends Resource {
* @attribute
*/
public get queuePolicyId(): string {
throw new Error('QueuePolicy.queuePolicyId has been removed from CloudFormation');
throw new ValidationError('QueuePolicy.queuePolicyId has been removed from CloudFormation', this);
}
}
27 changes: 14 additions & 13 deletions packages/aws-cdk-lib/aws-sqs/lib/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { validateProps } from './validate-props';
import * as iam from '../../aws-iam';
import * as kms from '../../aws-kms';
import { Duration, RemovalPolicy, Stack, Token, ArnFormat, Annotations } from '../../core';
import { ValidationError } from '../../core/lib/errors';

/**
* Properties for creating a new Queue
Expand Down Expand Up @@ -325,10 +326,10 @@ export class Queue extends QueueBase {
} else {
if (typeof attrs.fifo !== 'undefined') {
if (attrs.fifo && !queueName.endsWith('.fifo')) {
throw new Error("FIFO queue names must end in '.fifo'");
throw new ValidationError("FIFO queue names must end in '.fifo'", this);
}
if (!attrs.fifo && queueName.endsWith('.fifo')) {
throw new Error("Non-FIFO queue name may not end in '.fifo'");
throw new ValidationError("Non-FIFO queue name may not end in '.fifo'", this);
}
}
return queueName.endsWith('.fifo') ? true : false;
Expand Down Expand Up @@ -383,19 +384,19 @@ export class Queue extends QueueBase {
physicalName: props.queueName,
});

validateProps(props);
validateProps(this, props);

if (props.redriveAllowPolicy) {
const { redrivePermission, sourceQueues } = props.redriveAllowPolicy;
if (redrivePermission === RedrivePermission.BY_QUEUE) {
if (!sourceQueues || sourceQueues.length === 0) {
throw new Error('At least one source queue must be specified when RedrivePermission is set to \'byQueue\'');
throw new ValidationError('At least one source queue must be specified when RedrivePermission is set to \'byQueue\'', this);
}
if (sourceQueues && sourceQueues.length > 10) {
throw new Error('Up to 10 sourceQueues can be specified. Set RedrivePermission to \'allowAll\' to specify more');
throw new ValidationError('Up to 10 sourceQueues can be specified. Set RedrivePermission to \'allowAll\' to specify more', this);
}
} else if (redrivePermission && sourceQueues) {
throw new Error('sourceQueues cannot be configured when RedrivePermission is set to \'allowAll\' or \'denyAll\'');
throw new ValidationError('sourceQueues cannot be configured when RedrivePermission is set to \'allowAll\' or \'denyAll\'', this);
}
}

Expand Down Expand Up @@ -452,7 +453,7 @@ export class Queue extends QueueBase {
let encryption = props.encryption;

if (encryption === QueueEncryption.SQS_MANAGED && props.encryptionMasterKey) {
throw new Error("'encryptionMasterKey' is not supported if encryption type 'SQS_MANAGED' is used");
throw new ValidationError("'encryptionMasterKey' is not supported if encryption type 'SQS_MANAGED' is used", this);
}

if (encryption !== QueueEncryption.KMS && props.encryptionMasterKey) {
Expand Down Expand Up @@ -513,7 +514,7 @@ export class Queue extends QueueBase {
};
}

throw new Error(`Unexpected 'encryptionType': ${encryption}`);
throw new ValidationError(`Unexpected 'encryptionType': ${encryption}`, this);
}

// Enforce encryption of data in transit
Expand All @@ -537,23 +538,23 @@ export class Queue extends QueueBase {
// If we have a name, see that it agrees with the FIFO setting
if (typeof queueName === 'string') {
if (fifoQueue && !queueName.endsWith('.fifo')) {
throw new Error("FIFO queue names must end in '.fifo'");
throw new ValidationError("FIFO queue names must end in '.fifo'", this);
}
if (!fifoQueue && queueName.endsWith('.fifo')) {
throw new Error("Non-FIFO queue name may not end in '.fifo'");
throw new ValidationError("Non-FIFO queue name may not end in '.fifo'", this);
}
}

if (props.contentBasedDeduplication && !fifoQueue) {
throw new Error('Content-based deduplication can only be defined for FIFO queues');
throw new ValidationError('Content-based deduplication can only be defined for FIFO queues', this);
}

if (props.deduplicationScope && !fifoQueue) {
throw new Error('Deduplication scope can only be defined for FIFO queues');
throw new ValidationError('Deduplication scope can only be defined for FIFO queues', this);
}

if (props.fifoThroughputLimit && !fifoQueue) {
throw new Error('FIFO throughput limit can only be defined for FIFO queues');
throw new ValidationError('FIFO throughput limit can only be defined for FIFO queues', this);
}

return {
Expand Down
22 changes: 12 additions & 10 deletions packages/aws-cdk-lib/aws-sqs/lib/validate-props.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import { Construct } from 'constructs';
import { QueueProps } from './index';
import { Token } from '../../core';
import { ValidationError } from '../../core/lib/errors';

export function validateProps(props: QueueProps) {
validateRange('delivery delay', props.deliveryDelay && props.deliveryDelay.toSeconds(), 0, 900, 'seconds');
validateRange('maximum message size', props.maxMessageSizeBytes, 1_024, 262_144, 'bytes');
validateRange('message retention period', props.retentionPeriod && props.retentionPeriod.toSeconds(), 60, 1_209_600, 'seconds');
validateRange('receive wait time', props.receiveMessageWaitTime && props.receiveMessageWaitTime.toSeconds(), 0, 20, 'seconds');
validateRange('visibility timeout', props.visibilityTimeout && props.visibilityTimeout.toSeconds(), 0, 43_200, 'seconds');
validateRange('dead letter target maximum receive count', props.deadLetterQueue && props.deadLetterQueue.maxReceiveCount, 1, +Infinity);
export function validateProps(scope: Construct, props: QueueProps) {
validateRange(scope, 'delivery delay', props.deliveryDelay && props.deliveryDelay.toSeconds(), 0, 900, 'seconds');
validateRange(scope, 'maximum message size', props.maxMessageSizeBytes, 1_024, 262_144, 'bytes');
validateRange(scope, 'message retention period', props.retentionPeriod && props.retentionPeriod.toSeconds(), 60, 1_209_600, 'seconds');
validateRange(scope, 'receive wait time', props.receiveMessageWaitTime && props.receiveMessageWaitTime.toSeconds(), 0, 20, 'seconds');
validateRange(scope, 'visibility timeout', props.visibilityTimeout && props.visibilityTimeout.toSeconds(), 0, 43_200, 'seconds');
validateRange(scope, 'dead letter target maximum receive count', props.deadLetterQueue && props.deadLetterQueue.maxReceiveCount, 1, +Infinity);
}

function validateRange(label: string, value: number | undefined, minValue: number, maxValue: number, unit?: string) {
function validateRange(scope: Construct, label: string, value: number | undefined, minValue: number, maxValue: number, unit?: string) {
if (value === undefined || Token.isUnresolved(value)) { return; }
const unitSuffix = unit ? ` ${unit}` : '';
if (value < minValue) { throw new Error(`${label} must be ${minValue}${unitSuffix} or more, but ${value} was provided`); }
if (value > maxValue) { throw new Error(`${label} must be ${maxValue}${unitSuffix} or less, but ${value} was provided`); }
if (value < minValue) { throw new ValidationError(`${label} must be ${minValue}${unitSuffix} or more, but ${value} was provided`, scope); }
if (value > maxValue) { throw new ValidationError(`${label} must be ${maxValue}${unitSuffix} or less, but ${value} was provided`, scope); }
}
Loading

0 comments on commit dbfdcd4

Please # to comment.