From 6f27bd5d16926371b3bdc12486450a171137499a Mon Sep 17 00:00:00 2001 From: Kaizen Conroy <36202692+kaizen3031593@users.noreply.github.com> Date: Thu, 27 Jan 2022 12:10:47 -0500 Subject: [PATCH] chore: make all examples compile (#18651) Fixes erroneous examples in these modules and turn on strict mode for each. - cloudformation - region-info - elasticloadbalancing - apigatewayv2 - codestarnotifications - codestar - chatbot - panorama - rekognition - efs - lambda-layer-node-proxy-agent - dynamodb-global - amplify - cloudwatch-actions - app-delivery ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/@aws-cdk/app-delivery/README.md | 17 ++-- packages/@aws-cdk/app-delivery/package.json | 9 +- packages/@aws-cdk/aws-amplify/README.md | 90 ++++++++++++------- packages/@aws-cdk/aws-amplify/lib/app.ts | 2 +- packages/@aws-cdk/aws-amplify/package.json | 9 +- .../aws-amplify/rosetta/default.ts-fixture | 11 +++ packages/@aws-cdk/aws-apigatewayv2/README.md | 29 +++--- .../@aws-cdk/aws-apigatewayv2/package.json | 9 +- packages/@aws-cdk/aws-chatbot/README.md | 3 +- packages/@aws-cdk/aws-chatbot/package.json | 9 +- .../aws-chatbot/rosetta/default.ts-fixture | 10 +++ .../aws-cloudformation/lib/custom-resource.ts | 22 ++++- .../@aws-cdk/aws-cloudformation/package.json | 9 +- .../@aws-cdk/aws-cloudwatch-actions/README.md | 5 +- .../aws-cloudwatch-actions/package.json | 9 +- .../rosetta/default.ts-fixture | 12 +++ packages/@aws-cdk/aws-codestar/README.md | 6 +- packages/@aws-cdk/aws-codestar/package.json | 9 +- .../aws-codestar/rosetta/default.ts-fixture | 10 +++ .../aws-codestarnotifications/README.md | 8 +- .../aws-codestarnotifications/package.json | 9 +- .../rosetta/default.ts-fixture | 10 +++ .../@aws-cdk/aws-dynamodb-global/README.md | 4 +- .../@aws-cdk/aws-dynamodb-global/package.json | 9 +- packages/@aws-cdk/aws-efs/README.md | 4 +- packages/@aws-cdk/aws-efs/package.json | 9 +- .../with-filesystem-instance.ts-fixture | 1 + .../aws-elasticloadbalancing/README.md | 20 +++-- .../aws-elasticloadbalancing/package.json | 9 +- .../rosetta/default.ts-fixture | 13 +++ packages/@aws-cdk/aws-panorama/package.json | 7 ++ .../@aws-cdk/aws-rekognition/package.json | 7 ++ .../lambda-layer-node-proxy-agent/README.md | 7 +- .../package.json | 9 +- .../rosetta/default.ts-fixture | 10 +++ packages/@aws-cdk/region-info/README.md | 30 +++---- packages/@aws-cdk/region-info/package.json | 9 +- .../region-info/rosetta/default.ts-fixture | 11 +++ 38 files changed, 355 insertions(+), 111 deletions(-) create mode 100644 packages/@aws-cdk/aws-amplify/rosetta/default.ts-fixture create mode 100644 packages/@aws-cdk/aws-chatbot/rosetta/default.ts-fixture create mode 100644 packages/@aws-cdk/aws-cloudwatch-actions/rosetta/default.ts-fixture create mode 100644 packages/@aws-cdk/aws-codestar/rosetta/default.ts-fixture create mode 100644 packages/@aws-cdk/aws-codestarnotifications/rosetta/default.ts-fixture create mode 100644 packages/@aws-cdk/aws-elasticloadbalancing/rosetta/default.ts-fixture create mode 100644 packages/@aws-cdk/lambda-layer-node-proxy-agent/rosetta/default.ts-fixture create mode 100644 packages/@aws-cdk/region-info/rosetta/default.ts-fixture diff --git a/packages/@aws-cdk/app-delivery/README.md b/packages/@aws-cdk/app-delivery/README.md index a60f4590dc39f..cd8e80e218bba 100644 --- a/packages/@aws-cdk/app-delivery/README.md +++ b/packages/@aws-cdk/app-delivery/README.md @@ -59,6 +59,10 @@ import * as codepipeline from '@aws-cdk/aws-codepipeline'; import * as codepipeline_actions from '@aws-cdk/aws-codepipeline-actions'; import * as cdk from '@aws-cdk/core'; import * as cicd from '@aws-cdk/app-delivery'; +import * as iam from '@aws-cdk/aws-iam'; + +class MyServiceStackA extends cdk.Stack {} +class MyServiceStackB extends cdk.Stack {} const app = new cdk.App(); @@ -77,7 +81,9 @@ const sourceOutput = new codepipeline.Artifact(); const source = new codepipeline_actions.GitHubSourceAction({ actionName: 'GitHub', output: sourceOutput, - /* ... */ + owner: 'myName', + repo: 'myRepo', + oauthToken: cdk.SecretValue.plainText('secret'), }); pipeline.addStage({ stageName: 'source', @@ -129,10 +135,11 @@ deployStage.addAction(deployServiceAAction); // is passed to CloudFormation and needs the permissions necessary to deploy // stack. Alternatively you can enable [Administrator](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_job-functions.html#jf_administrator) permissions above, // users should understand the privileged nature of this role. -deployServiceAAction.addToRolePolicy(new iam.PolicyStatement({ - actions: ['service:SomeAction'], - resources: [myResource.myResourceArn], - // add more Action(s) and/or Resource(s) here, as needed +const myResourceArn = 'arn:partition:service:region:account-id:resource-id'; +deployServiceAAction.addToDeploymentRolePolicy(new iam.PolicyStatement({ + actions: ['service:SomeAction'], + resources: [myResourceArn], + // add more Action(s) and/or Resource(s) here, as needed })); const serviceStackB = new MyServiceStackB(app, 'ServiceStackB', { /* ... */ }); diff --git a/packages/@aws-cdk/app-delivery/package.json b/packages/@aws-cdk/app-delivery/package.json index 7f57bf73f19d3..8d3da28ad60ba 100644 --- a/packages/@aws-cdk/app-delivery/package.json +++ b/packages/@aws-cdk/app-delivery/package.json @@ -29,7 +29,14 @@ } }, "outdir": "dist", - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "scripts": { "build": "cdk-build", diff --git a/packages/@aws-cdk/aws-amplify/README.md b/packages/@aws-cdk/aws-amplify/README.md index c015bd38494e8..04d9f0d95bf08 100644 --- a/packages/@aws-cdk/aws-amplify/README.md +++ b/packages/@aws-cdk/aws-amplify/README.md @@ -29,37 +29,36 @@ To set up an Amplify Console app, define an `App`: ```ts import * as codebuild from '@aws-cdk/aws-codebuild'; -import * as amplify from '@aws-cdk/aws-amplify'; -import * as cdk from '@aws-cdk/core'; const amplifyApp = new amplify.App(this, 'MyApp', { sourceCodeProvider: new amplify.GitHubSourceCodeProvider({ owner: '', repository: '', - oauthToken: cdk.SecretValue.secretsManager('my-github-token') + oauthToken: SecretValue.secretsManager('my-github-token'), }), - buildSpec: codebuild.BuildSpec.fromObjectToYaml({ // Alternatively add a `amplify.yml` to the repo + buildSpec: codebuild.BuildSpec.fromObjectToYaml({ + // Alternatively add a `amplify.yml` to the repo version: '1.0', frontend: { phases: { preBuild: { commands: [ - 'yarn' - ] + 'yarn', + ], }, build: { commands: [ - 'yarn build' - ] - } + 'yarn build', + ], + }, }, artifacts: { baseDirectory: 'public', files: - - '**/*' - } - } - }) + - '**/*', + }, + }, + }), }); ``` @@ -70,20 +69,22 @@ const amplifyApp = new amplify.App(this, 'MyApp', { sourceCodeProvider: new amplify.GitLabSourceCodeProvider({ owner: '', repository: '', - oauthToken: cdk.SecretValue.secretsManager('my-gitlab-token') - }) + oauthToken: SecretValue.secretsManager('my-gitlab-token'), + }), }); ``` To connect your `App` to CodeCommit, use the `CodeCommitSourceCodeProvider`: ```ts +import * as codecommit from '@aws-cdk/aws-codecommit'; + const repository = new codecommit.Repository(this, 'Repo', { - repositoryName: 'my-repo' + repositoryName: 'my-repo', }); const amplifyApp = new amplify.App(this, 'App', { - sourceCodeProvider: new amplify.CodeCommitSourceCodeProvider({ repository }) + sourceCodeProvider: new amplify.CodeCommitSourceCodeProvider({ repository }), }); ``` @@ -93,6 +94,8 @@ to pull the CodeCommit repository. Add branches: ```ts +declare const amplifyApp: amplify.App; + const master = amplifyApp.addBranch('master'); // `id` will be used as repo branch name const dev = amplifyApp.addBranch('dev'); dev.addEnvironment('STAGE', 'dev'); @@ -103,10 +106,11 @@ Auto build and pull request preview are enabled by default. Add custom rules for redirection: ```ts +declare const amplifyApp: amplify.App; amplifyApp.addCustomRule({ source: '/docs/specific-filename.html', target: '/documents/different-filename.html', - status: amplify.RedirectStatus.TEMPORARY_REDIRECT + status: amplify.RedirectStatus.TEMPORARY_REDIRECT, }); ``` @@ -117,12 +121,18 @@ file extensions: css, gif, ico, jpg, js, png, txt, svg, woff, ttf, map, json, webmanifest. ```ts +declare const mySinglePageApp: amplify.App; + mySinglePageApp.addCustomRule(amplify.CustomRule.SINGLE_PAGE_APPLICATION_REDIRECT); ``` Add a domain and map sub domains to branches: ```ts +declare const amplifyApp: amplify.App; +declare const master: amplify.Branch; +declare const dev: amplify.Branch; + const domain = amplifyApp.addDomain('example.com', { enableAutoSubdomain: true, // in case subdomains should be auto registered for branches autoSubdomainCreationPatterns: ['*', 'pr*'], // regex for branches that should auto register subdomains @@ -140,9 +150,12 @@ Use `BasicAuth.fromCredentials` when referencing an existing secret: ```ts const amplifyApp = new amplify.App(this, 'MyApp', { - repository: 'https://github.com//', - oauthToken: cdk.SecretValue.secretsManager('my-github-token'), - basicAuth: amplify.BasicAuth.fromCredentials('username', cdk.SecretValue.secretsManager('my-github-token')) + sourceCodeProvider: new amplify.GitHubSourceCodeProvider({ + owner: '', + repository: '', + oauthToken: SecretValue.secretsManager('my-github-token'), + }), + basicAuth: amplify.BasicAuth.fromCredentials('username', SecretValue.secretsManager('my-github-token')), }); ``` @@ -150,17 +163,21 @@ Use `BasicAuth.fromGeneratedPassword` to generate a password in Secrets Manager: ```ts const amplifyApp = new amplify.App(this, 'MyApp', { - repository: 'https://github.com//', - oauthToken: cdk.SecretValue.secretsManager('my-github-token'), - basicAuth: amplify.BasicAuth.fromGeneratedPassword('username') + sourceCodeProvider: new amplify.GitHubSourceCodeProvider({ + owner: '', + repository: '', + oauthToken: SecretValue.secretsManager('my-github-token'), + }), + basicAuth: amplify.BasicAuth.fromGeneratedPassword('username'), }); ``` Basic auth can be added to specific branches: ```ts -app.addBranch('feature/next', { - basicAuth: amplify.BasicAuth.fromGeneratedPassword('username') +declare const amplifyApp: amplify.App; +amplifyApp.addBranch('feature/next', { + basicAuth: amplify.BasicAuth.fromGeneratedPassword('username'), }); ``` @@ -171,11 +188,14 @@ of branches: ```ts const amplifyApp = new amplify.App(this, 'MyApp', { - repository: 'https://github.com//', - oauthToken: cdk.SecretValue.secretsManager('my-github-token'), + sourceCodeProvider: new amplify.GitHubSourceCodeProvider({ + owner: '', + repository: '', + oauthToken: SecretValue.secretsManager('my-github-token'), + }), autoBranchCreation: { // Automatically connect branches that match a pattern set - patterns: ['feature/*', 'test/*'] - } + patterns: ['feature/*', 'test/*'], + }, autoBranchDeletion: true, // Automatically disconnect a branch when you delete a branch from your repository }); ``` @@ -185,11 +205,11 @@ const amplifyApp = new amplify.App(this, 'MyApp', { Use the `customResponseHeaders` prop to configure custom response headers for an Amplify app: ```ts -const amplifyApp = new amplify.App(stack, 'App', { +const amplifyApp = new amplify.App(this, 'App', { sourceCodeProvider: new amplify.GitHubSourceCodeProvider({ owner: '', repository: '', - oauthToken: cdk.SecretValue.secretsManager('my-github-token') + oauthToken: SecretValue.secretsManager('my-github-token'), }), customResponseHeaders: [ { @@ -214,7 +234,9 @@ const amplifyApp = new amplify.App(stack, 'App', { `sourceCodeProvider` is optional; when this is not specified the Amplify app can be deployed to using `.zip` packages. The `asset` property can be used to deploy S3 assets to Amplify as part of the CDK: ```ts -const asset = new assets.Asset(this, "SampleAsset", {}); -const amplifyApp = new amplify.App(this, 'MyApp', {}); +import * as assets from '@aws-cdk/aws-s3-assets'; + +declare const asset: assets.Asset; +declare const amplifyApp: amplify.App; const branch = amplifyApp.addBranch("dev", { asset: asset }); ``` diff --git a/packages/@aws-cdk/aws-amplify/lib/app.ts b/packages/@aws-cdk/aws-amplify/lib/app.ts index 030dc58059a6e..bedec6e9e58ac 100644 --- a/packages/@aws-cdk/aws-amplify/lib/app.ts +++ b/packages/@aws-cdk/aws-amplify/lib/app.ts @@ -28,7 +28,7 @@ export interface SourceCodeProviderConfig { /** * The repository for the application. Must use the `HTTPS` protocol. * - * @example https://github.com/aws/aws-cdk + * For example, `https://github.com/aws/aws-cdk`. */ readonly repository: string; diff --git a/packages/@aws-cdk/aws-amplify/package.json b/packages/@aws-cdk/aws-amplify/package.json index 7360eadcffaf4..e546c68ed28c4 100644 --- a/packages/@aws-cdk/aws-amplify/package.json +++ b/packages/@aws-cdk/aws-amplify/package.json @@ -28,7 +28,14 @@ ] } }, - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "repository": { "type": "git", diff --git a/packages/@aws-cdk/aws-amplify/rosetta/default.ts-fixture b/packages/@aws-cdk/aws-amplify/rosetta/default.ts-fixture new file mode 100644 index 0000000000000..922b7902f805d --- /dev/null +++ b/packages/@aws-cdk/aws-amplify/rosetta/default.ts-fixture @@ -0,0 +1,11 @@ +// Fixture with packages imported, but nothing else +import { SecretValue, Stack } from '@aws-cdk/core'; +import { Construct } from 'constructs'; +import * as amplify from '@aws-cdk/aws-amplify'; + +class Fixture extends Stack { + constructor(scope: Construct, id: string) { + super(scope, id); + /// here + } +} diff --git a/packages/@aws-cdk/aws-apigatewayv2/README.md b/packages/@aws-cdk/aws-apigatewayv2/README.md index ccecf1546466f..5e0a110082ab9 100644 --- a/packages/@aws-cdk/aws-apigatewayv2/README.md +++ b/packages/@aws-cdk/aws-apigatewayv2/README.md @@ -79,7 +79,7 @@ configures all other HTTP method calls to `/books` to a lambda proxy. ```ts import { HttpUrlIntegration, HttpLambdaIntegration } from '@aws-cdk/aws-apigatewayv2-integrations'; -const getBooksIntegration = new HttpUrlIntegration('GetBooksIntegration' 'https://get-books-proxy.myproxy.internal'); +const getBooksIntegration = new HttpUrlIntegration('GetBooksIntegration', 'https://get-books-proxy.myproxy.internal'); declare const booksDefaultFn: lambda.Function; const booksDefaultIntegration = new HttpLambdaIntegration('BooksIntegration', booksDefaultFn); @@ -261,19 +261,21 @@ Mutual TLS can be configured to limit access to your API based by using client c ```ts import * as s3 from '@aws-cdk/aws-s3'; +import * as acm from '@aws-cdk/aws-certificatemanager'; + const certArn = 'arn:aws:acm:us-east-1:111111111111:certificate'; const domainName = 'example.com'; -const bucket = new s3.Bucket.fromBucketName(stack, 'TrustStoreBucket', ...); +declare const bucket: s3.Bucket; -new DomainName(stack, 'DomainName', { +new apigwv2.DomainName(this, 'DomainName', { domainName, - certificate: Certificate.fromCertificateArn(stack, 'cert', certArn), + certificate: acm.Certificate.fromCertificateArn(this, 'cert', certArn), mtls: { bucket, key: 'someca.pem', version: 'version', }, -}) +}); ``` Instructions for configuring your trust store can be found [here](https://aws.amazon.com/blogs/compute/introducing-mutual-tls-authentication-for-amazon-api-gateway/) @@ -408,17 +410,17 @@ Grant permission to use API Gateway Management API of a WebSocket API by calling You can use Management API to send a callback message to a connected client, get connection information, or disconnect the client. Learn more at [Use @connections commands in your backend service](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-how-to-call-websocket-api-connections.html). ```ts -const lambda = new lambda.Function(this, 'lambda', { /* ... */ }); +declare const fn: lambda.Function; -const webSocketApi = new WebSocketApi(stack, 'mywsapi'); -const stage = new WebSocketStage(stack, 'mystage', { +const webSocketApi = new apigwv2.WebSocketApi(this, 'mywsapi'); +const stage = new apigwv2.WebSocketStage(this, 'mystage', { webSocketApi, stageName: 'dev', }); // per stage permission -stage.grantManageConnections(lambda); +stage.grantManagementApiAccess(fn); // for all the stages permission -webSocketApi.grantManageConnections(lambda); +webSocketApi.grantManageConnections(fn); ``` ### Managing access to WebSocket APIs @@ -434,9 +436,8 @@ Websocket APIs also support usage of API Keys. An API Key is a key that is used To require an API Key when accessing the Websocket API: ```ts -const webSocketApi = new WebSocketApi(stack, 'mywsapi',{ - apiKeySelectionExpression: WebSocketApiKeySelectionExpression.HEADER_X_API_KEY, - }); -... +const webSocketApi = new apigwv2.WebSocketApi(this, 'mywsapi',{ + apiKeySelectionExpression: apigwv2.WebSocketApiKeySelectionExpression.HEADER_X_API_KEY, +}); ``` diff --git a/packages/@aws-cdk/aws-apigatewayv2/package.json b/packages/@aws-cdk/aws-apigatewayv2/package.json index c35e477c574e4..31ec578d85b51 100644 --- a/packages/@aws-cdk/aws-apigatewayv2/package.json +++ b/packages/@aws-cdk/aws-apigatewayv2/package.json @@ -32,7 +32,14 @@ ] } }, - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "repository": { "type": "git", diff --git a/packages/@aws-cdk/aws-chatbot/README.md b/packages/@aws-cdk/aws-chatbot/README.md index 5e871bb81db48..6f868ff02e17d 100644 --- a/packages/@aws-cdk/aws-chatbot/README.md +++ b/packages/@aws-cdk/aws-chatbot/README.md @@ -18,6 +18,7 @@ This module is part of the [AWS Cloud Development Kit](https://github.com/aws/aw ```ts import * as chatbot from '@aws-cdk/aws-chatbot'; import * as sns from '@aws-cdk/aws-sns'; +import * as iam from '@aws-cdk/aws-iam'; const slackChannel = new chatbot.SlackChannelConfiguration(this, 'MySlackChannel', { slackChannelConfigurationName: 'YOUR_CHANNEL_NAME', @@ -33,7 +34,7 @@ slackChannel.addToRolePolicy(new iam.PolicyStatement({ resources: ['arn:aws:s3:::abc/xyz/123.txt'], })); -slackChannel.addNotificationTopic(new sns.Topic(this, 'MyTopic')) +slackChannel.addNotificationTopic(new sns.Topic(this, 'MyTopic')); ``` ## Log Group diff --git a/packages/@aws-cdk/aws-chatbot/package.json b/packages/@aws-cdk/aws-chatbot/package.json index 2abb1900c7cfd..35a6887f3b5cb 100644 --- a/packages/@aws-cdk/aws-chatbot/package.json +++ b/packages/@aws-cdk/aws-chatbot/package.json @@ -28,7 +28,14 @@ ] } }, - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "repository": { "type": "git", diff --git a/packages/@aws-cdk/aws-chatbot/rosetta/default.ts-fixture b/packages/@aws-cdk/aws-chatbot/rosetta/default.ts-fixture new file mode 100644 index 0000000000000..50d86e8a055ce --- /dev/null +++ b/packages/@aws-cdk/aws-chatbot/rosetta/default.ts-fixture @@ -0,0 +1,10 @@ +// Fixture with packages imported, but nothing else +import { Stack } from '@aws-cdk/core'; +import { Construct } from 'constructs'; + +class Fixture extends Stack { + constructor(scope: Construct, id: string) { + super(scope, id); + /// here + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-cloudformation/lib/custom-resource.ts b/packages/@aws-cdk/aws-cloudformation/lib/custom-resource.ts index 9c30e6c08540c..b71a9f56aea61 100644 --- a/packages/@aws-cdk/aws-cloudformation/lib/custom-resource.ts +++ b/packages/@aws-cdk/aws-cloudformation/lib/custom-resource.ts @@ -99,21 +99,35 @@ export interface CustomResourceProps { * [resource provider framework]: https://docs.aws.amazon.com/cdk/api/latest/docs/custom-resources-readme.html * * ```ts - * // use the provider framework from aws-cdk/custom-resources: - * provider: new custom_resources.Provider({ + * import * as custom_resources from '@aws-cdk/custom-resources'; + * import * as lambda from '@aws-cdk/aws-lambda'; + * import { Stack } from '@aws-cdk/core'; + * declare const myOnEventLambda: lambda.Function; + * declare const myIsCompleteLambda: lambda.Function; + * const stack = new Stack(); + * + * const provider = new custom_resources.Provider(stack, 'myProvider', { * onEventHandler: myOnEventLambda, * isCompleteHandler: myIsCompleteLambda, // optional * }); * ``` * * ```ts + * import * as cloudformation from '@aws-cdk/aws-cloudformation'; + * import * as lambda from '@aws-cdk/aws-lambda'; + * declare const myFunction: lambda.Function; + * * // invoke an AWS Lambda function when a lifecycle event occurs: - * provider: CustomResourceProvider.fromLambda(myFunction) + * const provider = cloudformation.CustomResourceProvider.fromLambda(myFunction); * ``` * * ```ts + * import * as cloudformation from '@aws-cdk/aws-cloudformation'; + * import * as sns from '@aws-cdk/aws-sns'; + * declare const myTopic: sns.Topic; + * * // publish lifecycle events to an SNS topic: - * provider: CustomResourceProvider.fromTopic(myTopic) + * const provider = cloudformation.CustomResourceProvider.fromTopic(myTopic); * ``` */ readonly provider: ICustomResourceProvider; diff --git a/packages/@aws-cdk/aws-cloudformation/package.json b/packages/@aws-cdk/aws-cloudformation/package.json index 3671367db5817..0b15fd01bfe35 100644 --- a/packages/@aws-cdk/aws-cloudformation/package.json +++ b/packages/@aws-cdk/aws-cloudformation/package.json @@ -28,7 +28,14 @@ ] } }, - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "repository": { "type": "git", diff --git a/packages/@aws-cdk/aws-cloudwatch-actions/README.md b/packages/@aws-cdk/aws-cloudwatch-actions/README.md index f13861a8c1555..99eb74e06eb54 100644 --- a/packages/@aws-cdk/aws-cloudwatch-actions/README.md +++ b/packages/@aws-cdk/aws-cloudwatch-actions/README.md @@ -17,12 +17,11 @@ The currently implemented actions are: EC2 Actions, SNS Actions, Autoscaling Act ## EC2 Action Example ```ts -import * as cw from "@aws-cdk/aws-cloudwatch"; // Alarm must be configured with an EC2 per-instance metric -let alarm: cw.Alarm; +declare const alarm: cloudwatch.Alarm; // Attach a reboot when alarm triggers alarm.addAlarmAction( - new Ec2Action(Ec2InstanceActions.REBOOT) + new actions.Ec2Action(actions.Ec2InstanceAction.REBOOT), ); ``` diff --git a/packages/@aws-cdk/aws-cloudwatch-actions/package.json b/packages/@aws-cdk/aws-cloudwatch-actions/package.json index 08a59bffab0d5..2a37790862f9b 100644 --- a/packages/@aws-cdk/aws-cloudwatch-actions/package.json +++ b/packages/@aws-cdk/aws-cloudwatch-actions/package.json @@ -28,7 +28,14 @@ ] } }, - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "repository": { "type": "git", diff --git a/packages/@aws-cdk/aws-cloudwatch-actions/rosetta/default.ts-fixture b/packages/@aws-cdk/aws-cloudwatch-actions/rosetta/default.ts-fixture new file mode 100644 index 0000000000000..c473f965be130 --- /dev/null +++ b/packages/@aws-cdk/aws-cloudwatch-actions/rosetta/default.ts-fixture @@ -0,0 +1,12 @@ +// Fixture with packages imported, but nothing else +import { Stack } from '@aws-cdk/core'; +import { Construct } from 'constructs'; +import * as actions from '@aws-cdk/aws-cloudwatch-actions'; +import * as cloudwatch from '@aws-cdk/aws-cloudwatch'; + +class Fixture extends Stack { + constructor(scope: Construct, id: string) { + super(scope, id); + /// here + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-codestar/README.md b/packages/@aws-cdk/aws-codestar/README.md index e9c6ec2e4bf75..6bdf425aab1d1 100644 --- a/packages/@aws-cdk/aws-codestar/README.md +++ b/packages/@aws-cdk/aws-codestar/README.md @@ -29,13 +29,13 @@ To create a new GitHub Repository and commit the assets from S3 bucket into the import * as codestar from '@aws-cdk/aws-codestar'; import * as s3 from '@aws-cdk/aws-s3' -new codestar.GitHubRepository(stack, 'GitHubRepo', { +new codestar.GitHubRepository(this, 'GitHubRepo', { owner: 'aws', repositoryName: 'aws-cdk', - accessToken: cdk.SecretValue.secretsManager('my-github-token', { + accessToken: SecretValue.secretsManager('my-github-token', { jsonField: 'token', }), - contentsBucket: s3.Bucket.fromBucketName(stack, 'Bucket', 'bucket-name'), + contentsBucket: s3.Bucket.fromBucketName(this, 'Bucket', 'bucket-name'), contentsKey: 'import.zip', }); ``` diff --git a/packages/@aws-cdk/aws-codestar/package.json b/packages/@aws-cdk/aws-codestar/package.json index e179f607ecbfc..a2ae9b1cbd339 100644 --- a/packages/@aws-cdk/aws-codestar/package.json +++ b/packages/@aws-cdk/aws-codestar/package.json @@ -28,7 +28,14 @@ ] } }, - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "repository": { "type": "git", diff --git a/packages/@aws-cdk/aws-codestar/rosetta/default.ts-fixture b/packages/@aws-cdk/aws-codestar/rosetta/default.ts-fixture new file mode 100644 index 0000000000000..439308f8c0176 --- /dev/null +++ b/packages/@aws-cdk/aws-codestar/rosetta/default.ts-fixture @@ -0,0 +1,10 @@ +// Fixture with packages imported, but nothing else +import { SecretValue, Stack } from '@aws-cdk/core'; +import { Construct } from 'constructs'; + +class Fixture extends Stack { + constructor(scope: Construct, id: string) { + super(scope, id); + /// here + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-codestarnotifications/README.md b/packages/@aws-cdk/aws-codestarnotifications/README.md index b13a33089b01a..ba1da9ced0026 100644 --- a/packages/@aws-cdk/aws-codestarnotifications/README.md +++ b/packages/@aws-cdk/aws-codestarnotifications/README.md @@ -39,17 +39,17 @@ import * as codebuild from '@aws-cdk/aws-codebuild'; import * as sns from '@aws-cdk/aws-sns'; import * as chatbot from '@aws-cdk/aws-chatbot'; -const project = new codebuild.PipelineProject(stack, 'MyProject'); +const project = new codebuild.PipelineProject(this, 'MyProject'); -const topic = new sns.Topic(stack, 'MyTopic1'); +const topic = new sns.Topic(this, 'MyTopic1'); -const slack = new chatbot.SlackChannelConfiguration(stack, 'MySlackChannel', { +const slack = new chatbot.SlackChannelConfiguration(this, 'MySlackChannel', { slackChannelConfigurationName: 'YOUR_CHANNEL_NAME', slackWorkspaceId: 'YOUR_SLACK_WORKSPACE_ID', slackChannelId: 'YOUR_SLACK_CHANNEL_ID', }); -const rule = new notifications.NotificationRule(stack, 'NotificationRule', { +const rule = new notifications.NotificationRule(this, 'NotificationRule', { source: project, events: [ 'codebuild-project-build-state-succeeded', diff --git a/packages/@aws-cdk/aws-codestarnotifications/package.json b/packages/@aws-cdk/aws-codestarnotifications/package.json index 251b0b0fa69f7..e6d2bf301f3b4 100644 --- a/packages/@aws-cdk/aws-codestarnotifications/package.json +++ b/packages/@aws-cdk/aws-codestarnotifications/package.json @@ -28,7 +28,14 @@ ] } }, - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "repository": { "type": "git", diff --git a/packages/@aws-cdk/aws-codestarnotifications/rosetta/default.ts-fixture b/packages/@aws-cdk/aws-codestarnotifications/rosetta/default.ts-fixture new file mode 100644 index 0000000000000..50d86e8a055ce --- /dev/null +++ b/packages/@aws-cdk/aws-codestarnotifications/rosetta/default.ts-fixture @@ -0,0 +1,10 @@ +// Fixture with packages imported, but nothing else +import { Stack } from '@aws-cdk/core'; +import { Construct } from 'constructs'; + +class Fixture extends Stack { + constructor(scope: Construct, id: string) { + super(scope, id); + /// here + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-dynamodb-global/README.md b/packages/@aws-cdk/aws-dynamodb-global/README.md index a31c37eb3e114..77f2725e76797 100644 --- a/packages/@aws-cdk/aws-dynamodb-global/README.md +++ b/packages/@aws-cdk/aws-dynamodb-global/README.md @@ -26,9 +26,9 @@ import { App } from '@aws-cdk/core'; const app = new App(); new GlobalTable(app, 'globdynamodb', { - partitionKey: { name: 'hashKey', type: AttributeType.String }, + partitionKey: { name: 'hashKey', type: AttributeType.STRING }, tableName: 'GlobalTable', - regions: [ "us-east-1", "us-east-2", "us-west-2" ] + regions: [ "us-east-1", "us-east-2", "us-west-2" ], }); app.synth(); ``` diff --git a/packages/@aws-cdk/aws-dynamodb-global/package.json b/packages/@aws-cdk/aws-dynamodb-global/package.json index 61e2d44daab47..882e1b789e912 100644 --- a/packages/@aws-cdk/aws-dynamodb-global/package.json +++ b/packages/@aws-cdk/aws-dynamodb-global/package.json @@ -39,7 +39,14 @@ "iconUrl": "https://raw.githubusercontent.com/aws/aws-cdk/master/logo/default-256-dark.png" } }, - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "keywords": [ "aws", diff --git a/packages/@aws-cdk/aws-efs/README.md b/packages/@aws-cdk/aws-efs/README.md index 1a26f9e0e9c5a..058198d0c897e 100644 --- a/packages/@aws-cdk/aws-efs/README.md +++ b/packages/@aws-cdk/aws-efs/README.md @@ -36,7 +36,7 @@ const fileSystem = new efs.FileSystem(this, 'MyEfsFileSystem', { vpc: new ec2.Vpc(this, 'VPC'), lifecyclePolicy: efs.LifecyclePolicy.AFTER_14_DAYS, // files are not transitioned to infrequent access (IA) storage by default performanceMode: efs.PerformanceMode.GENERAL_PURPOSE, // default - outInfrequentAccessPolicy: efs.OutOfInfrequentAccessPolicy.AFTER_1_ACCESS, // files are not transitioned back from (infrequent access) IA to primary storage by default + outOfInfrequentAccessPolicy: efs.OutOfInfrequentAccessPolicy.AFTER_1_ACCESS, // files are not transitioned back from (infrequent access) IA to primary storage by default }); ``` @@ -159,6 +159,6 @@ You can configure the file system to be destroyed on stack deletion by setting a ```ts const fileSystem = new efs.FileSystem(this, 'EfsFileSystem', { vpc: new ec2.Vpc(this, 'VPC'), - removalPolicy: RemovalPolicy.DESTROY + removalPolicy: RemovalPolicy.DESTROY, }); ``` diff --git a/packages/@aws-cdk/aws-efs/package.json b/packages/@aws-cdk/aws-efs/package.json index 4ce72aacb86e5..09d1c1f6f2ca6 100644 --- a/packages/@aws-cdk/aws-efs/package.json +++ b/packages/@aws-cdk/aws-efs/package.json @@ -28,7 +28,14 @@ ] } }, - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "repository": { "type": "git", diff --git a/packages/@aws-cdk/aws-efs/rosetta/with-filesystem-instance.ts-fixture b/packages/@aws-cdk/aws-efs/rosetta/with-filesystem-instance.ts-fixture index 092b572afa726..427e2ed030b4b 100644 --- a/packages/@aws-cdk/aws-efs/rosetta/with-filesystem-instance.ts-fixture +++ b/packages/@aws-cdk/aws-efs/rosetta/with-filesystem-instance.ts-fixture @@ -3,6 +3,7 @@ import { Stack } from '@aws-cdk/core'; import { Construct } from 'constructs'; import * as efs from '@aws-cdk/aws-efs'; import * as ec2 from '@aws-cdk/aws-ec2'; +import * as iam from '@aws-cdk/aws-iam'; class Fixture extends Stack { constructor(scope: Construct, id: string) { diff --git a/packages/@aws-cdk/aws-elasticloadbalancing/README.md b/packages/@aws-cdk/aws-elasticloadbalancing/README.md index 6d66ca5965c69..45ec1828bb466 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancing/README.md +++ b/packages/@aws-cdk/aws-elasticloadbalancing/README.md @@ -21,17 +21,19 @@ balancer, set up listeners and a health check, and supply the fleet(s) you want to load balance to in the `targets` property. ```ts +declare const vpc: ec2.IVpc; const lb = new elb.LoadBalancer(this, 'LB', { - vpc, - internetFacing: true, - healthCheck: { - port: 80 - }, + vpc, + internetFacing: true, + healthCheck: { + port: 80, + }, }); +declare const myAutoScalingGroup: autoscaling.AutoScalingGroup; lb.addTarget(myAutoScalingGroup); lb.addListener({ - externalPort: 80, + externalPort: 80, }); ``` @@ -39,8 +41,10 @@ The load balancer allows all connections by default. If you want to change that, pass the `allowConnectionsFrom` property while setting up the listener: ```ts +declare const mySecurityGroup: ec2.SecurityGroup; +declare const lb: elb.LoadBalancer; lb.addListener({ - externalPort: 80, - allowConnectionsFrom: [mySecurityGroup] + externalPort: 80, + allowConnectionsFrom: [mySecurityGroup], }); ``` diff --git a/packages/@aws-cdk/aws-elasticloadbalancing/package.json b/packages/@aws-cdk/aws-elasticloadbalancing/package.json index 190f42846901b..c43acdd739437 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancing/package.json +++ b/packages/@aws-cdk/aws-elasticloadbalancing/package.json @@ -28,7 +28,14 @@ ] } }, - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "repository": { "type": "git", diff --git a/packages/@aws-cdk/aws-elasticloadbalancing/rosetta/default.ts-fixture b/packages/@aws-cdk/aws-elasticloadbalancing/rosetta/default.ts-fixture new file mode 100644 index 0000000000000..036e5ddf38c1b --- /dev/null +++ b/packages/@aws-cdk/aws-elasticloadbalancing/rosetta/default.ts-fixture @@ -0,0 +1,13 @@ +// Fixture with packages imported, but nothing else +import { Stack } from '@aws-cdk/core'; +import { Construct } from 'constructs'; +import * as elb from '@aws-cdk/aws-elasticloadbalancing'; +import * as ec2 from '@aws-cdk/aws-ec2'; +import * as autoscaling from '@aws-cdk/aws-autoscaling'; + +class Fixture extends Stack { + constructor(scope: Construct, id: string) { + super(scope, id); + /// here + } +} diff --git a/packages/@aws-cdk/aws-panorama/package.json b/packages/@aws-cdk/aws-panorama/package.json index b49f7b48cfb52..5149569f8ff38 100644 --- a/packages/@aws-cdk/aws-panorama/package.json +++ b/packages/@aws-cdk/aws-panorama/package.json @@ -7,6 +7,13 @@ "jsii": { "outdir": "dist", "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + }, "targets": { "dotnet": { "namespace": "Amazon.CDK.AWS.Panorama", diff --git a/packages/@aws-cdk/aws-rekognition/package.json b/packages/@aws-cdk/aws-rekognition/package.json index b7371d019400b..9787e9a8715b7 100644 --- a/packages/@aws-cdk/aws-rekognition/package.json +++ b/packages/@aws-cdk/aws-rekognition/package.json @@ -7,6 +7,13 @@ "jsii": { "outdir": "dist", "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + }, "targets": { "dotnet": { "namespace": "Amazon.CDK.AWS.Rekognition", diff --git a/packages/@aws-cdk/lambda-layer-node-proxy-agent/README.md b/packages/@aws-cdk/lambda-layer-node-proxy-agent/README.md index 45187394cb8b2..f27c51013b3fc 100644 --- a/packages/@aws-cdk/lambda-layer-node-proxy-agent/README.md +++ b/packages/@aws-cdk/lambda-layer-node-proxy-agent/README.md @@ -16,8 +16,11 @@ This module exports a single class called `NodeProxyAgentLayer` which is a `lamb Usage: ```ts -const fn = new lambda.Function(...); -fn.addLayers(new NodeProxyAgentLayer(stack, 'NodeProxyAgentLayer')); +import { NodeProxyAgentLayer } from '@aws-cdk/lambda-layer-node-proxy-agent'; +import * as lambda from '@aws-cdk/aws-lambda'; + +declare const fn: lambda.Function; +fn.addLayers(new NodeProxyAgentLayer(this, 'NodeProxyAgentLayer')); ``` [`proxy-agent`](https://www.npmjs.com/package/proxy-agent) will be installed under `/opt/nodejs/node_modules`. diff --git a/packages/@aws-cdk/lambda-layer-node-proxy-agent/package.json b/packages/@aws-cdk/lambda-layer-node-proxy-agent/package.json index b4e0211270c66..1753c1057db84 100644 --- a/packages/@aws-cdk/lambda-layer-node-proxy-agent/package.json +++ b/packages/@aws-cdk/lambda-layer-node-proxy-agent/package.json @@ -29,7 +29,14 @@ ] } }, - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "repository": { "type": "git", diff --git a/packages/@aws-cdk/lambda-layer-node-proxy-agent/rosetta/default.ts-fixture b/packages/@aws-cdk/lambda-layer-node-proxy-agent/rosetta/default.ts-fixture new file mode 100644 index 0000000000000..50d86e8a055ce --- /dev/null +++ b/packages/@aws-cdk/lambda-layer-node-proxy-agent/rosetta/default.ts-fixture @@ -0,0 +1,10 @@ +// Fixture with packages imported, but nothing else +import { Stack } from '@aws-cdk/core'; +import { Construct } from 'constructs'; + +class Fixture extends Stack { + constructor(scope: Construct, id: string) { + super(scope, id); + /// here + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/region-info/README.md b/packages/@aws-cdk/region-info/README.md index 0f1186318ee49..b8d75339c3320 100644 --- a/packages/@aws-cdk/region-info/README.md +++ b/packages/@aws-cdk/region-info/README.md @@ -22,10 +22,8 @@ the form of the `RegionInfo` class. This is the preferred way to interact with the regional information database: ```ts -import { RegionInfo } from '@aws-cdk/region-info'; - // Get the information for "eu-west-1": -const region = RegionInfo.get('eu-west-1'); +const region = regionInfo.RegionInfo.get('eu-west-1'); // Access attributes: region.s3StaticWebsiteEndpoint; // s3-website-eu-west-1.amazonaws.com @@ -44,8 +42,6 @@ a list of known fact names, which can then be used with the `RegionInfo` to retrieve a particular value: ```ts -import * as regionInfo from '@aws-cdk/region-info'; - const codeDeployPrincipal = regionInfo.Fact.find('us-east-1', regionInfo.FactName.servicePrincipal('codedeploy.amazonaws.com')); // => codedeploy.us-east-1.amazonaws.com @@ -60,11 +56,13 @@ missing from the library. In such cases, the `Fact.register` method can be used to inject FactName into the database: ```ts -regionInfo.Fact.register({ - region: 'bermuda-triangle-1', - name: regionInfo.FactName.servicePrincipal('s3.amazonaws.com'), - value: 's3-website.bermuda-triangle-1.nowhere.com', -}); +class MyFact implements regionInfo.IFact { + public readonly region = 'bermuda-triangle-1'; + public readonly name = regionInfo.FactName.servicePrincipal('s3.amazonaws.com'); + public readonly value = 's3-website.bermuda-triangle-1.nowhere.com'; +} + +regionInfo.Fact.register(new MyFact()); ``` ## Overriding incorrect information @@ -74,11 +72,13 @@ overridden using the same `Fact.register` method demonstrated above, simply adding an extra boolean argument: ```ts -regionInfo.Fact.register({ - region: 'us-east-1', - name: regionInfo.FactName.servicePrincipal('service.amazonaws.com'), - value: 'the-correct-principal.amazonaws.com', -}, true /* Allow overriding information */); +class MyFact implements regionInfo.IFact { + public readonly region = 'us-east-1'; + public readonly name = regionInfo.FactName.servicePrincipal('service.amazonaws.com'); + public readonly value = 'the-correct-principal.amazonaws.com'; +} + +regionInfo.Fact.register(new MyFact(), true /* Allow overriding information */); ``` If you happen to have stumbled upon incorrect data built into this library, it diff --git a/packages/@aws-cdk/region-info/package.json b/packages/@aws-cdk/region-info/package.json index dba2268c2fa22..f3400ed30b3e4 100644 --- a/packages/@aws-cdk/region-info/package.json +++ b/packages/@aws-cdk/region-info/package.json @@ -28,7 +28,14 @@ ] } }, - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "scripts": { "gen": "bash build-tools/generate.sh", diff --git a/packages/@aws-cdk/region-info/rosetta/default.ts-fixture b/packages/@aws-cdk/region-info/rosetta/default.ts-fixture new file mode 100644 index 0000000000000..3a11f7f47a475 --- /dev/null +++ b/packages/@aws-cdk/region-info/rosetta/default.ts-fixture @@ -0,0 +1,11 @@ +// Fixture with packages imported, but nothing else +import { Stack } from '@aws-cdk/core'; +import { Construct } from 'constructs'; +import * as regionInfo from '@aws-cdk/region-info'; + +class Fixture extends Stack { + constructor(scope: Construct, id: string) { + super(scope, id); + /// here + } +} \ No newline at end of file