Skip to content

Commit 9f5e198

Browse files
committed
add translation job
1 parent 741ab20 commit 9f5e198

10 files changed

Lines changed: 1217 additions & 11 deletions

File tree

cdk/lib/constructs/async-job.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { Architecture, DockerImageCode, DockerImageFunction, IFunction } from 'a
44
import { Platform } from 'aws-cdk-lib/aws-ecr-assets';
55
import { Database } from './database';
66
import { EventBus } from './event-bus';
7+
import { PolicyStatement } from 'aws-cdk-lib/aws-iam';
8+
import { join } from 'path';
79

810
export interface AsyncJobProps {
911
readonly database: Database;
@@ -18,7 +20,7 @@ export class AsyncJob extends Construct {
1820
const { database, eventBus } = props;
1921

2022
const handler = new DockerImageFunction(this, 'Handler', {
21-
code: DockerImageCode.fromImageAsset('../webapp', {
23+
code: DockerImageCode.fromImageAsset(join('..', 'webapp'), {
2224
cmd: ['async-job-runner.handler'],
2325
platform: Platform.LINUX_ARM64,
2426
file: 'job.Dockerfile',
@@ -38,6 +40,13 @@ export class AsyncJob extends Construct {
3840
handler.connections.allowToDefaultPort(database);
3941
eventBus.api.grantPublish(handler);
4042

43+
handler.addToRolePolicy(
44+
new PolicyStatement({
45+
actions: ['translate:TranslateText', 'comprehend:DetectDominantLanguage'],
46+
resources: ['*'],
47+
}),
48+
);
49+
4150
new CfnOutput(this, 'HandlerArn', { value: handler.functionArn });
4251
this.handler = handler;
4352
}

cdk/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"aws-cdk-lib": "^2.189.1",
2828
"cdk-nag": "^2.14.29",
2929
"constructs": "^10.0.0",
30-
"deploy-time-build": "^0.3.28",
30+
"deploy-time-build": "^0.3.31",
3131
"source-map-support": "^0.5.21"
3232
}
3333
}

0 commit comments

Comments
 (0)