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 */ 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 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...