Skip to content

Commit

Permalink
Merge branch 'master' into peterwoodworth/lambdapythonFix
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Dec 23, 2021
2 parents 4c2d9e9 + aa7c160 commit 8204d6b
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
/**
Expand Down
22 changes: 18 additions & 4 deletions packages/@aws-cdk/core/lib/custom-resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
1 change: 1 addition & 0 deletions packages/aws-cdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 20 additions & 3 deletions scripts/bump.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
Expand All @@ -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...
Expand Down

0 comments on commit 8204d6b

Please sign in to comment.