From 85a5479bd6990397052c4a35aaa5909160eba612 Mon Sep 17 00:00:00 2001 From: Nan <107427662+unavailablealfaa@users.noreply.github.com> Date: Thu, 30 Jun 2022 14:33:10 -0700 Subject: [PATCH 1/5] Add Sagemaker Endpoint L2 construct Add SageMaker endpoint L2 construct to allow clients to define endpoint used to deploy and host models. RPC No.: 441 --- packages/@aws-cdk/aws-sagemaker/README.md | 44 ++- .../aws-sagemaker/lib/endpoint-base.ts | 93 +++++++ .../@aws-cdk/aws-sagemaker/lib/endpoint.ts | 105 +++++++ packages/@aws-cdk/aws-sagemaker/lib/index.ts | 3 + .../aws-sagemaker/lib/validate-props.ts | 19 ++ packages/@aws-cdk/aws-sagemaker/package.json | 11 +- .../aws-sagemaker/test/endpoint.test.ts | 260 ++++++++++++++++++ .../aws-sagemaker/test/sagemaker.test.ts | 6 - .../pkglint/test/temp9RSjzP/README.md | 39 +++ 9 files changed, 569 insertions(+), 11 deletions(-) create mode 100644 packages/@aws-cdk/aws-sagemaker/lib/endpoint-base.ts create mode 100644 packages/@aws-cdk/aws-sagemaker/lib/endpoint.ts create mode 100644 packages/@aws-cdk/aws-sagemaker/lib/validate-props.ts create mode 100644 packages/@aws-cdk/aws-sagemaker/test/endpoint.test.ts delete mode 100644 packages/@aws-cdk/aws-sagemaker/test/sagemaker.test.ts create mode 100644 tools/@aws-cdk/pkglint/test/temp9RSjzP/README.md diff --git a/packages/@aws-cdk/aws-sagemaker/README.md b/packages/@aws-cdk/aws-sagemaker/README.md index 482007cffe7d6..b992a2a00fc7e 100644 --- a/packages/@aws-cdk/aws-sagemaker/README.md +++ b/packages/@aws-cdk/aws-sagemaker/README.md @@ -9,16 +9,56 @@ > > [CFN Resources]: https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_lib +![cdk-constructs: Experimental](https://img.shields.io/badge/cdk--constructs-experimental-important.svg?style=for-the-badge) + +> The CDK constructs in this module are experimental. + --- This module is part of the [AWS Cloud Development Kit](https://github.com/aws/aws-cdk) project. +## Installation + +Import to your project: + ```ts nofixture import * as sagemaker from '@aws-cdk/aws-sagemaker'; ``` +## Endpoint + +### Basic definiton + +In order to define a Endpoint, you must provide the name of an endpoint config. This following codes allow you to define a basic AWS Sagemaker Endpoints: + +```ts +import * as sagemaker from '@aws-cdk/aws-sagemaker'; +const endpoint = new sagemaker.Endpoint(this, 'MyEndpoint', { + endpointName: 'MyEndpoint', + endpointConfigName: 'MyEndpointConfig', +}); +``` + +### Applying tags to endpoints + +You can apply [tags](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-resource-tags.html) to endpoint resources, example codes: + +```ts +import * as sagemaker from '@aws-cdk/aws-sagemaker'; +new sagemaker.Endpoint(this, 'MyEndpoint', { + endpointName: 'MyEndpoint', + endpointConfigName: 'MyEndpointConfig', + tags: { + 'key1': 'value1', + 'key2': 'value2', + }, +}); +``` + +--- + There are no official hand-written ([L2](https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_lib)) constructs for this service yet. Here are some suggestions on how to proceed: @@ -29,11 +69,11 @@ There are no official hand-written ([L2](https://docs.aws.amazon.com/cdk/latest/ -There are no hand-written ([L2](https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_lib)) constructs for this service yet. +There are no hand-written ([L2](https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_lib)) constructs for this service yet. However, you can still use the automatically generated [L1](https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_l1_using) constructs, and use this service exactly as you would using CloudFormation directly. For more information on the resources and properties available for this service, see the [CloudFormation documentation for AWS::SageMaker](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/AWS_SageMaker.html). (Read the [CDK Contributing Guide](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and submit an RFC if you are interested in contributing to this construct library.) - + \ No newline at end of file diff --git a/packages/@aws-cdk/aws-sagemaker/lib/endpoint-base.ts b/packages/@aws-cdk/aws-sagemaker/lib/endpoint-base.ts new file mode 100644 index 0000000000000..33dd5eb60f09c --- /dev/null +++ b/packages/@aws-cdk/aws-sagemaker/lib/endpoint-base.ts @@ -0,0 +1,93 @@ +import * as iam from '@aws-cdk/aws-iam'; +import { IResource, Resource, ResourceProps } from '@aws-cdk/core'; +import { Construct } from 'constructs'; + +/** + * Represents an Sagemaker endpoint resource. + */ +export interface IEndpoint extends IResource { + /** + * The ARN of the endpoint. + * + * @attribute + */ + readonly endpointArn: string; + + /** + * The name of the endpoint. + * + * @attribute + */ + readonly endpointName: string; + + /** + * Grant access to invoke the endpoint to the given identity. + * + * This will grant the following permissions: + * - sagemaker:InvokeEndpoint + * + * @param grantee Principal to grant send rights to + */ + grantInvoke(grantee: iam.IGrantable): iam.Grant; +} + +/** + * Reference to a new or existing Amazon Sagemaker endpoint. + */ +export abstract class EndpointBase extends Resource implements IEndpoint { + + /** + * The ARN of the endpoint. + * + * @attribute + */ + public abstract readonly endpointArn: string; + + /** + * The name of the endpoint. + * + * @attribute + */ + public abstract readonly endpointName: string; + + constructor(scope: Construct, id: string, props: ResourceProps = {}) { + super(scope, id, props); + } + + /** + * Grant access to invoke the endpoint to the given identity. + * + * This will grant the following permissions: + * - sagemaker:InvokeEndpoint + * + * @param grantee Principal to grant send rights to + */ + public grantInvoke(grantee: iam.IGrantable) { + return iam.Grant.addToPrincipal({ + grantee, + actions: [ + 'sagemaker:InvokeEndpoint', + ], + resourceArns: [ + this.endpointArn, + ], + }); + } +} + +/** + * Reference to a endpoint + */ +export interface EndpointAttributes { + /** + * The ARN of the endpoint. + */ + readonly endpointArn: string; + + /** + * The name of the endpoint. + * + * @default - if endpoint name is not specified, the name will be derived from the endpoint ARN + */ + readonly endpointName?: string; +} diff --git a/packages/@aws-cdk/aws-sagemaker/lib/endpoint.ts b/packages/@aws-cdk/aws-sagemaker/lib/endpoint.ts new file mode 100644 index 0000000000000..261c51bd25e3d --- /dev/null +++ b/packages/@aws-cdk/aws-sagemaker/lib/endpoint.ts @@ -0,0 +1,105 @@ +import { ArnFormat, Stack, CfnTag } from '@aws-cdk/core'; +import { Construct } from 'constructs'; +import { EndpointAttributes, EndpointBase, IEndpoint } from './endpoint-base'; +import { CfnEndpoint } from './sagemaker.generated'; +import { validateEndpointProps } from './validate-props'; + +/** + * Properties for creating a new Endpoint. + */ +export interface EndpointProps { + /** + * A physical name for the endpoint. + * + * @default CloudFormation-generated name + */ + readonly endpointName?: string; + + /** + * The name for the configuration for the endpoint. + */ + readonly endpointConfigName: string; + + /** + * Tags to apply to the endpoint. + * + * @default {} + */ + readonly tags?: { [key: string]: string }; +} + +/** + * A new Amazon Sagemaker endpoint. + */ +export class Endpoint extends EndpointBase { + /** + * Import an existing endpoint from endpoint attributes. + * + * @param scope the parent Construct for this new Construct + * @param id the logical ID of this new Construct + * @param attrs the properties of the referenced endpoint + * @returns a Construct representing a reference to an existing endpoint + */ + public static fromEndpointAttributes(scope: Construct, id: string, attrs: EndpointAttributes): IEndpoint { + + class ImportedEndpoint extends EndpointBase { + public readonly endpointArn = attrs.endpointArn; + public readonly endpointName = attrs.endpointName || this.parseEndpointNameFromArn(attrs.endpointArn); + + private parseEndpointNameFromArn(endpointArn: string): string { + const stack = Stack.of(scope); + const parsedArn = stack.splitArn(endpointArn, ArnFormat.SLASH_RESOURCE_NAME); + if (!parsedArn.resourceName) { + throw new Error(`Can not get endpoint name from ARN ${endpointArn}, please provide endpoint name.`); + } + return parsedArn.resourceName!!; + } + } + + return new ImportedEndpoint(scope, id); + } + + /** + * The ARN of the endpoint. + */ + public readonly endpointArn: string; + + /** + * The physical name of the endpoint. + */ + public readonly endpointName: string; + + constructor(scope: Construct, id: string, props: EndpointProps) { + super(scope, id, { + physicalName: props.endpointName, + }); + + validateEndpointProps(props); + + const endpoint = new CfnEndpoint(this, 'Resource', { + endpointName: this.physicalName, + endpointConfigName: props.endpointConfigName, + tags: this.renderTags(props.tags), + }); + + this.endpointArn = this.getResourceArnAttribute(endpoint.ref, { + service: 'sagemaker', + resource: 'endpoint', + resourceName: this.physicalName, + }); + this.endpointName = this.getResourceNameAttribute(endpoint.attrEndpointName); + } + + /** + * Render the configured Tags to be added to the endpoint properties. + */ + private renderTags(tags?: { [key: string]: string }): CfnTag[] | undefined { + if (!tags) { return undefined; } + return Object.keys(tags).map((key) => { + return { + key: key, + value: tags[key], + }; + }); + } +} diff --git a/packages/@aws-cdk/aws-sagemaker/lib/index.ts b/packages/@aws-cdk/aws-sagemaker/lib/index.ts index 4c40a31057568..ae49002c4a238 100644 --- a/packages/@aws-cdk/aws-sagemaker/lib/index.ts +++ b/packages/@aws-cdk/aws-sagemaker/lib/index.ts @@ -1,2 +1,5 @@ +export * from './endpoint'; +export * from './endpoint-base'; + // AWS::SageMaker CloudFormation Resources: export * from './sagemaker.generated'; diff --git a/packages/@aws-cdk/aws-sagemaker/lib/validate-props.ts b/packages/@aws-cdk/aws-sagemaker/lib/validate-props.ts new file mode 100644 index 0000000000000..50f4e0e87dc0c --- /dev/null +++ b/packages/@aws-cdk/aws-sagemaker/lib/validate-props.ts @@ -0,0 +1,19 @@ +import { EndpointProps } from './index'; + +export function validateEndpointProps(props: EndpointProps) { + const defaultNameMaxLength: number = 63; + const defaultNamePattern: RegExp = /^[a-zA-Z0-9](-*[a-zA-Z0-9]){0,62}/; + validateName('Endpoint name', props.endpointName, defaultNameMaxLength, defaultNamePattern); + validateName('Endpoint config name', props.endpointConfigName, defaultNameMaxLength, defaultNamePattern); +} + +function validateName(label: string, name: string | undefined, maxLength: number, pattern: RegExp) { + if (name === undefined) { return; } + + if (name.length > maxLength) { + throw new Error(`${label} can not be longer than ${maxLength} characters.`); + } + if (!pattern.test(name)) { + throw new Error(`${label} can contain only letters, numbers, hyphens with no spaces.`); + } +} diff --git a/packages/@aws-cdk/aws-sagemaker/package.json b/packages/@aws-cdk/aws-sagemaker/package.json index 37739b75d69b8..1e55bca7f3028 100644 --- a/packages/@aws-cdk/aws-sagemaker/package.json +++ b/packages/@aws-cdk/aws-sagemaker/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-sagemaker", - "version": "0.0.0", + "version": "0.0.1", "private": true, "description": "The CDK Construct Library for AWS::SageMaker", "main": "lib/index.js", @@ -85,21 +85,26 @@ "@aws-cdk/cdk-build-tools": "0.0.0", "@aws-cdk/cfn2ts": "0.0.0", "@aws-cdk/pkglint": "0.0.0", - "@types/jest": "^27.5.2" + "@types/jest": "^27.5.2", + "jest": "^27.5.1" }, "dependencies": { "@aws-cdk/core": "0.0.0", + "@aws-cdk/aws-iam": "0.0.0", + "@aws-cdk/aws-cloudwatch": "0.0.0", "constructs": "^10.0.0" }, "peerDependencies": { "@aws-cdk/core": "0.0.0", + "@aws-cdk/aws-iam": "0.0.0", + "@aws-cdk/aws-cloudwatch": "0.0.0", "constructs": "^10.0.0" }, "engines": { "node": ">= 14.15.0" }, "stability": "experimental", - "maturity": "cfn-only", + "maturity": "experimental", "awscdkio": { "announce": false }, diff --git a/packages/@aws-cdk/aws-sagemaker/test/endpoint.test.ts b/packages/@aws-cdk/aws-sagemaker/test/endpoint.test.ts new file mode 100644 index 0000000000000..c77ef817eb960 --- /dev/null +++ b/packages/@aws-cdk/aws-sagemaker/test/endpoint.test.ts @@ -0,0 +1,260 @@ +import { Template } from '@aws-cdk/assertions'; +import * as iam from '@aws-cdk/aws-iam'; +import * as cdk from '@aws-cdk/core'; +import * as sagemaker from '../lib'; + +/* eslint-disable quote-props */ + +describe('endpoint', () => { + test('succeeds to create endpoint when endpoint config name is valid', () => { + const stack = new cdk.Stack(); + + new sagemaker.Endpoint(stack, 'MyEndpoint', { + endpointConfigName: 'MyEndpointConfig', + }); + + Template.fromStack(stack).templateMatches({ + Resources: { + MyEndpointE262FD4F: { + Type: 'AWS::SageMaker::Endpoint', + Properties: { + EndpointConfigName: 'MyEndpointConfig', + }, + }, + }, + }); + }); + + test('succeeds to create endpoint when endpoint name and config name is valid', () => { + const stack = new cdk.Stack(); + + new sagemaker.Endpoint(stack, 'MyEndpoint', { + endpointName: 'MyEndpoint', + endpointConfigName: 'MyEndpointConfig', + }); + + Template.fromStack(stack).templateMatches({ + Resources: { + MyEndpointE262FD4F: { + Type: 'AWS::SageMaker::Endpoint', + Properties: { + EndpointName: 'MyEndpoint', + EndpointConfigName: 'MyEndpointConfig', + }, + }, + }, + }); + }); + + test('fails to create endpoint when endpoint name or endpoint config name is invalid', () => { + const stack = new cdk.Stack(); + + expect(() => { + new sagemaker.Endpoint(stack, 'MyEndpoint1', { + endpointName: 'MyEndpointNameIsMoreThan63Characters12345678901234567890123456789012345678901234567890', + endpointConfigName: 'MyEndpointConfig', + }); + }).toThrow('Endpoint name can not be longer than 63 characters.'); + + expect(() => { + new sagemaker.Endpoint(stack, 'MyEndpoint2', { + endpointName: '_MyEndpoint', + endpointConfigName: 'MyEndpointConfig', + }); + }).toThrow('Endpoint name can contain only letters, numbers, hyphens with no spaces.'); + + expect(() => { + new sagemaker.Endpoint(stack, 'MyEndpoint13', { + endpointName: 'MyEndpoint', + endpointConfigName: 'MyEndpointConfigNameIsMoreThan63Characters1234567890123456789012345678901234567890', + }); + }).toThrow('Endpoint config name can not be longer than 63 characters.'); + + expect(() => { + new sagemaker.Endpoint(stack, 'MyEndpoint4', { + endpointName: 'MyEndpoint', + endpointConfigName: '_MyEndpointConfig', + }); + }).toThrow('Endpoint config name can contain only letters, numbers, hyphens with no spaces.'); + }); + + test('endpoint creation fails when endpoint name or endpoint config name is invalid', () => { + const stack = new cdk.Stack(); + + expect(() => { + new sagemaker.Endpoint(stack, 'MyEndpoint1', { + endpointName: 'MyEndpointNameIsMoreThan63Characters12345678901234567890123456789012345678901234567890', + endpointConfigName: 'MyEndpointConfig', + }); + }).toThrow('Endpoint name can not be longer than 63 characters.'); + + expect(() => { + new sagemaker.Endpoint(stack, 'MyEndpoint2', { + endpointName: '_MyEndpoint', + endpointConfigName: 'MyEndpointConfig', + }); + }).toThrow('Endpoint name can contain only letters, numbers, hyphens with no spaces.'); + + expect(() => { + new sagemaker.Endpoint(stack, 'MyEndpoint13', { + endpointName: 'MyEndpoint', + endpointConfigName: 'MyEndpointConfigNameIsMoreThan63Characters1234567890123456789012345678901234567890', + }); + }).toThrow('Endpoint config name can not be longer than 63 characters.'); + + expect(() => { + new sagemaker.Endpoint(stack, 'MyEndpoint4', { + endpointName: 'MyEndpoint', + endpointConfigName: '_MyEndpointConfig', + }); + }).toThrow('Endpoint config name can contain only letters, numbers, hyphens with no spaces.'); + }); + + test('succeeds to create endpoint with tags', () => { + const stack = new cdk.Stack(); + + new sagemaker.Endpoint(stack, 'MyEndpoint', { + endpointName: 'MyEndpoint', + endpointConfigName: 'MyEndpointConfig', + tags: { + 'key1': 'value1', + 'key2': 'value2', + }, + }); + + Template.fromStack(stack).templateMatches({ + Resources: { + MyEndpointE262FD4F: { + Type: 'AWS::SageMaker::Endpoint', + Properties: { + EndpointName: 'MyEndpoint', + EndpointConfigName: 'MyEndpointConfig', + Tags: [ + { + Key: 'key1', + Value: 'value1', + }, + { + Key: 'key2', + Value: 'value2', + }, + ], + }, + }, + }, + }); + }); + + test('succeeds to import endpoint when endpoint arn and name are valid', () => { + const stack = new cdk.Stack(); + + const endpointName = 'test-endpoint'; + const endpointArn = `arn:aws:sagemaker:us-east-1:123456789012:endpoint/${endpointName}`; + + const importedEndpoint = sagemaker.Endpoint.fromEndpointAttributes(stack, 'MyEndpoint', { + endpointArn: endpointArn, + endpointName: endpointName, + }); + + expect(importedEndpoint).not.toEqual(undefined); + expect(importedEndpoint.endpointArn).toEqual(endpointArn); + expect(importedEndpoint.endpointName).toEqual(endpointName); + }); + + test('succeeds to import endpoint when endpoint arn is valid', () => { + const stack = new cdk.Stack(); + + const endpointArn = 'arn:aws:sagemaker:us-east-1:123456789012:endpoint/test-endpoint'; + + const importedEndpoint = sagemaker.Endpoint.fromEndpointAttributes(stack, 'MyEndpoint', { + endpointArn: endpointArn, + }); + + expect(importedEndpoint).not.toEqual(undefined); + expect(importedEndpoint.endpointArn).toEqual(endpointArn); + expect(importedEndpoint.endpointName).toEqual('test-endpoint'); + }); + + test('failed to import endpoint when endpoint arn is invalid', () => { + const stack = new cdk.Stack(); + + const endpointArn = 'arn:aws:sagemaker:us-east-1:123456789012:endpoint/'; + expect(() => { + sagemaker.Endpoint.fromEndpointAttributes(stack, 'MyEndpoint', { + endpointArn: endpointArn, + }); + }).toThrow(`Can not get endpoint name from ARN ${endpointArn}, please provide endpoint name.`); + }); +}); + +describe('grant', () => { + test('succeeds to grantInvoke', () => { + const stack = new cdk.Stack(); + const role = new iam.Role(stack, 'Role', { + assumedBy: new iam.AccountPrincipal('accountPrincipal'), + }); + const endpoint = new sagemaker.Endpoint(stack, 'MyEndpoint', { + endpointName: 'MyEndpoint', + endpointConfigName: 'MyEndpointConfig', + }); + + endpoint.grantInvoke(role); + + Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', { + PolicyDocument: { + Statement: [ + { + Action: 'sagemaker:InvokeEndpoint', + Effect: 'Allow', + Resource: { + Ref: 'MyEndpointE262FD4F', + }, + }, + ], + Version: '2012-10-17', + }, + PolicyName: 'RoleDefaultPolicy5FFB7DAB', + Roles: [ + { + Ref: 'Role1ABCC5F0', + }, + ], + }); + }); + + test('succeeds to grantInvoke with imported endpoint', () => { + const stack = new cdk.Stack(); + const role = new iam.Role(stack, 'Role', { + assumedBy: new iam.AccountPrincipal('accountPrincipal'), + }); + + const endpointName = 'test-endpoint'; + const endpointArn = `arn:aws:sagemaker:us-east-1:123456789012:endpoint/${endpointName}`; + + const importedEndpoint = sagemaker.Endpoint.fromEndpointAttributes(stack, 'MyEndpoint', { + endpointArn: endpointArn, + endpointName: endpointName, + }); + + importedEndpoint.grantInvoke(role); + + Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', { + PolicyDocument: { + Statement: [ + { + Action: 'sagemaker:InvokeEndpoint', + Effect: 'Allow', + Resource: 'arn:aws:sagemaker:us-east-1:123456789012:endpoint/test-endpoint', + }, + ], + Version: '2012-10-17', + }, + PolicyName: 'RoleDefaultPolicy5FFB7DAB', + Roles: [ + { + Ref: 'Role1ABCC5F0', + }, + ], + }); + }); +}); diff --git a/packages/@aws-cdk/aws-sagemaker/test/sagemaker.test.ts b/packages/@aws-cdk/aws-sagemaker/test/sagemaker.test.ts deleted file mode 100644 index 465c7bdea0693..0000000000000 --- a/packages/@aws-cdk/aws-sagemaker/test/sagemaker.test.ts +++ /dev/null @@ -1,6 +0,0 @@ -import '@aws-cdk/assertions'; -import {} from '../lib'; - -test('No tests are specified for this package', () => { - expect(true).toBe(true); -}); diff --git a/tools/@aws-cdk/pkglint/test/temp9RSjzP/README.md b/tools/@aws-cdk/pkglint/test/temp9RSjzP/README.md new file mode 100644 index 0000000000000..9de782e255195 --- /dev/null +++ b/tools/@aws-cdk/pkglint/test/temp9RSjzP/README.md @@ -0,0 +1,39 @@ +# Alexa Skills Kit Construct Library + + +--- + +![cfn-resources: Stable](https://img.shields.io/badge/cfn--resources-stable-success.svg?style=for-the-badge) + +> All classes with the `Cfn` prefix in this module ([CFN Resources]) are always stable and safe to use. +> +> [CFN Resources]: https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_lib + +--- + + + +This module is part of the [AWS Cloud Development Kit](https://github.com/aws/aws-cdk) project. + +```ts nofixture +import * as alexa_ask from '@aws-cdk/alexa-ask'; +``` + + + +There are no official hand-written ([L2](https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_lib)) constructs for this service yet. Here are some suggestions on how to proceed: + +- Search [Construct Hub for ASK construct libraries](https://constructs.dev/search?q=ask) +- Use the automatically generated [L1](https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_l1_using) constructs, in the same way you would use [the CloudFormation Alexa::ASK resources](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Alexa_ASK.html) directly. + + + + +There are no hand-written ([L2](https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_lib)) constructs for this service yet. +However, you can still use the automatically generated [L1](https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_l1_using) constructs, and use this service exactly as you would using CloudFormation directly. + +For more information on the resources and properties available for this service, see the [CloudFormation documentation for Alexa::ASK](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Alexa_ASK.html). + +(Read the [CDK Contributing Guide](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and submit an RFC if you are interested in contributing to this construct library.) + + From 173a5b1378d94bdd35deb6ca927144f31e2b5f86 Mon Sep 17 00:00:00 2001 From: Nan Date: Thu, 30 Jun 2022 15:18:07 -0700 Subject: [PATCH 2/5] Update aws-sagemaker model version to 0.0.0 following cdk convention Update aws-sagemaker model version to 0.0.0 following cdk convention --- packages/@aws-cdk/aws-sagemaker/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@aws-cdk/aws-sagemaker/package.json b/packages/@aws-cdk/aws-sagemaker/package.json index 1e55bca7f3028..71589bcb309e1 100644 --- a/packages/@aws-cdk/aws-sagemaker/package.json +++ b/packages/@aws-cdk/aws-sagemaker/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-sagemaker", - "version": "0.0.1", + "version": "0.0.0", "private": true, "description": "The CDK Construct Library for AWS::SageMaker", "main": "lib/index.js", From dff30461b4fac3bd437ee906fd3ad032091ffd57 Mon Sep 17 00:00:00 2001 From: Nan Date: Thu, 30 Jun 2022 15:40:17 -0700 Subject: [PATCH 3/5] Remove unnecessary file --- .../pkglint/test/temp9RSjzP/README.md | 39 ------------------- 1 file changed, 39 deletions(-) delete mode 100644 tools/@aws-cdk/pkglint/test/temp9RSjzP/README.md diff --git a/tools/@aws-cdk/pkglint/test/temp9RSjzP/README.md b/tools/@aws-cdk/pkglint/test/temp9RSjzP/README.md deleted file mode 100644 index 9de782e255195..0000000000000 --- a/tools/@aws-cdk/pkglint/test/temp9RSjzP/README.md +++ /dev/null @@ -1,39 +0,0 @@ -# Alexa Skills Kit Construct Library - - ---- - -![cfn-resources: Stable](https://img.shields.io/badge/cfn--resources-stable-success.svg?style=for-the-badge) - -> All classes with the `Cfn` prefix in this module ([CFN Resources]) are always stable and safe to use. -> -> [CFN Resources]: https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_lib - ---- - - - -This module is part of the [AWS Cloud Development Kit](https://github.com/aws/aws-cdk) project. - -```ts nofixture -import * as alexa_ask from '@aws-cdk/alexa-ask'; -``` - - - -There are no official hand-written ([L2](https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_lib)) constructs for this service yet. Here are some suggestions on how to proceed: - -- Search [Construct Hub for ASK construct libraries](https://constructs.dev/search?q=ask) -- Use the automatically generated [L1](https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_l1_using) constructs, in the same way you would use [the CloudFormation Alexa::ASK resources](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Alexa_ASK.html) directly. - - - - -There are no hand-written ([L2](https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_lib)) constructs for this service yet. -However, you can still use the automatically generated [L1](https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_l1_using) constructs, and use this service exactly as you would using CloudFormation directly. - -For more information on the resources and properties available for this service, see the [CloudFormation documentation for Alexa::ASK](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Alexa_ASK.html). - -(Read the [CDK Contributing Guide](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and submit an RFC if you are interested in contributing to this construct library.) - - From 1228b220769f120c92f02636d77c149ccd44d695 Mon Sep 17 00:00:00 2001 From: Nan Date: Thu, 30 Jun 2022 17:07:27 -0700 Subject: [PATCH 4/5] Add stability banner for experimental in README.md file --- packages/@aws-cdk/aws-sagemaker/README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/@aws-cdk/aws-sagemaker/README.md b/packages/@aws-cdk/aws-sagemaker/README.md index b992a2a00fc7e..368ba05547200 100644 --- a/packages/@aws-cdk/aws-sagemaker/README.md +++ b/packages/@aws-cdk/aws-sagemaker/README.md @@ -11,7 +11,11 @@ ![cdk-constructs: Experimental](https://img.shields.io/badge/cdk--constructs-experimental-important.svg?style=for-the-badge) -> The CDK constructs in this module are experimental. +> 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. --- From 040a0322b957d2010ce2f61f4ffe4e2e0cf6269b Mon Sep 17 00:00:00 2001 From: Nan Date: Thu, 30 Jun 2022 18:03:38 -0700 Subject: [PATCH 5/5] Add rosetta fixture to import the necessary packages to make code snippets in readme to be compiled --- packages/@aws-cdk/aws-sagemaker/README.md | 2 -- .../aws-sagemaker/rosetta/default.ts-fixture | 12 ++++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 packages/@aws-cdk/aws-sagemaker/rosetta/default.ts-fixture diff --git a/packages/@aws-cdk/aws-sagemaker/README.md b/packages/@aws-cdk/aws-sagemaker/README.md index 368ba05547200..3dca6d892bbfb 100644 --- a/packages/@aws-cdk/aws-sagemaker/README.md +++ b/packages/@aws-cdk/aws-sagemaker/README.md @@ -38,7 +38,6 @@ import * as sagemaker from '@aws-cdk/aws-sagemaker'; In order to define a Endpoint, you must provide the name of an endpoint config. This following codes allow you to define a basic AWS Sagemaker Endpoints: ```ts -import * as sagemaker from '@aws-cdk/aws-sagemaker'; const endpoint = new sagemaker.Endpoint(this, 'MyEndpoint', { endpointName: 'MyEndpoint', endpointConfigName: 'MyEndpointConfig', @@ -50,7 +49,6 @@ const endpoint = new sagemaker.Endpoint(this, 'MyEndpoint', { You can apply [tags](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-resource-tags.html) to endpoint resources, example codes: ```ts -import * as sagemaker from '@aws-cdk/aws-sagemaker'; new sagemaker.Endpoint(this, 'MyEndpoint', { endpointName: 'MyEndpoint', endpointConfigName: 'MyEndpointConfig', diff --git a/packages/@aws-cdk/aws-sagemaker/rosetta/default.ts-fixture b/packages/@aws-cdk/aws-sagemaker/rosetta/default.ts-fixture new file mode 100644 index 0000000000000..90e36954c7bfa --- /dev/null +++ b/packages/@aws-cdk/aws-sagemaker/rosetta/default.ts-fixture @@ -0,0 +1,12 @@ +// Fixture with packages imported, but nothing else +import { Construct } from 'constructs'; +import { Stack } from '@aws-cdk/core'; +import sagemaker = require('@aws-cdk/aws-sagemaker'); + +class Fixture extends Stack { + constructor(scope: Construct, id: string) { + super(scope, id); + + /// here + } +}