Skip to content
GitHubXDiscord

Delivery

The Delivery resource enables you to configure AWS Logs Delivery for managing and directing log data to specified destinations. For more details, refer to the AWS Logs Delivery documentation.

This example demonstrates how to create a basic Logs Delivery configuration with required properties and one optional property.

import AWS from "alchemy/aws/control";
const logsDelivery = await AWS.Logs.Delivery("basicLogsDelivery", {
DeliveryDestinationArn: "arn:aws:s3:::my-logs-bucket",
DeliverySourceName: "MyApplicationLogs",
S3EnableHiveCompatiblePath: true
});

In this example, we configure Logs Delivery with additional options such as field delimiter and tags for better organization.

const advancedLogsDelivery = await AWS.Logs.Delivery("advancedLogsDelivery", {
DeliveryDestinationArn: "arn:aws:s3:::my-logs-bucket",
DeliverySourceName: "MyApplicationLogs",
FieldDelimiter: ",",
RecordFields: ["timestamp", "logLevel", "message"],
Tags: [
{ Key: "Environment", Value: "Production" },
{ Key: "Application", Value: "WebApp" }
]
});

This example shows how to customize the S3 path for log storage by specifying a suffix path.

const customPathLogsDelivery = await AWS.Logs.Delivery("customPathLogsDelivery", {
DeliveryDestinationArn: "arn:aws:s3:::my-logs-bucket",
DeliverySourceName: "MyApplicationLogs",
S3SuffixPath: "logs/yyyy/MM/dd/"
});

In this example, we demonstrate how to adopt an existing Logs Delivery resource instead of failing if it already exists.

const adoptExistingLogsDelivery = await AWS.Logs.Delivery("adoptExistingLogsDelivery", {
DeliveryDestinationArn: "arn:aws:s3:::my-logs-bucket",
DeliverySourceName: "MyApplicationLogs",
adopt: true
});