MCPcopy Create free account
hub / github.com/cdk-patterns/serverless / PollyStack

Class PollyStack

polly/python/polly/polly_stack.py:10–33  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8
9
10class PollyStack(core.Stack):
11
12 def __init__(self, scope: core.Construct, id: str, **kwargs) -> None:
13 super().__init__(scope, id, **kwargs)
14
15 # Lambda Function that takes in text and returns a polly voice synthesis
16 polly_lambda = _lambda.Function(self, 'pollyHandler',
17 runtime=_lambda.Runtime.PYTHON_3_8,
18 code=_lambda.Code.from_asset('lambda_fns'),
19 handler='polly.handler')
20
21 # https://docs.aws.amazon.com/polly/latest/dg/api-permissions-reference.html
22 # https://docs.aws.amazon.com/translate/latest/dg/translate-api-permissions-ref.html
23 polly_policy = iam.PolicyStatement(effect=iam.Effect.ALLOW,
24 resources=['*'],
25 actions=['translate:TranslateText',
26 'polly:SynthesizeSpeech'])
27 polly_lambda.add_to_role_policy(polly_policy)
28
29 # defines an API Gateway Http API resource backed by our "efs_lambda" function.
30 api = api_gw.HttpApi(self, 'Polly',
31 default_integration=integrations.LambdaProxyIntegration(handler=polly_lambda))
32
33 core.CfnOutput(self, 'HTTP API Url', value=api.url)

Callers 1

app.pyFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected