Skip to content

Commit

Permalink
Merge branch 'main' into bobertzh/legacy-taggables
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Dec 23, 2024
2 parents efa49af + ff21117 commit 26e0fb9
Show file tree
Hide file tree
Showing 38 changed files with 410 additions and 183 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
"fs-extra": "^9.1.0",
"graceful-fs": "^4.2.11",
"jest-junit": "^13.2.0",
"jsii-diff": "1.106.0",
"jsii-pacmak": "1.106.0",
"jsii-reflect": "1.106.0",
"jsii-diff": "1.104.0",
"jsii-pacmak": "1.104.0",
"jsii-reflect": "1.104.0",
"lerna": "^8.1.8",
"nx": "^19.8.6",
"semver": "^7.6.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk-testing/cli-integ/bin/query-github
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env node
require('./query-github.js');
require('../lib/cli/query-github.js');
2 changes: 1 addition & 1 deletion packages/@aws-cdk-testing/cli-integ/bin/run-suite
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env node
require('./run-suite.js');
require('../lib/cli/run-suite.js');
2 changes: 1 addition & 1 deletion packages/@aws-cdk-testing/cli-integ/bin/stage-distribution
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env node
require('./stage-distribution.js');
require('../lib/cli/stage-distribution.js');
2 changes: 1 addition & 1 deletion packages/@aws-cdk-testing/cli-integ/bin/test-root
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env node
require('./test-root.js');
require('../lib/cli/test-root.js');
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as yargs from 'yargs';
import { fetchPreviousVersion } from '../lib/github';
import { fetchPreviousVersion } from '../github';

async function main() {
const args = await yargs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
import * as path from 'path';
import * as jest from 'jest';
import * as yargs from 'yargs';
import { ReleasePackageSourceSetup } from '../lib/package-sources/release-source';
import { RepoPackageSourceSetup, autoFindRoot } from '../lib/package-sources/repo-source';
import { IPackageSourceSetup } from '../lib/package-sources/source';
import { serializeForSubprocess } from '../lib/package-sources/subprocess';
import { ReleasePackageSourceSetup } from '../package-sources/release-source';
import { RepoPackageSourceSetup, autoFindRoot } from '../package-sources/repo-source';
import { IPackageSourceSetup } from '../package-sources/source';
import { serializeForSubprocess } from '../package-sources/subprocess';

async function main() {
const args = await yargs
Expand Down Expand Up @@ -126,7 +126,7 @@ async function main() {
...args.verbose ? ['--verbose'] : [],
...passWithNoTests ? ['--passWithNoTests'] : [],
...args['test-file'] ? [args['test-file']] : [],
], path.resolve(__dirname, '..', 'resources', 'integ.jest.config.js'));
], path.resolve(__dirname, '..', '..', 'resources', 'integ.jest.config.js'));

} finally {
await packageSource.cleanup();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import * as path from 'path';
import * as fs from 'fs-extra';
import * as glob from 'glob';
import * as yargs from 'yargs';
import { shell } from '../lib';
import { TestRepository } from '../lib/staging/codeartifact';
import { uploadJavaPackages, mavenLogin } from '../lib/staging/maven';
import { uploadNpmPackages, npmLogin } from '../lib/staging/npm';
import { uploadDotnetPackages, nugetLogin } from '../lib/staging/nuget';
import { uploadPythonPackages, pypiLogin } from '../lib/staging/pypi';
import { UsageDir } from '../lib/staging/usage-dir';
import { shell } from '..';
import { TestRepository } from '../staging/codeartifact';
import { uploadJavaPackages, mavenLogin } from '../staging/maven';
import { uploadNpmPackages, npmLogin } from '../staging/npm';
import { uploadDotnetPackages, nugetLogin } from '../staging/nuget';
import { uploadPythonPackages, pypiLogin } from '../staging/pypi';
import { UsageDir } from '../staging/usage-dir';

async function main() {
await yargs
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import * as path from 'path';
// eslint-disable-next-line no-console
console.log(path.resolve(__dirname, '..'));
console.log(path.resolve(__dirname, '..', '..'));
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@ const POOL_NAME = 'resource-pool.test';
test('take and dispose', async () => {
const pool = ResourcePool.withResources(POOL_NAME, ['a']);
const take1 = pool.take();
const take2 = pool.take();

let released = false;

const lease1 = await take1;

// We must start the take2 only after take1 has definitely
// succeeded, otherwise we have a race condition if take2 happens to
// win the race (we expect take1 to succeed and take2 to wait).
const take2 = pool.take();

// awaiting 'take2' would now block but we add an async
// handler to it to flip a boolean to see when it gets activated.
void(take2.then(() => released = true));
Expand Down
1 change: 1 addition & 0 deletions packages/@aws-cdk/cli-lib-alpha/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const baseConfig = require('@aws-cdk/cdk-build-tools/config/eslintrc');
baseConfig.parserOptions.project = __dirname + '/tsconfig.json';
baseConfig.ignorePatterns.push('**/*.template.ts');

baseConfig.rules['import/no-extraneous-dependencies'] = ['error', { devDependencies: true, peerDependencies: true } ];
baseConfig.rules['import/order'] = 'off';
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/cli-lib-alpha/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*.js.map
*.d.ts
*.gz
!lib/init-templates/**/javascript/**/*
lib/init-templates/
node_modules
dist
.jsii
Expand Down
12 changes: 12 additions & 0 deletions packages/@aws-cdk/cli-lib-alpha/build-tools/copy-cli-resources.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
set -euo pipefail

aws_cdk="$1"

# Copy all resources that aws_cdk/generate.sh produced, and some othersCall the generator for the
cp $aws_cdk/build-info.json ./
cp -R $aws_cdk/lib/init-templates ./lib/

mkdir -p ./lib/api/bootstrap/ && cp $aws_cdk/lib/api/bootstrap/bootstrap-template.yaml ./lib/api/bootstrap/
cp $aws_cdk/lib/index_bg.wasm ./lib/
cp $aws_cdk/db.json.gz ./
8 changes: 4 additions & 4 deletions packages/@aws-cdk/cli-lib-alpha/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
"main": "lib/main.js",
"types": "lib/index.d.ts",
"jsii": {
"excludeTypescript": [
"**/*.template.ts"
],
"outdir": "dist",
"targets": {
"dotnet": {
Expand Down Expand Up @@ -52,7 +55,7 @@
"build+test+package": "yarn build+test && yarn package",
"bundle": "esbuild --bundle lib/index.ts --target=node18 --platform=node --external:fsevents --minify-whitespace --outfile=lib/main.js",
"compat": "cdk-compat",
"gen": "../../../packages/aws-cdk/generate.sh",
"gen": "build-tools/copy-cli-resources.sh ../../../packages/aws-cdk",
"lint": "cdk-lint",
"package": "cdk-package",
"pkglint": "pkglint -f",
Expand All @@ -63,9 +66,6 @@
"cdk-build": {
"post": [
"yarn attribute",
"mkdir -p ./lib/api/bootstrap/ && cp ../../aws-cdk/lib/api/bootstrap/bootstrap-template.yaml ./lib/api/bootstrap/",
"cp ../../../node_modules/cdk-from-cfn/index_bg.wasm ./lib/",
"cp ../../../node_modules/@aws-cdk/aws-service-spec/db.json.gz ./",
"yarn bundle",
"node ./lib/main.js >/dev/null 2>/dev/null </dev/null"
],
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/cloudformation-diff/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
},
"license": "Apache-2.0",
"dependencies": {
"@aws-cdk/aws-service-spec": "^0.1.39",
"@aws-cdk/service-spec-types": "^0.0.106",
"@aws-cdk/aws-service-spec": "^0.1.40",
"@aws-cdk/service-spec-types": "^0.0.107",
"chalk": "^4",
"diff": "^5.2.0",
"fast-deep-equal": "^3.1.3",
Expand Down
6 changes: 6 additions & 0 deletions packages/@aws-cdk/integ-runner/build-tools/generate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
set -euo pipefail

# Copy the recommended-feature-flags.json file out from aws-cdk-lib.
path=$(node -p 'require.resolve("aws-cdk-lib/recommended-feature-flags.json")')
cp $path lib/recommended-feature-flags.json
14 changes: 12 additions & 2 deletions packages/@aws-cdk/integ-runner/lib/runner/runner-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import * as path from 'path';
import { CdkCliWrapper, ICdk } from '@aws-cdk/cdk-cli-wrapper';
import { TestCase, DefaultCdkOptions } from '@aws-cdk/cloud-assembly-schema';
import { AVAILABILITY_ZONE_FALLBACK_CONTEXT_KEY, TARGET_PARTITIONS, NEW_PROJECT_CONTEXT } from '@aws-cdk/cx-api';
import { AVAILABILITY_ZONE_FALLBACK_CONTEXT_KEY, TARGET_PARTITIONS } from '@aws-cdk/cx-api';
import * as fs from 'fs-extra';
import { IntegTestSuite, LegacyIntegTestSuite } from './integ-test-suite';
import { IntegTest } from './integration-tests';
Expand Down Expand Up @@ -365,7 +365,7 @@ export abstract class IntegRunner {

protected getContext(additionalContext?: Record<string, any>): Record<string, any> {
return {
...NEW_PROJECT_CONTEXT,
...currentlyRecommendedAwsCdkLibFlags(),
...this.legacyContext,
...additionalContext,

Expand Down Expand Up @@ -432,3 +432,13 @@ export const DEFAULT_SYNTH_OPTIONS = {
CDK_INTEG_SUBNET_ID: 'subnet-0dff1a399d8f6f92c',
},
};

/**
* Return the currently recommended flags for `aws-cdk-lib`.
*
* These have been built into the CLI at build time.
*/
export function currentlyRecommendedAwsCdkLibFlags() {
const recommendedFlagsFile = path.join(__dirname, '..', 'recommended-feature-flags.json');
return JSON.parse(fs.readFileSync(recommendedFlagsFile, { encoding: 'utf-8' }));
}
3 changes: 2 additions & 1 deletion packages/@aws-cdk/integ-runner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"integ-runner": "bin/integ-runner"
},
"scripts": {
"gen": "./build-tools/generate.sh",
"build": "cdk-build",
"lint": "cdk-lint",
"package": "cdk-package",
Expand Down Expand Up @@ -74,7 +75,7 @@
"@aws-cdk/cloud-assembly-schema": "^38.0.0",
"@aws-cdk/cloudformation-diff": "0.0.0",
"@aws-cdk/cx-api": "0.0.0",
"@aws-cdk/aws-service-spec": "^0.1.39",
"@aws-cdk/aws-service-spec": "^0.1.40",
"cdk-assets": "3.0.0-rc.32",
"@aws-cdk/cdk-cli-wrapper": "0.0.0",
"aws-cdk": "0.0.0",
Expand Down
9 changes: 8 additions & 1 deletion packages/aws-cdk-lib/cx-api/build-tools/flag-report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ async function main() {
diff: changedFlags(),
migratejson: migrateJson(),
});

// Write to the package root
await updateRecommendedFlagsFile(path.join(__dirname, '..', '..', 'recommended-feature-flags.json'));
}

function flagsTable() {
Expand Down Expand Up @@ -117,7 +120,7 @@ function oldBehavior(flag: FlagInfo): string | undefined {
function recommendedJson() {
return [
'```json',
JSON.stringify({ context: feats.NEW_PROJECT_CONTEXT }, undefined, 2),
JSON.stringify({ context: feats.CURRENTLY_RECOMMENDED_FLAGS }, undefined, 2),
'```',
].join('\n');
}
Expand Down Expand Up @@ -206,6 +209,10 @@ async function updateMarkdownFile(filename: string, sections: Record<string, str
await fs.writeFile(filename, contents, { encoding: 'utf-8' });
}

async function updateRecommendedFlagsFile(filename: string) {
await fs.writeFile(filename, JSON.stringify(feats.CURRENTLY_RECOMMENDED_FLAGS, undefined, 2), { encoding: 'utf-8' });
}

function firstCmp(...xs: number[]) {
return xs.find(x => x !== 0) ?? 0;
}
Expand Down
13 changes: 8 additions & 5 deletions packages/aws-cdk-lib/cx-api/lib/features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1317,10 +1317,13 @@ export const CURRENT_VERSION_EXPIRED_FLAGS: string[] = Object.entries(FLAGS)
* Add a flag in here (typically with the value `true`), to enable
* backwards-breaking behavior changes only for new projects. New projects
* generated through `cdk init` will include these flags in their generated
* project config.
*
* Tests must cover the default (disabled) case and the future (enabled) case.
*
* Going forward, this should *NOT* be consumed directly anymore.
*/
export const NEW_PROJECT_CONTEXT = Object.fromEntries(
export const CURRENTLY_RECOMMENDED_FLAGS = Object.fromEntries(
Object.entries(FLAGS)
.filter(([_, flag]) => flag.recommendedValue !== flag.defaults?.[CURRENT_MV] && flag.introducedIn[CURRENT_MV])
.map(([name, flag]) => [name, flag.recommendedValue]),
Expand Down Expand Up @@ -1352,10 +1355,10 @@ export function futureFlagDefault(flag: string): boolean {
/** @deprecated use CURRENT_VERSION_EXPIRED_FLAGS instead */
export const FUTURE_FLAGS_EXPIRED = CURRENT_VERSION_EXPIRED_FLAGS;

/** @deprecated use NEW_PROJECT_CONTEXT instead */
export const FUTURE_FLAGS = Object.fromEntries(Object.entries(NEW_PROJECT_CONTEXT)
/** @deprecated do not use at all! */
export const FUTURE_FLAGS = Object.fromEntries(Object.entries(CURRENTLY_RECOMMENDED_FLAGS)
.filter(([_, v]) => typeof v === 'boolean'));

/** @deprecated use NEW_PROJECT_CONTEXT instead */
export const NEW_PROJECT_DEFAULT_CONTEXT = Object.fromEntries(Object.entries(NEW_PROJECT_CONTEXT)
/** @deprecated do not use at all! */
export const NEW_PROJECT_DEFAULT_CONTEXT = Object.fromEntries(Object.entries(CURRENTLY_RECOMMENDED_FLAGS)
.filter(([_, v]) => typeof v !== 'boolean'));
2 changes: 1 addition & 1 deletion packages/aws-cdk-lib/cx-api/lib/private/flag-modeling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export interface FlagInfoBase {
/** Version number the flag was introduced in each version line. `undefined` means flag does not exist in that line. */
readonly introducedIn: { v1?: string; v2?: string };
/** Default value, if flag is unset by user. Adding a flag with a default may not change behavior after GA! */
readonly defaults?: { v2?: any };
readonly defaults?: { v1?: any; v2?: any };
/** Default in new projects */
readonly recommendedValue: any;
};
Expand Down
3 changes: 2 additions & 1 deletion packages/aws-cdk-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
"mime-types": "^2.1.35"
},
"devDependencies": {
"@aws-cdk/aws-service-spec": "^0.1.39",
"@aws-cdk/aws-service-spec": "^0.1.40",
"@aws-cdk/cdk-build-tools": "0.0.0",
"@aws-cdk/custom-resource-handlers": "0.0.0",
"@aws-cdk/pkglint": "0.0.0",
Expand Down Expand Up @@ -509,6 +509,7 @@
"./pipelines/.warnings.jsii.js": "./pipelines/.warnings.jsii.js",
"./pipelines/lib/helpers-internal": "./pipelines/lib/helpers-internal/index.js",
"./pipelines/package.json": "./pipelines/package.json",
"./recommended-feature-flags.json": "./recommended-feature-flags.json",
"./region-info": "./region-info/index.js",
"./triggers": "./triggers/index.js"
},
Expand Down
63 changes: 63 additions & 0 deletions packages/aws-cdk-lib/recommended-feature-flags.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"@aws-cdk/aws-lambda:recognizeLayerVersion": true,
"@aws-cdk/core:checkSecretUsage": true,
"@aws-cdk/core:target-partitions": [
"aws",
"aws-cn"
],
"@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
"@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true,
"@aws-cdk/aws-ecs:arnFormatIncludesClusterName": true,
"@aws-cdk/aws-iam:minimizePolicies": true,
"@aws-cdk/core:validateSnapshotRemovalPolicy": true,
"@aws-cdk/aws-codepipeline:crossAccountKeyAliasStackSafeResourceName": true,
"@aws-cdk/aws-s3:createDefaultLoggingPolicy": true,
"@aws-cdk/aws-sns-subscriptions:restrictSqsDescryption": true,
"@aws-cdk/aws-apigateway:disableCloudWatchRole": true,
"@aws-cdk/core:enablePartitionLiterals": true,
"@aws-cdk/aws-events:eventsTargetQueueSameAccount": true,
"@aws-cdk/aws-ecs:disableExplicitDeploymentControllerForCircuitBreaker": true,
"@aws-cdk/aws-iam:importedRoleStackSafeDefaultPolicyName": true,
"@aws-cdk/aws-s3:serverAccessLogsUseBucketPolicy": true,
"@aws-cdk/aws-route53-patters:useCertificate": true,
"@aws-cdk/customresources:installLatestAwsSdkDefault": false,
"@aws-cdk/aws-rds:databaseProxyUniqueResourceName": true,
"@aws-cdk/aws-codedeploy:removeAlarmsFromDeploymentGroup": true,
"@aws-cdk/aws-apigateway:authorizerChangeDeploymentLogicalId": true,
"@aws-cdk/aws-ec2:launchTemplateDefaultUserData": true,
"@aws-cdk/aws-secretsmanager:useAttachedSecretResourcePolicyForSecretTargetAttachments": true,
"@aws-cdk/aws-redshift:columnId": true,
"@aws-cdk/aws-stepfunctions-tasks:enableEmrServicePolicyV2": true,
"@aws-cdk/aws-ec2:restrictDefaultSecurityGroup": true,
"@aws-cdk/aws-apigateway:requestValidatorUniqueId": true,
"@aws-cdk/aws-kms:aliasNameRef": true,
"@aws-cdk/aws-autoscaling:generateLaunchTemplateInsteadOfLaunchConfig": true,
"@aws-cdk/core:includePrefixInUniqueNameGeneration": true,
"@aws-cdk/aws-efs:denyAnonymousAccess": true,
"@aws-cdk/aws-opensearchservice:enableOpensearchMultiAzWithStandby": true,
"@aws-cdk/aws-lambda-nodejs:useLatestRuntimeVersion": true,
"@aws-cdk/aws-efs:mountTargetOrderInsensitiveLogicalId": true,
"@aws-cdk/aws-rds:auroraClusterChangeScopeOfInstanceParameterGroupWithEachParameters": true,
"@aws-cdk/aws-appsync:useArnForSourceApiAssociationIdentifier": true,
"@aws-cdk/aws-rds:preventRenderingDeprecatedCredentials": true,
"@aws-cdk/aws-codepipeline-actions:useNewDefaultBranchForCodeCommitSource": true,
"@aws-cdk/aws-cloudwatch-actions:changeLambdaPermissionLogicalIdForLambdaAction": true,
"@aws-cdk/aws-codepipeline:crossAccountKeysDefaultValueToFalse": true,
"@aws-cdk/aws-codepipeline:defaultPipelineTypeToV2": true,
"@aws-cdk/aws-kms:reduceCrossAccountRegionPolicyScope": true,
"@aws-cdk/aws-eks:nodegroupNameAttribute": true,
"@aws-cdk/aws-ec2:ebsDefaultGp3Volume": true,
"@aws-cdk/aws-ecs:removeDefaultDeploymentAlarm": true,
"@aws-cdk/custom-resources:logApiResponseDataPropertyTrueDefault": false,
"@aws-cdk/aws-s3:keepNotificationInImportedBucket": false,
"@aws-cdk/aws-ecs:reduceEc2FargateCloudWatchPermissions": true,
"@aws-cdk/aws-dynamodb:resourcePolicyPerReplica": true,
"@aws-cdk/aws-ec2:ec2SumTImeoutEnabled": true,
"@aws-cdk/aws-appsync:appSyncGraphQLAPIScopeLambdaPermission": true,
"@aws-cdk/aws-rds:setCorrectValueForDatabaseInstanceReadReplicaInstanceResourceId": true,
"@aws-cdk/core:cfnIncludeRejectComplexResourceUpdateCreatePolicyIntrinsics": true,
"@aws-cdk/aws-lambda-nodejs:sdkV3ExcludeSmithyPackages": true,
"@aws-cdk/aws-stepfunctions-tasks:fixRunEcsTaskPolicy": true,
"@aws-cdk/aws-ec2:bastionHostUseAmazonLinux2023ByDefault": true,
"@aws-cdk/aws-route53-targets:userPoolDomainNameMethodWithoutCustomResource": true
}
2 changes: 2 additions & 0 deletions packages/aws-cdk/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
!lib/init-templates/**/javascript/**/*
lib/init-templates/**/*.hook.js
lib/init-templates/**/*.hook.d.ts
lib/init-templates/.*.json
node_modules
dist

Expand Down Expand Up @@ -40,5 +41,6 @@ test/integ/cli/*.d.ts

junit.xml


lib/**/*.wasm
db.json.gz
Loading

0 comments on commit 26e0fb9

Please sign in to comment.