Simple AWS Examples

Let’s start with some example AWS Infrastructure to better understand how expressive the TerraConstructs library is.

In the open file, we prepared a setupStack function for a sample AWS Stack. For now, we can understand a stack as Terraform configuration backed by a single Terraform state, we will explore this further later.

We can define an AWS Lambda Function using the NodejsFunction constructor with the logEventhandlerPath prepared for us.

stack.ts
export function setupStack(stack: TerraformStack) {
// Add NodeJsFunction
new NodejsFunction(stack, "Main", {
path: logEventhandlerPath,
});
}

To convert this configuration to Terraform, we have to synth the stack (takes about 10s).

Powered by WebContainers
Files
Preparing Environment
  • Installing dependencies