Skip to main content

Integrating Woovi with AWS Lambda

Configuring the AWS CLI​

You also need the aws CLI configured. This is required because it handles all access to your account and runs the script that deploys your application via CDK.

This link has the CLI installation instructions for your operating system.

After that, configure the CLI with the command aws configure. It will ask for a few values such as AWS Access Key ID, AWS Secret Access Key, etc. To learn how to get these values, see the AWS documentation, which walks you through the full process.

References​

Configuring CDK​

First of all, you need to install CDK. As a prerequisite, you also need npm installed on your machine (you can use Yarn if you prefer).

Once npm is installed, install the AWS CDK toolkit as follows:

npm install --global aws-cdk

When it finishes, check that everything worked with:

cdk --version

References​

Boilerplate repository for CDK + AWS Lambda​

For the next steps, we have a boilerplate repository. If you want to use it for the following steps, you can find it here.

Bootstrapping CDK​

Under the hood, CDK uses other resources such as S3 buckets. We need to create them to make sure the whole flow works correctly. To do so, run:

cdk boostrap aws://ACCOUNT-NUMBER/REGION

To get both the ACCOUNT-NUMBER and the desired REGION, if you don't have them at hand, run the following command with the AWS CLI you set up earlier:

aws sts get-caller identity

This shows some information about your account, including the REGION and the ACCOUNT-NUMBER.

Deploying my CDK stack​

After configuring the CDK CLI correctly, two more steps are needed to finally have our stack running on AWS:

First, we "synthesize" our application into the format expected by CloudFormation, the service CDK uses under the hood to handle all deployment responsibilities.

To synthesize, run this command:

cdk synth

This converts your entire application into a friendly YML format that AWS CloudFormation reads.


Once synthesized, just deploy our stack by running:

cdk deploy

You have now deployed your application successfully! You can access resources such as:

  • API Gateway
  • Lambda

And check that everything was deployed correctly.

References​

How to use it?​

To use it, we need three things configured correctly:

  • API Gateway (you already configured it in the previous step);
  • The webhook;

Configuring the webhook​

To create the webhook, see the documentation on creating a webhook in our platform and click the Novo webhook (New webhook) button. You will see this form:

Webhook

Fill it in as follows:

  1. Nome (Name): enter any name you like for the webhook.
  2. Evento (Event): the event that should trigger the webhook; select Transação Pix Recebida (Pix transaction received).
  3. Url: enter the API Gateway URL that will act as the trigger for your Lambda function.

After filling in these three fields, click Salvar (Save). Congratulations, you've created your new webhook!

For more information on configuring your webhook, see these other docs: