From eca1e748913979646e59f4d740cf26e1c0e0f9ef Mon Sep 17 00:00:00 2001 From: Kaizen Conroy <36202692+kaizen3031593@users.noreply.github.com> Date: Wed, 22 Dec 2021 18:42:33 -0500 Subject: [PATCH 1/4] chore(cli): add watch to readme table of contents (#18142) Not the most interesting thing in the world, but I was surprised to not find `cdk watch` in the readme table of contents for the cdk cli. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/aws-cdk/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/aws-cdk/README.md b/packages/aws-cdk/README.md index ac399df3008df..faa5a0a121fe0 100644 --- a/packages/aws-cdk/README.md +++ b/packages/aws-cdk/README.md @@ -19,6 +19,7 @@ Command | Description [`cdk synth`](#cdk-synthesize) | Synthesize a CDK app to CloudFormation template(s) [`cdk diff`](#cdk-diff) | Diff stacks against current state [`cdk deploy`](#cdk-deploy) | Deploy a stack into an AWS account +[`cdk watch`](#cdk-watch) | Watches a CDK app for deployable and hotswappable changes [`cdk destroy`](#cdk-destroy) | Deletes a stack from an AWS account [`cdk bootstrap`](#cdk-bootstrap) | Deploy a toolkit stack to support deploying large stacks & artifacts [`cdk doctor`](#cdk-doctor) | Inspect the environment and produce information useful for troubleshooting From d15fc500dccca34273db79ade1d38a4356a35363 Mon Sep 17 00:00:00 2001 From: Rico Huijbers Date: Wed, 22 Dec 2021 16:25:53 +0100 Subject: [PATCH 2/4] chore(pipelines): move example to function scope (#18132) The example as declared in this doc block was part of the parameter, not of the function. Change to an `@example` declaration to associate the example with the right scope. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* (cherry picked from commit 1c111fcd4ad0a8650db570bde3f5bbc3f58251bc) --- .../lib/codepipeline/codepipeline-source.ts | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/packages/@aws-cdk/pipelines/lib/codepipeline/codepipeline-source.ts b/packages/@aws-cdk/pipelines/lib/codepipeline/codepipeline-source.ts index 382bed08028ff..dd40d0d6cf0e7 100644 --- a/packages/@aws-cdk/pipelines/lib/codepipeline/codepipeline-source.ts +++ b/packages/@aws-cdk/pipelines/lib/codepipeline/codepipeline-source.ts @@ -11,7 +11,7 @@ import { FileSet, Step } from '../blueprint'; import { CodePipelineActionFactoryResult, ProduceActionOptions, ICodePipelineActionFactory } from './codepipeline-action-factory'; /** - * CodePipeline source steps + * Factory for CodePipeline source steps * * This class contains a number of factory methods for the different types * of sources that CodePipeline supports. @@ -48,14 +48,9 @@ export abstract class CodePipelineSource extends Step implements ICodePipelineAc * @param props The options, which include the key that identifies the source code file and * and how the pipeline should be triggered. * - * Example: - * - * ```ts + * @example * declare const bucket: s3.Bucket; - * pipelines.CodePipelineSource.s3(bucket, { - * key: 'path/to/file.zip', - * }); - * ``` + * pipelines.CodePipelineSource.s3(bucket, 'path/to/file.zip'); */ public static s3(bucket: IBucket, objectKey: string, props: S3SourceOptions = {}): CodePipelineSource { return new S3Source(bucket, objectKey, props); @@ -96,12 +91,9 @@ export abstract class CodePipelineSource extends Step implements ICodePipelineAc * @param branch The branch to use. * @param props The source properties. * - * Example: - * - * ```ts - * const repository: IRepository = ... - * CodePipelineSource.codeCommit(repository, 'main'); - * ``` + * @example + * declare const repository: codecommit.IRepository; + * pipelines.CodePipelineSource.codeCommit(repository, 'main'); */ public static codeCommit(repository: codecommit.IRepository, branch: string, props: CodeCommitSourceOptions = {}): CodePipelineSource { return new CodeCommitSource(repository, branch, props); @@ -362,4 +354,4 @@ class CodeCommitSource extends CodePipelineSource { codeBuildCloneOutput: this.props.codeBuildCloneOutput, }); } -} \ No newline at end of file +} From fa5b2bb45444d7bb6bd79393314dc7be96abea88 Mon Sep 17 00:00:00 2001 From: Rico Huijbers Date: Thu, 23 Dec 2021 13:15:28 +0100 Subject: [PATCH 3/4] chore: don't bump empty releases (#18151) v2.3.0 was an empty release compared to v2.2.0, because the forward merge had been failing. It's pointless to release an empty release, so have the bump script check for this situation, and not do anything. Slightly complicated from the obvious logic which would only check commit history: in practice the merge-back commit gets added on top. So we check the actual file changes since the previous release. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- scripts/bump.js | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/scripts/bump.js b/scripts/bump.js index 3daca6711605f..943edd6da5d8b 100755 --- a/scripts/bump.js +++ b/scripts/bump.js @@ -4,7 +4,7 @@ const fs = require('fs'); const path = require('path'); const semver = require('semver'); const ver = require('./resolve-version'); -const { exec } = require('child_process'); +const { execSync } = require('child_process'); async function main() { const releaseAs = process.argv[2] || 'minor'; @@ -39,6 +39,23 @@ async function main() { // published. opts.prerelease = ver.prerelease || 'rc'; console.error(`BUMP_CANDIDATE is set, so bumping version for testing (with the "${opts.prerelease}" prerelease tag)`); + } else { + // We're not running the bump in a regular pipeline, we're running it "for real" to do an actual release. + // + // In that case -- check if there have been changes since the last release. If not, there's no point in + // doing the release at all. Our customers won't appreciate a new version with 0 changes. + const prevVersion = ver.version; + const topLevelFileChanges = execSync(`git diff-tree --name-only v${prevVersion} HEAD`, { encoding: 'utf-8' }).split('\n').filter(x => x); + + // We only release if there have been changes to files other than metadata files + // (for an empty release, the difference since the previous release is updates to json files and the changelog, through + // mergeback) + const anyInteresting = topLevelFileChanges.some(name => !name.includes('CHANGELOG') && !name.startsWith('version.')); + + if (!anyInteresting) { + console.error(`No changes detected since last release -- we're done here.`); + return; + } } const majorVersion = semver.major(ver.version); @@ -52,14 +69,14 @@ async function main() { // and creates really muddled changelogs with both v1 and v2 releases intermingled, and lots of missing data. // A super HACK here is to locally remove all version tags that don't match this major version prior // to doing the bump, and then later fetching to restore those tags. - await exec(`git tag -d $(git tag -l | grep -v '^v${majorVersion}.')`); + execSync(`git tag -d $(git tag -l | grep -v '^v${majorVersion}.')`); // Delay loading standard-version until the git tags have been pruned. const standardVersion = require('standard-version'); await standardVersion(opts); // fetch back the tags, and only the tags, removed locally above - await exec('git fetch origin "refs/tags/*:refs/tags/*"'); + execSync('git fetch origin "refs/tags/*:refs/tags/*"'); } else { // this is incredible, but passing this option to standard-version actually makes it crash! // good thing we're getting rid of it... From aa7c16012436cdeb9cfb4e39349fe88d4241602f Mon Sep 17 00:00:00 2001 From: Rico Huijbers Date: Thu, 23 Dec 2021 17:29:03 +0100 Subject: [PATCH 4/4] docs(core): update CustomResource documentation (#18156) Make the use and implications of CustomResources in the `core` library a bit more clear. Strongly direct users to the `custom-resources` module. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .../custom-resource-provider.ts | 20 ++++++++++++++++- packages/@aws-cdk/core/lib/custom-resource.ts | 22 +++++++++++++++---- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/packages/@aws-cdk/core/lib/custom-resource-provider/custom-resource-provider.ts b/packages/@aws-cdk/core/lib/custom-resource-provider/custom-resource-provider.ts index 013c1f49b8ab8..c4423051ac6ca 100644 --- a/packages/@aws-cdk/core/lib/custom-resource-provider/custom-resource-provider.ts +++ b/packages/@aws-cdk/core/lib/custom-resource-provider/custom-resource-provider.ts @@ -111,8 +111,26 @@ export enum CustomResourceProviderRuntime { } /** - * An AWS-Lambda backed custom resource provider. + * An AWS-Lambda backed custom resource provider, for CDK Construct Library constructs * + * This is a provider for `CustomResource` constructs, backed by an AWS Lambda + * Function. It only supports NodeJS runtimes. + * + * **This is not a generic custom resource provider class**. It is specifically + * intended to be used only by constructs in the AWS CDK Construct Library, and + * only exists here because of reverse dependency issues (for example, it cannot + * use `iam.PolicyStatement` objects, since the `iam` library already depends on + * the CDK `core` library and we cannot have cyclic dependencies). + * + * If you are not writing constructs for the AWS Construct Library, you should + * use the `Provider` class in the `custom-resources` module instead, which has + * a better API and supports all Lambda runtimes, not just Node. + * + * N.B.: When you are writing Custom Resource Providers, there are a number of + * lifecycle events you have to pay attention to. These are documented in the + * README of the `custom-resources` module. Be sure to give the documentation + * in that module a read, regardless of whether you end up using the Provider + * class in there or this one. */ export class CustomResourceProvider extends CoreConstruct { /** diff --git a/packages/@aws-cdk/core/lib/custom-resource.ts b/packages/@aws-cdk/core/lib/custom-resource.ts index 261f442f1a951..a466b600fa386 100644 --- a/packages/@aws-cdk/core/lib/custom-resource.ts +++ b/packages/@aws-cdk/core/lib/custom-resource.ts @@ -98,11 +98,25 @@ export interface CustomResourceProps { } /** - * Custom resource that is implemented using a Lambda + * Instantiation of a custom resource, whose implementation is provided a Provider * - * As a custom resource author, you should be publishing a subclass of this class - * that hides the choice of provider, and accepts a strongly-typed properties - * object with the properties your provider accepts. + * This class is intended to be used by construct library authors. Application + * builder should not be able to tell whether or not a construct is backed by + * a custom resource, and so the use of this class should be invisible. + * + * Instead, construct library authors declare a custom construct that hides the + * choice of provider, and accepts a strongly-typed properties object with the + * properties your provider accepts. + * + * Your custom resource provider (identified by the `serviceToken` property) + * can be one of 4 constructs: + * + * - If you are authoring a construct library or application, we recommend you + * use the `Provider` class in the `custom-resources` module. + * - If you are authoring a construct for the CDK's AWS Construct Library, + * you should use the `CustomResourceProvider` construct in this package. + * - If you want full control over the provider, you can always directly use + * a Lambda Function or SNS Topic by passing the ARN into `serviceToken`. * * @resource AWS::CloudFormation::CustomResource */