Skip to content

Commit 9fe48b3

Browse files
authored
chore: make even more examples compile (#18349)
- globalaccelerator - ecr-assets - apprunner - route53resolver - iot-actions - iot - codecommit - fsx ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 6f318b5 commit 9fe48b3

File tree

24 files changed

+307
-134
lines changed

24 files changed

+307
-134
lines changed

packages/@aws-cdk/aws-apprunner/README.md

+23-20
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323

2424
This module is part of the [AWS Cloud Development Kit](https://github.com/aws/aws-cdk) project.
2525

26-
```ts
27-
import apprunner = require('@aws-cdk/aws-apprunner');
26+
```ts nofixture
27+
import * as apprunner from '@aws-cdk/aws-apprunner';
2828
```
2929

3030
## Introduction
@@ -46,8 +46,8 @@ The `Service` construct allows you to create AWS App Runner services with `ECR P
4646
To create a `Service` with ECR Public:
4747

4848
```ts
49-
new Service(stack, 'Service', {
50-
source: Source.fromEcrPublic({
49+
new apprunner.Service(this, 'Service', {
50+
source: apprunner.Source.fromEcrPublic({
5151
imageConfiguration: { port: 8000 },
5252
imageIdentifier: 'public.ecr.aws/aws-containers/hello-app-runner:latest',
5353
}),
@@ -59,10 +59,12 @@ new Service(stack, 'Service', {
5959
To create a `Service` from an existing ECR repository:
6060

6161
```ts
62-
new Service(stack, 'Service', {
63-
source: Source.fromEcr({
62+
import * as ecr from '@aws-cdk/aws-ecr';
63+
64+
new apprunner.Service(this, 'Service', {
65+
source: apprunner.Source.fromEcr({
6466
imageConfiguration: { port: 80 },
65-
repository: ecr.Repository.fromRepositoryName(stack, 'NginxRepository', 'nginx'),
67+
repository: ecr.Repository.fromRepositoryName(this, 'NginxRepository', 'nginx'),
6668
tag: 'latest',
6769
}),
6870
});
@@ -71,11 +73,13 @@ new Service(stack, 'Service', {
7173
To create a `Service` from local docker image asset directory built and pushed to Amazon ECR:
7274

7375
```ts
74-
const imageAsset = new assets.DockerImageAsset(stack, 'ImageAssets', {
76+
import * as assets from '@aws-cdk/aws-ecr-assets';
77+
78+
const imageAsset = new assets.DockerImageAsset(this, 'ImageAssets', {
7579
directory: path.join(__dirname, './docker.assets'),
7680
});
77-
new Service(stack, 'Service', {
78-
source: Source.fromAsset({
81+
new apprunner.Service(this, 'Service', {
82+
source: apprunner.Source.fromAsset({
7983
imageConfiguration: { port: 8000 },
8084
asset: imageAsset,
8185
}),
@@ -89,36 +93,35 @@ To create a `Service` from the GitHub repository, you need to specify an existin
8993
See [Managing App Runner connections](https://docs.aws.amazon.com/apprunner/latest/dg/manage-connections.html) for more details.
9094

9195
```ts
92-
new Service(stack, 'Service', {
93-
source: Source.fromGitHub({
96+
new apprunner.Service(this, 'Service', {
97+
source: apprunner.Source.fromGitHub({
9498
repositoryUrl: 'https://github.com/aws-containers/hello-app-runner',
9599
branch: 'main',
96-
configurationSource: ConfigurationSourceType.REPOSITORY,
97-
connection: GitHubConnection.fromConnectionArn('CONNECTION_ARN'),
100+
configurationSource: apprunner.ConfigurationSourceType.REPOSITORY,
101+
connection: apprunner.GitHubConnection.fromConnectionArn('CONNECTION_ARN'),
98102
}),
99103
});
100104
```
101105

102106
Use `codeConfigurationValues` to override configuration values with the `API` configuration source type.
103107

104108
```ts
105-
new Service(stack, 'Service', {
106-
source: Source.fromGitHub({
109+
new apprunner.Service(this, 'Service', {
110+
source: apprunner.Source.fromGitHub({
107111
repositoryUrl: 'https://github.com/aws-containers/hello-app-runner',
108112
branch: 'main',
109-
configurationSource: ConfigurationSourceType.API,
113+
configurationSource: apprunner.ConfigurationSourceType.API,
110114
codeConfigurationValues: {
111-
runtime: Runtime.PYTHON_3,
115+
runtime: apprunner.Runtime.PYTHON_3,
112116
port: '8000',
113117
startCommand: 'python app.py',
114118
buildCommand: 'yum install -y pycairo && pip install -r requirements.txt',
115119
},
116-
connection: GitHubConnection.fromConnectionArn('CONNECTION_ARN'),
120+
connection: apprunner.GitHubConnection.fromConnectionArn('CONNECTION_ARN'),
117121
}),
118122
});
119123
```
120124

121-
122125
## IAM Roles
123126

124127
You are allowed to define `instanceRole` and `accessRole` for the `Service`.

packages/@aws-cdk/aws-apprunner/package.json

+7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77
"jsii": {
88
"outdir": "dist",
99
"projectReferences": true,
10+
"metadata": {
11+
"jsii": {
12+
"rosetta": {
13+
"strict": true
14+
}
15+
}
16+
},
1017
"targets": {
1118
"dotnet": {
1219
"namespace": "Amazon.CDK.AWS.AppRunner",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Fixture with packages imported, but nothing else
2+
import { Stack } from '@aws-cdk/core';
3+
import { Construct } from 'constructs';
4+
import * as apprunner from '@aws-cdk/aws-apprunner';
5+
import * as path from 'path';
6+
7+
class Fixture extends Stack {
8+
constructor(scope: Construct, id: string) {
9+
super(scope, id);
10+
/// here
11+
}
12+
}

packages/@aws-cdk/aws-codecommit/README.md

+21-13
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,9 @@ see the [AWS CodeCommit documentation](https://docs.aws.amazon.com/codecommit).
1919
To add a CodeCommit Repository to your stack:
2020

2121
```ts
22-
import * as codecommit from '@aws-cdk/aws-codecommit';
23-
2422
const repo = new codecommit.Repository(this, 'Repository', {
25-
repositoryName: 'MyRepositoryName',
26-
description: 'Some description.', // optional property
23+
repositoryName: 'MyRepositoryName',
24+
description: 'Some description.', // optional property
2725
});
2826
```
2927

@@ -33,6 +31,8 @@ property to clone your repository.
3331
To add an Amazon SNS trigger to your repository:
3432

3533
```ts
34+
declare const repo: codecommit.Repository;
35+
3636
// trigger is established for all repository actions on all branches by default.
3737
repo.notify('arn:aws:sns:*:123456789012:my_topic');
3838
```
@@ -45,12 +45,9 @@ It provides methods for loading code from a directory, `.zip` file and from a pr
4545
Example:
4646

4747
```ts
48-
import * as codecommit from '@aws-cdk/aws-codecommit';
49-
import * as path from 'path';
50-
5148
const repo = new codecommit.Repository(this, 'Repository', {
52-
repositoryName: 'MyRepositoryName',
53-
code: codecommit.Code.fromDirectory(path.join(__dirname, 'directory/'), 'develop'), // optional property, branch parameter can be omitted
49+
repositoryName: 'MyRepositoryName',
50+
code: codecommit.Code.fromDirectory(path.join(__dirname, 'directory/'), 'develop'), // optional property, branch parameter can be omitted
5451
});
5552
```
5653

@@ -61,15 +58,22 @@ Use the `repo.onXxx` methods to define rules that trigger on these events
6158
and invoke targets as a result:
6259

6360
```ts
61+
import * as sns from '@aws-cdk/aws-sns';
62+
import * as targets from '@aws-cdk/aws-events-targets';
63+
64+
declare const repo: codecommit.Repository;
65+
declare const project: codebuild.PipelineProject;
66+
declare const myTopic: sns.Topic;
67+
6468
// starts a CodeBuild project when a commit is pushed to the "master" branch of the repo
6569
repo.onCommit('CommitToMaster', {
66-
target: new targets.CodeBuildProject(project),
67-
branches: ['master'],
70+
target: new targets.CodeBuildProject(project),
71+
branches: ['master'],
6872
});
6973

7074
// publishes a message to an Amazon SNS topic when a comment is made on a pull request
7175
const rule = repo.onCommentOnPullRequest('CommentOnPullRequest', {
72-
target: new targets.SnsTopic(myTopic),
76+
target: new targets.SnsTopic(myTopic),
7377
});
7478
```
7579

@@ -79,9 +83,13 @@ To define CodeStar Notification rules for Repositories, use one of the `notifyOn
7983
They are very similar to `onXxx()` methods for CloudWatch events:
8084

8185
```ts
82-
const target = new chatbot.SlackChannelConfiguration(stack, 'MySlackChannel', {
86+
import * as chatbot from '@aws-cdk/aws-chatbot';
87+
88+
declare const repository: codecommit.Repository;
89+
const target = new chatbot.SlackChannelConfiguration(this, 'MySlackChannel', {
8390
slackChannelConfigurationName: 'YOUR_CHANNEL_NAME',
8491
slackWorkspaceId: 'YOUR_SLACK_WORKSPACE_ID',
8592
slackChannelId: 'YOUR_SLACK_CHANNEL_ID',
8693
});
8794
const rule = repository.notifyOnPullRequestCreated('NotifyOnPullRequestCreated', target);
95+
```

packages/@aws-cdk/aws-codecommit/package.json

+8-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,14 @@
2828
]
2929
}
3030
},
31-
"projectReferences": true
31+
"projectReferences": true,
32+
"metadata": {
33+
"jsii": {
34+
"rosetta": {
35+
"strict": true
36+
}
37+
}
38+
}
3239
},
3340
"repository": {
3441
"type": "git",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Fixture with packages imported, but nothing else
2+
import { Stack } from '@aws-cdk/core';
3+
import { Construct } from 'constructs';
4+
import * as codecommit from '@aws-cdk/aws-codecommit';
5+
import * as codebuild from '@aws-cdk/aws-codebuild';
6+
import * as path from 'path';
7+
8+
class Fixture extends Stack {
9+
constructor(scope: Construct, id: string) {
10+
super(scope, id);
11+
/// here
12+
}
13+
}

packages/@aws-cdk/aws-ecr-assets/README.md

+15-8
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ and/or your app's CI/CD pipeline, and can be naturally referenced in your CDK ap
2121
import { DockerImageAsset } from '@aws-cdk/aws-ecr-assets';
2222

2323
const asset = new DockerImageAsset(this, 'MyBuildImage', {
24-
directory: path.join(__dirname, 'my-image')
24+
directory: path.join(__dirname, 'my-image'),
2525
});
2626
```
2727

@@ -55,25 +55,29 @@ values that can change between different machines to maintain a consistent
5555
asset hash.
5656

5757
```ts
58+
import { DockerImageAsset } from '@aws-cdk/aws-ecr-assets';
59+
5860
const asset = new DockerImageAsset(this, 'MyBuildImage', {
5961
directory: path.join(__dirname, 'my-image'),
6062
buildArgs: {
61-
HTTP_PROXY: 'http://10.20.30.2:1234'
63+
HTTP_PROXY: 'http://10.20.30.2:1234',
6264
},
6365
invalidation: {
64-
buildArgs: false
65-
}
66+
buildArgs: false,
67+
},
6668
});
6769
```
6870

6971
You can optionally pass a target to the `docker build` command by specifying
7072
the `target` property:
7173

7274
```ts
75+
import { DockerImageAsset } from '@aws-cdk/aws-ecr-assets';
76+
7377
const asset = new DockerImageAsset(this, 'MyBuildImage', {
7478
directory: path.join(__dirname, 'my-image'),
75-
target: 'a-target'
76-
})
79+
target: 'a-target',
80+
});
7781
```
7882

7983
## Images from Tarball
@@ -85,7 +89,7 @@ naturally referenced in your CDK app.
8589
import { TarballImageAsset } from '@aws-cdk/aws-ecr-assets';
8690

8791
const asset = new TarballImageAsset(this, 'MyBuildImage', {
88-
tarballFile: 'local-image.tar'
92+
tarballFile: 'local-image.tar',
8993
});
9094
```
9195

@@ -106,7 +110,10 @@ your choice.
106110

107111
Here an example from the [cdklabs/cdk-ecr-deployment] project:
108112

109-
```ts
113+
```text
114+
// This example available in TypeScript only
115+
116+
import { DockerImageAsset } from '@aws-cdk/aws-ecr-assets';
110117
import * as ecrdeploy from 'cdk-ecr-deployment';
111118
112119
const image = new DockerImageAsset(this, 'CDKDockerImage', {

packages/@aws-cdk/aws-ecr-assets/package.json

+8-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,14 @@
2828
]
2929
}
3030
},
31-
"projectReferences": true
31+
"projectReferences": true,
32+
"metadata": {
33+
"jsii": {
34+
"rosetta": {
35+
"strict": true
36+
}
37+
}
38+
}
3239
},
3340
"repository": {
3441
"type": "git",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Fixture with packages imported, but nothing else
2+
import { Stack } from '@aws-cdk/core';
3+
import { Construct } from 'constructs';
4+
import * as path from 'path';
5+
6+
class Fixture extends Stack {
7+
constructor(scope: Construct, id: string) {
8+
super(scope, id);
9+
/// here
10+
}
11+
}

0 commit comments

Comments
 (0)