Part 4 - Guichet - Building the transcription capability

Series on building a web application with the AWS CDK continued
Author

Isaac Mbuotidem

Published

April 25, 2021

In our last post we built out the s3 bucket, DynamoDB table and lambda function resources for our application. In this post, we will modify the placeholder lambda function that we created. At the end of the post, we should be able to upload a sound file into our bucket and have our lambda invoke the Amazon Transcribe service with it.

Working with Amazon Transcribe

Creating an S3 bucket resource is simple with the AWS CDK. The same general pattern applies regardless of the construct. All you need do is import the module that contains said construct, and then make use of it. In this case, we need the s3 construct which we can find in the npm module @aws-cdk/aws-s3. Our code below does just that in addition to setting some bucket properties such as the bucket’s removal policy and the access permissions. You can learn more about these bucket property options here. Finally, we use the CfnOutput construct to surface the name of the created bucket upon completion.

import * as cdk from '@aws-cdk/core';
import * as s3 from '@aws-cdk/aws-s3';

//s3 audio bucket
const audioBucket = new s3.Bucket(this, 'AudioBucket', {
    removalPolicy: cdk.RemovalPolicy.DESTROY,
    publicReadAccess: true,
    accessControl: s3.BucketAccessControl.PUBLIC_READ,
});

new cdk.CfnOutput(this, 'audioBucket', { value: audioBucket.bucketName });

Liking the series? In our next post, we will continue building out our lambda function, adding the ability to store the transcription results in a DynamoDB table. You can find the previous post here And if you’d like to dive into the code, here is a link to the project on GitHub.