From 2d623d08d8d5d8c356d871ccd69a8cdac9c4170e Mon Sep 17 00:00:00 2001 From: Neta Nir Date: Mon, 29 Mar 2021 16:26:20 -0700 Subject: [PATCH 1/4] =?UTF-8?q?feat(autoscaling-common):=20graduate=20to?= =?UTF-8?q?=20stable=20=F0=9F=9A=80=20=20(#13862)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ---- *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-autoscaling-common/README.md | 8 +------- packages/@aws-cdk/aws-autoscaling-common/package.json | 4 ++-- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/packages/@aws-cdk/aws-autoscaling-common/README.md b/packages/@aws-cdk/aws-autoscaling-common/README.md index 83b483af43573..fdea0531620e1 100644 --- a/packages/@aws-cdk/aws-autoscaling-common/README.md +++ b/packages/@aws-cdk/aws-autoscaling-common/README.md @@ -3,13 +3,7 @@ --- -![cdk-constructs: Experimental](https://img.shields.io/badge/cdk--constructs-experimental-important.svg?style=for-the-badge) - -> The APIs of higher level constructs in this module are experimental and under active development. -> They are subject to non-backward compatible changes or removal in any future version. These are -> not subject to the [Semantic Versioning](https://semver.org/) model and breaking changes will be -> announced in the release notes. This means that while you may use them, you may need to update -> your source code when upgrading to a newer version of this package. +![cdk-constructs: Stable](https://img.shields.io/badge/cdk--constructs-stable-success.svg?style=for-the-badge) --- diff --git a/packages/@aws-cdk/aws-autoscaling-common/package.json b/packages/@aws-cdk/aws-autoscaling-common/package.json index ffc31b5241a02..6378bdc86c35d 100644 --- a/packages/@aws-cdk/aws-autoscaling-common/package.json +++ b/packages/@aws-cdk/aws-autoscaling-common/package.json @@ -105,8 +105,8 @@ "engines": { "node": ">= 10.13.0 <13 || >=13.7.0" }, - "stability": "experimental", - "maturity": "experimental", + "stability": "stable", + "maturity": "stable", "awscdkio": { "announce": false }, From 294f54692c609eaf20257caba0b53ceb9882ff35 Mon Sep 17 00:00:00 2001 From: Neta Nir Date: Mon, 29 Mar 2021 17:01:02 -0700 Subject: [PATCH 2/4] =?UTF-8?q?feat(cloudformation-diff):=20graduate=20to?= =?UTF-8?q?=20stable=20=F0=9F=9A=80=20=20(#13857)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/@aws-cdk/cloudformation-diff/README.md | 8 +------- packages/@aws-cdk/cloudformation-diff/package.json | 4 ++-- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/packages/@aws-cdk/cloudformation-diff/README.md b/packages/@aws-cdk/cloudformation-diff/README.md index 678bc2c9ba0d2..cc8a457769e9e 100644 --- a/packages/@aws-cdk/cloudformation-diff/README.md +++ b/packages/@aws-cdk/cloudformation-diff/README.md @@ -3,13 +3,7 @@ --- -![cdk-constructs: Experimental](https://img.shields.io/badge/cdk--constructs-experimental-important.svg?style=for-the-badge) - -> The APIs of higher level constructs in this module are experimental and under active development. -> They are subject to non-backward compatible changes or removal in any future version. These are -> not subject to the [Semantic Versioning](https://semver.org/) model and breaking changes will be -> announced in the release notes. This means that while you may use them, you may need to update -> your source code when upgrading to a newer version of this package. +![cdk-constructs: Stable](https://img.shields.io/badge/cdk--constructs-stable-success.svg?style=for-the-badge) --- diff --git a/packages/@aws-cdk/cloudformation-diff/package.json b/packages/@aws-cdk/cloudformation-diff/package.json index f9b2c7342a84e..d781b061ff175 100644 --- a/packages/@aws-cdk/cloudformation-diff/package.json +++ b/packages/@aws-cdk/cloudformation-diff/package.json @@ -51,8 +51,8 @@ "engines": { "node": ">= 10.13.0 <13 || >=13.7.0" }, - "stability": "experimental", - "maturity": "experimental", + "stability": "stable", + "maturity": "stable", "cdk-build": { "jest": true }, From fb6512314db1b11fc608cd62753090684ad0d3c4 Mon Sep 17 00:00:00 2001 From: Adam Ruka Date: Mon, 29 Mar 2021 23:26:41 -0700 Subject: [PATCH 3/4] fix(codebuild): take the account & region of an imported Project from its ARN (#13708) This is needed to correctly use CodeBuild in CodePipeline (which needs to know whether the Project is from a different account/region). Fixes #13694 ---- *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-codebuild/lib/project.ts | 9 +++++++-- .../@aws-cdk/aws-codebuild/test/test.project.ts | 15 +++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/packages/@aws-cdk/aws-codebuild/lib/project.ts b/packages/@aws-cdk/aws-codebuild/lib/project.ts index 4b03ed8756f9f..abca536a2c354 100644 --- a/packages/@aws-cdk/aws-codebuild/lib/project.ts +++ b/packages/@aws-cdk/aws-codebuild/lib/project.ts @@ -639,14 +639,19 @@ export interface BindToCodePipelineOptions { export class Project extends ProjectBase { public static fromProjectArn(scope: Construct, id: string, projectArn: string): IProject { + const parsedArn = Stack.of(scope).parseArn(projectArn); + class Import extends ProjectBase { public readonly grantPrincipal: iam.IPrincipal; public readonly projectArn = projectArn; - public readonly projectName = Stack.of(scope).parseArn(projectArn).resourceName!; + public readonly projectName = parsedArn.resourceName!; public readonly role?: iam.Role = undefined; constructor(s: Construct, i: string) { - super(s, i); + super(s, i, { + account: parsedArn.account, + region: parsedArn.region, + }); this.grantPrincipal = new iam.UnknownPrincipal({ resource: this }); } } diff --git a/packages/@aws-cdk/aws-codebuild/test/test.project.ts b/packages/@aws-cdk/aws-codebuild/test/test.project.ts index 80c6940bd79bd..d1c6ad1e85b13 100644 --- a/packages/@aws-cdk/aws-codebuild/test/test.project.ts +++ b/packages/@aws-cdk/aws-codebuild/test/test.project.ts @@ -1386,6 +1386,7 @@ export = { test.done(); }, + 'can override build timeout'(test: Test) { // GIVEN const stack = new cdk.Stack(); @@ -1407,4 +1408,18 @@ export = { test.done(); }, }, + + 'can be imported': { + 'by ARN'(test: Test) { + const stack = new cdk.Stack(); + const project = codebuild.Project.fromProjectArn(stack, 'Project', + 'arn:aws:codebuild:us-west-2:123456789012:project/My-Project'); + + test.equal(project.projectName, 'My-Project'); + test.equal(project.env.account, '123456789012'); + test.equal(project.env.region, 'us-west-2'); + + test.done(); + }, + }, }; From ffea818f26a383e7f314dac3505c46f3b4b4348d Mon Sep 17 00:00:00 2001 From: Adam Ruka Date: Tue, 30 Mar 2021 00:58:27 -0700 Subject: [PATCH 4/4] fix(yaml-cfn): do not deserialize year-month-date as strings (#13745) Currently, we are using the `yaml-1.1` schema when de-serializing YAML documents, Unfortunately, this has the side effect of treating unquoted parts of the template like '2010-09-09' as Date objects, instead of just simple strings. This has been noted by a customer using the cloudformation-include module, but I assume a very similar problem exists for other places we parse YAML, like cloudformation-diff. Switch to the `core` schema from `yaml-1.1`, where those are treated as strings, instead of dates. Fixes #13709 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .../yaml/year-month-date-as-strings.yaml | 14 ++++++++ .../test/yaml-templates.test.ts | 27 +++++++++++++++ packages/@aws-cdk/yaml-cfn/lib/yaml.ts | 2 +- .../yaml-cfn/test/deserialization.test.ts | 34 +++++++++++++++++++ .../yaml-cfn/test/serialization.test.ts | 8 +++++ packages/@aws-cdk/yaml-cfn/test/yaml.test.ts | 5 --- 6 files changed, 84 insertions(+), 6 deletions(-) create mode 100644 packages/@aws-cdk/cloudformation-include/test/test-templates/yaml/year-month-date-as-strings.yaml create mode 100644 packages/@aws-cdk/yaml-cfn/test/deserialization.test.ts create mode 100644 packages/@aws-cdk/yaml-cfn/test/serialization.test.ts delete mode 100644 packages/@aws-cdk/yaml-cfn/test/yaml.test.ts diff --git a/packages/@aws-cdk/cloudformation-include/test/test-templates/yaml/year-month-date-as-strings.yaml b/packages/@aws-cdk/cloudformation-include/test/test-templates/yaml/year-month-date-as-strings.yaml new file mode 100644 index 0000000000000..f25f363879810 --- /dev/null +++ b/packages/@aws-cdk/cloudformation-include/test/test-templates/yaml/year-month-date-as-strings.yaml @@ -0,0 +1,14 @@ +AWSTemplateFormatVersion: 2010-09-09 +Resources: + Role: + Type: AWS::IAM::Role + Properties: + AssumeRolePolicyDocument: + Version: 2012-10-17 + Statement: + - Effect: Allow + Principal: + Service: + - ec2.amazonaws.com + Action: + - sts:AssumeRole diff --git a/packages/@aws-cdk/cloudformation-include/test/yaml-templates.test.ts b/packages/@aws-cdk/cloudformation-include/test/yaml-templates.test.ts index 5faf8bd1a5e1c..0724020f90f56 100644 --- a/packages/@aws-cdk/cloudformation-include/test/yaml-templates.test.ts +++ b/packages/@aws-cdk/cloudformation-include/test/yaml-templates.test.ts @@ -23,6 +23,33 @@ describe('CDK Include', () => { ); }); + test('can ingest a template with year-month-date parsed as string instead of Date', () => { + includeTestTemplate(stack, 'year-month-date-as-strings.yaml'); + + expect(stack).toMatchTemplate({ + "AWSTemplateFormatVersion": "2010-09-09", + "Resources": { + "Role": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Effect": "Allow", + "Principal": { + "Service": ["ec2.amazonaws.com"], + }, + "Action": ["sts:AssumeRole"], + }, + ], + }, + }, + }, + }, + }); + }); + test('can ingest a template with the short form Base64 function', () => { includeTestTemplate(stack, 'short-form-base64.yaml'); diff --git a/packages/@aws-cdk/yaml-cfn/lib/yaml.ts b/packages/@aws-cdk/yaml-cfn/lib/yaml.ts index eca37db0ed048..e46c8f8d6bf72 100644 --- a/packages/@aws-cdk/yaml-cfn/lib/yaml.ts +++ b/packages/@aws-cdk/yaml-cfn/lib/yaml.ts @@ -54,6 +54,6 @@ const shortForms: yaml_types.Schema.CustomTag[] = [ function parseYamlStrWithCfnTags(text: string): any { return yaml.parse(text, { customTags: shortForms, - schema: 'yaml-1.1', + schema: 'core', }); } diff --git a/packages/@aws-cdk/yaml-cfn/test/deserialization.test.ts b/packages/@aws-cdk/yaml-cfn/test/deserialization.test.ts new file mode 100644 index 0000000000000..e2a3688393b61 --- /dev/null +++ b/packages/@aws-cdk/yaml-cfn/test/deserialization.test.ts @@ -0,0 +1,34 @@ +import '@aws-cdk/assert/jest'; +import * as yaml_cfn from '../lib'; + +test('Unquoted year-month-day is treated as a string, not a Date', () => { + const value = yaml_cfn.deserialize('Key: 2020-12-31'); + + expect(value).toEqual({ + Key: '2020-12-31', + }); +}); + +test("Unquoted 'No' is treated as a string, not a boolean", () => { + const value = yaml_cfn.deserialize('Key: No'); + + expect(value).toEqual({ + Key: 'No', + }); +}); + +test("Short-form 'Ref' is deserialized correctly", () => { + const value = yaml_cfn.deserialize('!Ref Resource'); + + expect(value).toEqual({ + Ref: 'Resource', + }); +}); + +test("Short-form 'Fn::GetAtt' is deserialized correctly", () => { + const value = yaml_cfn.deserialize('!GetAtt Resource.Attribute'); + + expect(value).toEqual({ + 'Fn::GetAtt': 'Resource.Attribute', + }); +}); diff --git a/packages/@aws-cdk/yaml-cfn/test/serialization.test.ts b/packages/@aws-cdk/yaml-cfn/test/serialization.test.ts new file mode 100644 index 0000000000000..bbc3a45d6ac26 --- /dev/null +++ b/packages/@aws-cdk/yaml-cfn/test/serialization.test.ts @@ -0,0 +1,8 @@ +import '@aws-cdk/assert/jest'; +import * as yaml_cfn from '../lib'; + +test('An object with a single string value is serialized as a simple string', () => { + const value = yaml_cfn.serialize({ key: 'some string' }); + + expect(value).toEqual('key: some string\n'); +}); diff --git a/packages/@aws-cdk/yaml-cfn/test/yaml.test.ts b/packages/@aws-cdk/yaml-cfn/test/yaml.test.ts deleted file mode 100644 index f8ce8131c4de7..0000000000000 --- a/packages/@aws-cdk/yaml-cfn/test/yaml.test.ts +++ /dev/null @@ -1,5 +0,0 @@ -import '@aws-cdk/assert/jest'; - -test('No tests are specified for this package', () => { - expect(true).toBe(true); -});