How do I build an AWS CloudWatch Log Group?
To create an AWS CloudWatch Log Group using Pulumi, you can use the aws.cloudwatch.LogGroup
resource. Below is a TypeScript program that demonstrates how to define and create a CloudWatch Log Group in AWS.
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
// Create a CloudWatch Log Group
const logGroup = new aws.cloudwatch.LogGroup("my-log-group", {
name: "my-log-group",
retentionInDays: 14, // Retain logs for 14 days
});
// Export the name of the log group
export const logGroupName = logGroup.name;
This program does the following:
- Imports the necessary Pulumi and AWS packages.
- Creates a CloudWatch Log Group named “my-log-group” with a retention period of 14 days.
- Exports the name of the created log group.
In summary, this program demonstrates how to create and manage an AWS CloudWatch Log Group using Pulumi, including setting a retention policy for the logs.
Deploy this code
Want to deploy this code? Sign up for a free Pulumi account to deploy in a few clicks.
Sign upNew to Pulumi?
Want to deploy this code? Sign up with Pulumi to deploy in a few clicks.
Sign upThank you for your feedback!
If you have a question about how to use Pulumi, reach out in Community Slack.
Open an issue on GitHub to report a problem or suggest an improvement.