Send your logs to Coralogix using [AWS CloudFormation](https://aws.amazon.com/cloudformation/), granting you observability into your CloudFormation events.

The following tutorial demonstrates how to configure an AWS CloudFormation template using a Lambda function to send your telemetry data to Coralogix.

## Prerequisites

1. [Sign up](https://signup.coralogix.com/#/) for a Coralogix account. Set up your account on the Coralogix [domain](https://coralogix.com/docs/user-guides/account-management/account-settings/coralogix-domain/index.md) corresponding to the region within which you would like your data stored.
1. Access your Coralogix [Send Your Data - API Key](https://coralogix.com/docs/user-guides/account-management/api-keys/send-your-data-api-key/index.md).
1. [Create an active AWS account](https://docs.aws.amazon.com/accounts/latest/reference/manage-acct-creating.html) with permissions to manage Lambda functions. Log in to your account as administrator.
1. Save the script for the AWS CloudFormation template on your desktop or in an S3 bucket.

## Configuration

### Create a Stack

1. Navigate to CloudFormation Page and click **Create Stack** (with new resources).

   Note

   AWS CloudFormation may create IAM resources.

1. Under the Stack option tab, select **Template is ready**. Upload a .yaml file from your S3 bucket or desktop, as in the example below.

   ```yaml
   Resources:
       LambdaFunction:
           Type: 'AWS::Lambda::Function'
           Properties:
           FunctionName: AwsLambdaExample
           Handler: index.handler
           Runtime: nodejs20.x
           Role: !GetAtt LambdaFunctionRole.Arn
           MemorySize: 1024
           Code:
               ZipFile: |
               exports.handler = async (event) => {
                   return "Hello World!";
               };
       LambdaFunctionRole:
           Type: 'AWS::IAM::Role'
           Properties:
           AssumeRolePolicyDocument:
               Version: '2012-10-17'
               Statement:
               - Effect: Allow
                   Principal:
                   Service:
                       - lambda.amazonaws.com
                   Action:
                   - sts:AssumeRole
           Path: "/"
           Policies:
               - PolicyName: AppendToLogsPolicy
               PolicyDocument:
                   Version: '2012-10-17'
                   Statement:
                   - Effect: Allow
                       Action:
                       - logs:CreateLogGroup
                       - logs:CreateLogStream
                       - logs:PutLogEvents
                       Resource: "*"
   ```

1. Click **Next** and define your stack name.

1. No other changes are required. Click **Next** and submit the stack.

### API Destination

1. Navigate to [Amazon EventBridge](https://aws.amazon.com/eventbridge/) and click **Create API destination** in the API Destination section.
1. Define the name.
1. Choose the https://ingress.\[[DOMAIN_VALUE]\]/aws/event-bridge endpoint that corresponds to your Coralogix [domain](https://coralogix.com/docs/user-guides/account-management/account-settings/coralogix-domain/index.md) using the domain selector at the top of the page.
1. HTTP Method: POST
1. Invocation rate limit per second – 300 sec
1. Select API Key as your **Authorization type**.
1. Name your API key **x-amz-event-bridge-access-key**.
1. The value of your API key will be your Coralogix [Send Your Data - API Key](https://coralogix.com/docs/user-guides/account-management/api-keys/send-your-data-api-key/index.md).

### Create a Rule in Amazon EventBridge

1. Name your Rule CoralogixRule. Leave all other settings as is. Click **Next**.

1. Select **All Events**.

   Note

   This may affect customer AWS billing.

1. Click **Next**.

1. In the Target, select **EventBridge API destination** and input the destination previously configured.

1. Click **Next** to the create the rule.

## Validation

View your logs, together with the Lambda execution, in your Coralogix dashboard.

## Additional resources

|                     |                                                                                             |
| ------------------- | ------------------------------------------------------------------------------------------- |
| Coralogix Endpoints | [Coralogix Endpoints](https://coralogix.com/docs/integrations/coralogix-endpoints/index.md) |

## Support

**Need help?**

Our world-class customer success team is available 24/7 to walk you through your setup and answer any questions that may come up.

Feel free to reach out to us **via our in-app chat** or by sending us an email at [support@coralogix.com](mailto:support@coralogix.com).
