From 430b81dda604845418ac69ddf3dbfe819c43eca8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Aug 2022 10:52:15 +0000 Subject: [PATCH 1/3] chore(deps): Bump awscli from 1.25.46 to 1.25.51 in /packages/@aws-cdk/lambda-layer-awscli (#21601) Bumps [awscli](https://github.com/aws/aws-cli) from 1.25.46 to 1.25.51.
Changelog

Sourced from awscli's changelog.

1.25.51

1.25.50

1.25.49

1.25.48

1.25.47

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=awscli&package-manager=pip&previous-version=1.25.46&new-version=1.25.51)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- packages/@aws-cdk/lambda-layer-awscli/layer/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@aws-cdk/lambda-layer-awscli/layer/requirements.txt b/packages/@aws-cdk/lambda-layer-awscli/layer/requirements.txt index faa0808b05129..1aed1c536cca2 100644 --- a/packages/@aws-cdk/lambda-layer-awscli/layer/requirements.txt +++ b/packages/@aws-cdk/lambda-layer-awscli/layer/requirements.txt @@ -1 +1 @@ -awscli==1.25.46 +awscli==1.25.51 From f44eb9800ac80b9edde62771377d32a017880701 Mon Sep 17 00:00:00 2001 From: Julian Michel Date: Mon, 15 Aug 2022 14:54:02 +0200 Subject: [PATCH 2/3] fix(route53): misleading error message in `fromLookup` if `domainName` is undefined (#21596) If TypeScript compiler option `strictPropertyInitialization` is set to `false`, it is possible to pass an undefined value to the `fromLookup` method in `HostedZone`. Currently the error message `Cannot read property 'endsWith' of undefined` will be displayed. This error message does not indicate the root cause, so it is difficult to fix the problem. This fix introduces an additional check that shows an appropriate error message. Fixes #10053. ---- ### All Submissions: * [X] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/@aws-cdk/aws-route53/lib/hosted-zone.ts | 4 ++++ .../@aws-cdk/aws-route53/test/hosted-zone.test.ts | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/packages/@aws-cdk/aws-route53/lib/hosted-zone.ts b/packages/@aws-cdk/aws-route53/lib/hosted-zone.ts index c7cd541703c57..c965021665b52 100644 --- a/packages/@aws-cdk/aws-route53/lib/hosted-zone.ts +++ b/packages/@aws-cdk/aws-route53/lib/hosted-zone.ts @@ -112,6 +112,10 @@ export class HostedZone extends Resource implements IHostedZone { * @see https://docs.aws.amazon.com/cdk/latest/guide/environments.html */ public static fromLookup(scope: Construct, id: string, query: HostedZoneProviderProps): IHostedZone { + if (!query.domainName) { + throw new Error('Cannot use undefined value for attribute `domainName`'); + } + const DEFAULT_HOSTED_ZONE: HostedZoneContextResponse = { Id: 'DUMMY', Name: query.domainName, diff --git a/packages/@aws-cdk/aws-route53/test/hosted-zone.test.ts b/packages/@aws-cdk/aws-route53/test/hosted-zone.test.ts index f34d777220418..b659e41446d75 100644 --- a/packages/@aws-cdk/aws-route53/test/hosted-zone.test.ts +++ b/packages/@aws-cdk/aws-route53/test/hosted-zone.test.ts @@ -176,4 +176,19 @@ describe('hosted zone', () => { hz.zoneName; }).toThrow('Cannot reference `zoneName` when using `HostedZone.fromHostedZoneId()`. A construct consuming this hosted zone may be trying to reference its `zoneName`. If this is the case, use `fromHostedZoneAttributes()` or `fromLookup()` instead.'); }); + + test('fromLookup throws error when domainName is undefined', () => { + // GIVEN + let domainName!: string; + const stack = new cdk.Stack(undefined, 'TestStack', { + env: { account: '123456789012', region: 'us-east-1' }, + }); + + // THEN + expect(() => { + HostedZone.fromLookup(stack, 'HostedZone', { + domainName, + }); + }).toThrow(/Cannot use undefined value for attribute `domainName`/); + }); }); From ea11f33c7380ba2d79c122397576782ed13fe00e Mon Sep 17 00:00:00 2001 From: Dan Vicarel Date: Mon, 15 Aug 2022 12:01:34 -0400 Subject: [PATCH 3/3] feat(pipelines): add static PipelineBase.isPipeline method (#21075) This change adds a new `isPipeline` method to `PipelineBase`. This method works the same way as `Stack.isStack` (checking if a specific `Symbol` property is defined on the provided object), and serves the same purpose: to check if a provided object extends `PipelineBase` (e.g., `CodePipeline` would return true, while `Stack` or `s3.Bucket` would return false). ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### ~Adding new Unconventional Dependencies:~ ~* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies)~ ### New Features * [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .../pipelines/lib/main/pipeline-base.ts | 13 +++++++++ .../pipelines/test/main/pipeline-base.test.ts | 29 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 packages/@aws-cdk/pipelines/test/main/pipeline-base.test.ts diff --git a/packages/@aws-cdk/pipelines/lib/main/pipeline-base.ts b/packages/@aws-cdk/pipelines/lib/main/pipeline-base.ts index 34402b0b5cffa..0bb27cb78a7bc 100644 --- a/packages/@aws-cdk/pipelines/lib/main/pipeline-base.ts +++ b/packages/@aws-cdk/pipelines/lib/main/pipeline-base.ts @@ -2,6 +2,8 @@ import { Aspects, Stage } from '@aws-cdk/core'; import { Construct } from 'constructs'; import { AddStageOpts as StageOptions, WaveOptions, Wave, IFileSetProducer, ShellStep, FileSet } from '../blueprint'; +const PIPELINE_SYMBOL = Symbol.for('@aws-cdk/pipelines.PipelineBase'); + /** * Properties for a `Pipeline` */ @@ -32,6 +34,15 @@ export interface PipelineBaseProps { * happens first). */ export abstract class PipelineBase extends Construct { + /** + * Return whether the given object extends {@link PipelineBase}. + * + * We do attribute detection since we can't reliably use 'instanceof'. + */ + public static isPipeline(x: any): x is PipelineBase { + return x !== null && typeof (x) === 'object' && PIPELINE_SYMBOL in x; + } + /** * The build step that produces the CDK Cloud Assembly */ @@ -54,6 +65,8 @@ export abstract class PipelineBase extends Construct { constructor(scope: Construct, id: string, props: PipelineBaseProps) { super(scope, id); + Object.defineProperty(this, PIPELINE_SYMBOL, { value: true }); + if (props.synth instanceof ShellStep && !props.synth.primaryOutput) { props.synth.primaryOutputDirectory('cdk.out'); } diff --git a/packages/@aws-cdk/pipelines/test/main/pipeline-base.test.ts b/packages/@aws-cdk/pipelines/test/main/pipeline-base.test.ts new file mode 100644 index 0000000000000..680f33f7dc602 --- /dev/null +++ b/packages/@aws-cdk/pipelines/test/main/pipeline-base.test.ts @@ -0,0 +1,29 @@ +import * as cdk from '@aws-cdk/core'; +import { Construct } from 'constructs'; +import { App } from '../../../core/lib'; +import { PipelineBase, IFileSetProducer, FileSet } from '../../lib'; +import { PIPELINE_ENV } from '../testhelpers'; + +describe('pipeline base', () => { + + test('PipelineBase.isPipeline indicates that a construct extends PipelineBase', () => { + const app = new App(); + const pipelineStack = new cdk.Stack(app, 'PipelineStack', { env: PIPELINE_ENV }); + const construct = new Construct(pipelineStack, 'Construct'); + const pipeline = new class extends PipelineBase { + constructor() { + super(pipelineStack, 'Pipeline', { + synth: new class implements IFileSetProducer { + public readonly primaryOutput = new FileSet('PrimaryOutput'); + }(), + }); + } + protected doBuildPipeline(): void { } + }(); + + expect(PipelineBase.isPipeline(pipelineStack)).toStrictEqual(false); + expect(PipelineBase.isPipeline(construct)).toStrictEqual(false); + expect(PipelineBase.isPipeline(pipeline)).toStrictEqual(true); + }); + +}); \ No newline at end of file