From cf6118977f61e988c9609c5444e822bf9fbc063d Mon Sep 17 00:00:00 2001 From: Sam Goodwin Date: Thu, 21 Mar 2019 12:47:16 -0700 Subject: [PATCH 1/5] Rename serverless to sam --- .../@aws-cdk/{aws-serverless => aws-sam}/.gitignore | 0 .../@aws-cdk/{aws-serverless => aws-sam}/.npmignore | 0 .../@aws-cdk/{aws-serverless => aws-sam}/LICENSE | 0 packages/@aws-cdk/{aws-serverless => aws-sam}/NOTICE | 0 packages/@aws-cdk/aws-sam/README.md | 5 +++++ .../{aws-serverless => aws-sam}/lib/index.ts | 2 +- .../{aws-serverless => aws-sam}/package.json | 12 ++++++------ .../test.serverless.ts => aws-sam/test/test.sam.ts} | 0 packages/@aws-cdk/aws-serverless/README.md | 5 ----- packages/decdk/package.json | 2 +- tools/awslint/lib/rules/module.ts | 12 +++++++++++- tools/cfn2ts/lib/genspec.ts | 12 +++++++++++- 12 files changed, 35 insertions(+), 15 deletions(-) rename packages/@aws-cdk/{aws-serverless => aws-sam}/.gitignore (100%) rename packages/@aws-cdk/{aws-serverless => aws-sam}/.npmignore (100%) rename packages/@aws-cdk/{aws-serverless => aws-sam}/LICENSE (100%) rename packages/@aws-cdk/{aws-serverless => aws-sam}/NOTICE (100%) create mode 100644 packages/@aws-cdk/aws-sam/README.md rename packages/@aws-cdk/{aws-serverless => aws-sam}/lib/index.ts (52%) rename packages/@aws-cdk/{aws-serverless => aws-sam}/package.json (84%) rename packages/@aws-cdk/{aws-serverless/test/test.serverless.ts => aws-sam/test/test.sam.ts} (100%) delete mode 100644 packages/@aws-cdk/aws-serverless/README.md diff --git a/packages/@aws-cdk/aws-serverless/.gitignore b/packages/@aws-cdk/aws-sam/.gitignore similarity index 100% rename from packages/@aws-cdk/aws-serverless/.gitignore rename to packages/@aws-cdk/aws-sam/.gitignore diff --git a/packages/@aws-cdk/aws-serverless/.npmignore b/packages/@aws-cdk/aws-sam/.npmignore similarity index 100% rename from packages/@aws-cdk/aws-serverless/.npmignore rename to packages/@aws-cdk/aws-sam/.npmignore diff --git a/packages/@aws-cdk/aws-serverless/LICENSE b/packages/@aws-cdk/aws-sam/LICENSE similarity index 100% rename from packages/@aws-cdk/aws-serverless/LICENSE rename to packages/@aws-cdk/aws-sam/LICENSE diff --git a/packages/@aws-cdk/aws-serverless/NOTICE b/packages/@aws-cdk/aws-sam/NOTICE similarity index 100% rename from packages/@aws-cdk/aws-serverless/NOTICE rename to packages/@aws-cdk/aws-sam/NOTICE diff --git a/packages/@aws-cdk/aws-sam/README.md b/packages/@aws-cdk/aws-sam/README.md new file mode 100644 index 0000000000000..4a3888e60e31b --- /dev/null +++ b/packages/@aws-cdk/aws-sam/README.md @@ -0,0 +1,5 @@ +## AWS Serverless Construct Library + +```ts +const sam = require('@aws-cdk/aws-sam'); +``` diff --git a/packages/@aws-cdk/aws-serverless/lib/index.ts b/packages/@aws-cdk/aws-sam/lib/index.ts similarity index 52% rename from packages/@aws-cdk/aws-serverless/lib/index.ts rename to packages/@aws-cdk/aws-sam/lib/index.ts index eb26f203a6065..7431d9e9031b7 100644 --- a/packages/@aws-cdk/aws-serverless/lib/index.ts +++ b/packages/@aws-cdk/aws-sam/lib/index.ts @@ -1,2 +1,2 @@ // AWS::Serverless CloudFormation Resources: -export * from './serverless.generated'; +export * from './sam.generated'; diff --git a/packages/@aws-cdk/aws-serverless/package.json b/packages/@aws-cdk/aws-sam/package.json similarity index 84% rename from packages/@aws-cdk/aws-serverless/package.json rename to packages/@aws-cdk/aws-sam/package.json index 43888b177757f..151d843bcb1a5 100644 --- a/packages/@aws-cdk/aws-serverless/package.json +++ b/packages/@aws-cdk/aws-sam/package.json @@ -1,5 +1,5 @@ { - "name": "@aws-cdk/aws-serverless", + "name": "@aws-cdk/aws-sam", "version": "0.26.0", "description": "The CDK Construct Library for AWS::Serverless", "main": "lib/index.js", @@ -8,16 +8,16 @@ "outdir": "dist", "targets": { "dotnet": { - "namespace": "Amazon.CDK.AWS.Serverless", - "packageId": "Amazon.CDK.AWS.Serverless", + "namespace": "Amazon.CDK.AWS.Sam", + "packageId": "Amazon.CDK.AWS.Sam", "signAssembly": true, "assemblyOriginatorKeyFile": "../../key.snk" }, "java": { - "package": "software.amazon.awscdk.services.serverless", + "package": "software.amazon.awscdk.services.sam", "maven": { "groupId": "software.amazon.awscdk", - "artifactId": "serverless" + "artifactId": "sam" } }, "sphinx": {} @@ -46,7 +46,7 @@ "aws", "cdk", "constructs", - "aws-serverless" + "aws-sam" ], "author": { "name": "Amazon Web Services", diff --git a/packages/@aws-cdk/aws-serverless/test/test.serverless.ts b/packages/@aws-cdk/aws-sam/test/test.sam.ts similarity index 100% rename from packages/@aws-cdk/aws-serverless/test/test.serverless.ts rename to packages/@aws-cdk/aws-sam/test/test.sam.ts diff --git a/packages/@aws-cdk/aws-serverless/README.md b/packages/@aws-cdk/aws-serverless/README.md deleted file mode 100644 index 86d576684fc5e..0000000000000 --- a/packages/@aws-cdk/aws-serverless/README.md +++ /dev/null @@ -1,5 +0,0 @@ -## AWS Serverless Construct Library - -```ts -const serverless = require('@aws-cdk/aws-serverless'); -``` diff --git a/packages/decdk/package.json b/packages/decdk/package.json index 786fafc7abe61..ad90cc929fd52 100644 --- a/packages/decdk/package.json +++ b/packages/decdk/package.json @@ -104,10 +104,10 @@ "@aws-cdk/aws-s3": "^0.26.0", "@aws-cdk/aws-s3-deployment": "^0.26.0", "@aws-cdk/aws-s3-notifications": "^0.26.0", + "@aws-cdk/aws-sam": "^0.26.0", "@aws-cdk/aws-sagemaker": "^0.26.0", "@aws-cdk/aws-sdb": "^0.26.0", "@aws-cdk/aws-secretsmanager": "^0.26.0", - "@aws-cdk/aws-serverless": "^0.26.0", "@aws-cdk/aws-servicecatalog": "^0.26.0", "@aws-cdk/aws-servicediscovery": "^0.26.0", "@aws-cdk/aws-ses": "^0.26.0", diff --git a/tools/awslint/lib/rules/module.ts b/tools/awslint/lib/rules/module.ts index ae4ac8db9d315..c733e8749c4f7 100644 --- a/tools/awslint/lib/rules/module.ts +++ b/tools/awslint/lib/rules/module.ts @@ -25,7 +25,17 @@ moduleLinter.add( { eval: e => { if (!e.ctx.namespace) { return; } if (!e.ctx.assembly) { return; } - const namespace = e.ctx.namespace.toLocaleLowerCase().replace('::', '-'); + const namespace = overrideNamespace(e.ctx.namespace.toLocaleLowerCase().replace('::', '-')); e.assertEquals(e.ctx.assembly.name, `@aws-cdk/${namespace}`, e.ctx.assembly.name); } }); + +/** + * Overrides special-case namespaces like aws-serverless=>aws-sam + */ +function overrideNamespace(namespace: string) { + if (namespace === 'aws-serverless') { + return 'aws-sam'; + } + return namespace; +} diff --git a/tools/cfn2ts/lib/genspec.ts b/tools/cfn2ts/lib/genspec.ts index ca5ec4ffaf613..4603e4b9b092f 100644 --- a/tools/cfn2ts/lib/genspec.ts +++ b/tools/cfn2ts/lib/genspec.ts @@ -119,7 +119,17 @@ export function packageName(module: SpecName | string): string { throw new Error(`Module component name must be "AWS::Xxx" or "Alexa::Xxx" (module: ${module})`); } - return parts[parts.length - 1].toLowerCase(); + return overridePackageName(parts[parts.length - 1].toLowerCase()); +} + +/** + * Overrides special-case namespaces like serverless=>sam + */ +function overridePackageName(name: string) { + if (name === 'serverless') { + return 'sam'; + } + return name; } /** From 8665ea4082f2c8b4312ab8d7d937ee2d3d24286c Mon Sep 17 00:00:00 2001 From: Sam Goodwin Date: Fri, 22 Mar 2019 10:25:35 -0700 Subject: [PATCH 2/5] Incorporate previous names from https://github.com/awslabs/aws-cdk/pull/704 and update aws-rds to use aws-sam instead of aws-serverless --- packages/@aws-cdk/aws-rds/lib/rotation-single-user.ts | 2 +- packages/@aws-cdk/aws-rds/package.json | 2 +- packages/@aws-cdk/aws-sam/package.json | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/@aws-cdk/aws-rds/lib/rotation-single-user.ts b/packages/@aws-cdk/aws-rds/lib/rotation-single-user.ts index 9a67f5b49904b..10ce1c47bc766 100644 --- a/packages/@aws-cdk/aws-rds/lib/rotation-single-user.ts +++ b/packages/@aws-cdk/aws-rds/lib/rotation-single-user.ts @@ -1,7 +1,7 @@ import ec2 = require('@aws-cdk/aws-ec2'); import lambda = require('@aws-cdk/aws-lambda'); import secretsmanager = require('@aws-cdk/aws-secretsmanager'); -import serverless = require('@aws-cdk/aws-serverless'); +import serverless = require('@aws-cdk/aws-sam'); import cdk = require('@aws-cdk/cdk'); /** diff --git a/packages/@aws-cdk/aws-rds/package.json b/packages/@aws-cdk/aws-rds/package.json index 79999fb99e94d..87090f7ea9c76 100644 --- a/packages/@aws-cdk/aws-rds/package.json +++ b/packages/@aws-cdk/aws-rds/package.json @@ -66,7 +66,7 @@ "@aws-cdk/aws-kms": "^0.26.0", "@aws-cdk/aws-lambda": "^0.26.0", "@aws-cdk/aws-secretsmanager": "^0.26.0", - "@aws-cdk/aws-serverless": "^0.26.0", + "@aws-cdk/aws-sam": "^0.26.0", "@aws-cdk/cdk": "^0.26.0" }, "homepage": "https://github.com/awslabs/aws-cdk", diff --git a/packages/@aws-cdk/aws-sam/package.json b/packages/@aws-cdk/aws-sam/package.json index 151d843bcb1a5..61e71f9889084 100644 --- a/packages/@aws-cdk/aws-sam/package.json +++ b/packages/@aws-cdk/aws-sam/package.json @@ -1,15 +1,15 @@ { "name": "@aws-cdk/aws-sam", "version": "0.26.0", - "description": "The CDK Construct Library for AWS::Serverless", + "description": "The CDK Construct Library for the AWS Serverless Application Model (SAM) resources", "main": "lib/index.js", "types": "lib/index.d.ts", "jsii": { "outdir": "dist", "targets": { "dotnet": { - "namespace": "Amazon.CDK.AWS.Sam", - "packageId": "Amazon.CDK.AWS.Sam", + "namespace": "Amazon.CDK.AWS.SAM", + "packageId": "Amazon.CDK.AWS.SAM", "signAssembly": true, "assemblyOriginatorKeyFile": "../../key.snk" }, From d13c36b8e1f4ad64059bcd4a3dcf6a1623203f13 Mon Sep 17 00:00:00 2001 From: Sam Goodwin Date: Fri, 22 Mar 2019 13:10:57 -0700 Subject: [PATCH 3/5] Fix order of imports --- packages/@aws-cdk/aws-rds/lib/rotation-single-user.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@aws-cdk/aws-rds/lib/rotation-single-user.ts b/packages/@aws-cdk/aws-rds/lib/rotation-single-user.ts index 10ce1c47bc766..f9bbf8cac761a 100644 --- a/packages/@aws-cdk/aws-rds/lib/rotation-single-user.ts +++ b/packages/@aws-cdk/aws-rds/lib/rotation-single-user.ts @@ -1,7 +1,7 @@ import ec2 = require('@aws-cdk/aws-ec2'); import lambda = require('@aws-cdk/aws-lambda'); -import secretsmanager = require('@aws-cdk/aws-secretsmanager'); import serverless = require('@aws-cdk/aws-sam'); +import secretsmanager = require('@aws-cdk/aws-secretsmanager'); import cdk = require('@aws-cdk/cdk'); /** From 5f0a4c96d725b376ea4bcd7f6ff7a8c5ce3be672 Mon Sep 17 00:00:00 2001 From: Sam Goodwin Date: Fri, 22 Mar 2019 13:11:10 -0700 Subject: [PATCH 4/5] Fix async test in decdk ... wut --- packages/decdk/test/schema.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/decdk/test/schema.test.ts b/packages/decdk/test/schema.test.ts index 3ac79cdeb4252..f83f7d715317d 100644 --- a/packages/decdk/test/schema.test.ts +++ b/packages/decdk/test/schema.test.ts @@ -21,7 +21,7 @@ beforeAll(async () => { await typesys.load(path.dirname(require.resolve('@aws-cdk/cdk/.jsii'))); }); -test('schemaForInterface: interface with primitives', () => { +test('schemaForInterface: interface with primitives', async () => { // GIVEN const defs = { }; const ctx = SchemaContext.root(defs); From 91ff76bd2980999e4e7fd0eb518337e3cf50243e Mon Sep 17 00:00:00 2001 From: Sam Goodwin Date: Mon, 25 Mar 2019 17:12:34 -0700 Subject: [PATCH 5/5] Update README - better title and note to use standard lambda/apigw libraries instead of aws-sam --- packages/@aws-cdk/aws-sam/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/@aws-cdk/aws-sam/README.md b/packages/@aws-cdk/aws-sam/README.md index 4a3888e60e31b..d67b26a50e3a8 100644 --- a/packages/@aws-cdk/aws-sam/README.md +++ b/packages/@aws-cdk/aws-sam/README.md @@ -1,5 +1,7 @@ -## AWS Serverless Construct Library +## AWS Serverless Application Model Construct Library ```ts const sam = require('@aws-cdk/aws-sam'); ``` + +Note: we recommended to use `@aws-cdk/aws-lambda`, `aws-cdk/aws-lambda-event-sources` and `@aws-cdk/aws-apigateway` packages to build 'serverless' applications with the CDK instead of the `AWS::Serverless` resources exposes by `@aws-cdk/aws-sam`.