You should explore the contents of this project. It demonstrates a CDK app with an instance of a stack (text_to_speech_pipeline_stack
)
which contains an Amazon S3 bucket that triggers an AWS Lambda to send .txt
style content to AWS Polly for conversion to .mp3
that is landed in another S3 bucket.
I find that a picture is worth a thousand words, but I look at the CDK as an abstraction on top of CloudFormation/Terraform that allows developers to rapidly build out solutions.
If you would like to learn more about it here is a great link covering this topic.
-
When you are logged in, you can upload an alphanumeric
.txt
file to the S3 bucket named text-to-speech-pipeline-s3inputbucket5b674094-1j7kl0t3tprdz using the orangeUpload
button. -
After the
.txt
file has been uploaded, the Lambda function will automagically pickup the file and send it to AWS Polly which will then output the.mp3
file to the S3 bucket tangle-audio-output.
The cdk.json
file tells the CDK Toolkit how to execute your app.
This project is set up like a standard Python project. The initialization process also creates
a virtualenv within this project, stored under the .venv directory. To create the virtualenv
it assumes that there is a python3
executable in your path with access to the venv
package.
If for any reason the automatic creation of the virtualenv fails, you can create the virtualenv
manually once the init process completes.
To setup this project, manually create a virtualenv on MacOS and Linux:
$ python3 -m venv .venv
After the virtualenv is created, you can use the following step to activate your virtualenv.
$ source .venv/bin/activate
If you are a Windows platform, you would activate the virtualenv like this:
% .venv\Scripts\activate.bat
Once the virtualenv is activated, you can install the required dependencies.
$ pip install -r requirements.txt
$ poetry install
Configure pre-commit hooks prior to development:
$ inv install-hooks
Note: this workflow will now looks something like:
git add <file>
git commit
git add .
-- if there are code correctionsgit cz
-- to make a descriptive commit to the repo
At this point you can now synthesize the CloudFormation template for this code.
$ inv synth
You can now begin exploring the source code, contained in the text_to_speech directory. There is also a very trivial test included that can be run like this:
$ pytest
To add additional dependencies, for example other CDK libraries, just run the poetry add <library>
command.
inv ls
list all stacks in the appinv synth
emits the synthesized CloudFormation templateinv deploy
deploy this stack to your default AWS account/regioninv diff
compare deployed stack with current statecdk docs
open CDK documentation
Enjoy!