LogDelivery class

Resource for managing an AWS CloudWatch Logs Delivery. A delivery is a connection between an aws.cloudwatch.LogDeliverySource and an aws.cloudwatch.LogDeliveryDestination.

Example Usage

Basic Usage

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const example = new aws.cloudwatch.LogDelivery("example", {
    deliverySourceName: exampleAwsCloudwatchLogDeliverySource.name,
    deliveryDestinationArn: exampleAwsCloudwatchLogDeliveryDestination.arn,
    fieldDelimiter: ",",
    recordFields: [
        "event_timestamp",
        "event",
    ],
});
import pulumi
import pulumi_aws as aws

example = aws.cloudwatch.LogDelivery("example",
    delivery_source_name=example_aws_cloudwatch_log_delivery_source["name"],
    delivery_destination_arn=example_aws_cloudwatch_log_delivery_destination["arn"],
    field_delimiter=",",
    record_fields=[
        "event_timestamp",
        "event",
    ])
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() =>
{
    var example = new Aws.CloudWatch.LogDelivery("example", new()
    {
        DeliverySourceName = exampleAwsCloudwatchLogDeliverySource.Name,
        DeliveryDestinationArn = exampleAwsCloudwatchLogDeliveryDestination.Arn,
        FieldDelimiter = ",",
        RecordFields = new[]
        {
            "event_timestamp",
            "event",
        },
    });

});
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/cloudwatch"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := cloudwatch.NewLogDelivery(ctx, "example", &cloudwatch.LogDeliveryArgs{
			DeliverySourceName:     pulumi.Any(exampleAwsCloudwatchLogDeliverySource.Name),
			DeliveryDestinationArn: pulumi.Any(exampleAwsCloudwatchLogDeliveryDestination.Arn),
			FieldDelimiter:         pulumi.String(","),
			RecordFields: pulumi.StringArray{
				pulumi.String("event_timestamp"),
				pulumi.String("event"),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

resource "aws_cloudwatch_logdelivery" "example" {
  delivery_source_name     = exampleAwsCloudwatchLogDeliverySource.name
  delivery_destination_arn = exampleAwsCloudwatchLogDeliveryDestination.arn
  field_delimiter          = ","
  record_fields            = ["event_timestamp", "event"]
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.cloudwatch.LogDelivery;
import com.pulumi.aws.cloudwatch.LogDeliveryArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var example = new LogDelivery("example", LogDeliveryArgs.builder()
            .deliverySourceName(exampleAwsCloudwatchLogDeliverySource.name())
            .deliveryDestinationArn(exampleAwsCloudwatchLogDeliveryDestination.arn())
            .fieldDelimiter(",")
            .recordFields(
                "event_timestamp",
                "event")
            .build());

    }
}
resources:
  example:
    type: aws:cloudwatch:LogDelivery
    properties:
      deliverySourceName: ${exampleAwsCloudwatchLogDeliverySource.name}
      deliveryDestinationArn: ${exampleAwsCloudwatchLogDeliveryDestination.arn}
      fieldDelimiter: ','
      recordFields:
        - event_timestamp
        - event

CloudFront Standard Logging (v2)

CloudFront delivers access logs through CloudWatch Logs, so a distribution's standard logging (v2) configuration is expressed as a delivery source, a delivery destination, and a delivery. The recordFields list selects the access log fields, including viewer-request-log-data and viewer-response-log-data, which carry the custom data that a viewer request or viewer response CloudFront Function logs with cf.logCustomData().

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const example = new aws.cloudwatch.LogDeliverySource("example", {
    name: "cloudfront-access-logs",
    logType: "ACCESS_LOGS",
    resourceArn: exampleAwsCloudfrontDistribution.arn,
});
const exampleLogDeliveryDestination = new aws.cloudwatch.LogDeliveryDestination("example", {
    deliveryDestinationConfiguration: {
        destinationResourceArn: exampleAwsCloudwatchLogGroup.arn,
    },
    name: "cloudfront-access-logs",
    outputFormat: "json",
});
const exampleLogDelivery = new aws.cloudwatch.LogDelivery("example", {
    deliverySourceName: example.name,
    deliveryDestinationArn: exampleLogDeliveryDestination.arn,
    recordFields: [
        "date",
        "time",
        "c-ip",
        "sc-status",
        "viewer-request-log-data",
        "viewer-response-log-data",
    ],
});
import pulumi
import pulumi_aws as aws

example = aws.cloudwatch.LogDeliverySource("example",
    name="cloudfront-access-logs",
    log_type="ACCESS_LOGS",
    resource_arn=example_aws_cloudfront_distribution["arn"])
example_log_delivery_destination = aws.cloudwatch.LogDeliveryDestination("example",
    delivery_destination_configuration={
        "destination_resource_arn": example_aws_cloudwatch_log_group["arn"],
    },
    name="cloudfront-access-logs",
    output_format="json")
example_log_delivery = aws.cloudwatch.LogDelivery("example",
    delivery_source_name=example.name,
    delivery_destination_arn=example_log_delivery_destination.arn,
    record_fields=[
        "date",
        "time",
        "c-ip",
        "sc-status",
        "viewer-request-log-data",
        "viewer-response-log-data",
    ])
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() =>
{
    var example = new Aws.CloudWatch.LogDeliverySource("example", new()
    {
        Name = "cloudfront-access-logs",
        LogType = "ACCESS_LOGS",
        ResourceArn = exampleAwsCloudfrontDistribution.Arn,
    });

    var exampleLogDeliveryDestination = new Aws.CloudWatch.LogDeliveryDestination("example", new()
    {
        DeliveryDestinationConfiguration = new Aws.CloudWatch.Inputs.LogDeliveryDestinationDeliveryDestinationConfigurationArgs
        {
            DestinationResourceArn = exampleAwsCloudwatchLogGroup.Arn,
        },
        Name = "cloudfront-access-logs",
        OutputFormat = "json",
    });

    var exampleLogDelivery = new Aws.CloudWatch.LogDelivery("example", new()
    {
        DeliverySourceName = example.Name,
        DeliveryDestinationArn = exampleLogDeliveryDestination.Arn,
        RecordFields = new[]
        {
            "date",
            "time",
            "c-ip",
            "sc-status",
            "viewer-request-log-data",
            "viewer-response-log-data",
        },
    });

});
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/cloudwatch"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		example, err := cloudwatch.NewLogDeliverySource(ctx, "example", &cloudwatch.LogDeliverySourceArgs{
			Name:        pulumi.String("cloudfront-access-logs"),
			LogType:     pulumi.String("ACCESS_LOGS"),
			ResourceArn: pulumi.Any(exampleAwsCloudfrontDistribution.Arn),
		})
		if err != nil {
			return err
		}
		exampleLogDeliveryDestination, err := cloudwatch.NewLogDeliveryDestination(ctx, "example", &cloudwatch.LogDeliveryDestinationArgs{
			DeliveryDestinationConfiguration: &cloudwatch.LogDeliveryDestinationDeliveryDestinationConfigurationArgs{
				DestinationResourceArn: pulumi.Any(exampleAwsCloudwatchLogGroup.Arn),
			},
			Name:         pulumi.String("cloudfront-access-logs"),
			OutputFormat: pulumi.String("json"),
		})
		if err != nil {
			return err
		}
		_, err = cloudwatch.NewLogDelivery(ctx, "example", &cloudwatch.LogDeliveryArgs{
			DeliverySourceName:     example.Name,
			DeliveryDestinationArn: exampleLogDeliveryDestination.Arn,
			RecordFields: pulumi.StringArray{
				pulumi.String("date"),
				pulumi.String("time"),
				pulumi.String("c-ip"),
				pulumi.String("sc-status"),
				pulumi.String("viewer-request-log-data"),
				pulumi.String("viewer-response-log-data"),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

resource "aws_cloudwatch_logdeliverysource" "example" {
  name         = "cloudfront-access-logs"
  log_type     = "ACCESS_LOGS"
  resource_arn = exampleAwsCloudfrontDistribution.arn
}
resource "aws_cloudwatch_logdeliverydestination" "example" {
  delivery_destination_configuration = {
    destination_resource_arn = exampleAwsCloudwatchLogGroup.arn
  }
  name          = "cloudfront-access-logs"
  output_format = "json"
}
resource "aws_cloudwatch_logdelivery" "example" {
  delivery_source_name     = aws_cloudwatch_logdeliverysource.example.name
  delivery_destination_arn = aws_cloudwatch_logdeliverydestination.example.arn
  record_fields            = ["date", "time", "c-ip", "sc-status", "viewer-request-log-data", "viewer-response-log-data"]
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.cloudwatch.LogDeliverySource;
import com.pulumi.aws.cloudwatch.LogDeliverySourceArgs;
import com.pulumi.aws.cloudwatch.LogDeliveryDestination;
import com.pulumi.aws.cloudwatch.LogDeliveryDestinationArgs;
import com.pulumi.aws.cloudwatch.inputs.LogDeliveryDestinationDeliveryDestinationConfigurationArgs;
import com.pulumi.aws.cloudwatch.LogDelivery;
import com.pulumi.aws.cloudwatch.LogDeliveryArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var example = new LogDeliverySource("example", LogDeliverySourceArgs.builder()
            .name("cloudfront-access-logs")
            .logType("ACCESS_LOGS")
            .resourceArn(exampleAwsCloudfrontDistribution.arn())
            .build());

        var exampleLogDeliveryDestination = new LogDeliveryDestination("exampleLogDeliveryDestination", LogDeliveryDestinationArgs.builder()
            .deliveryDestinationConfiguration(LogDeliveryDestinationDeliveryDestinationConfigurationArgs.builder()
                .destinationResourceArn(exampleAwsCloudwatchLogGroup.arn())
                .build())
            .name("cloudfront-access-logs")
            .outputFormat("json")
            .build());

        var exampleLogDelivery = new LogDelivery("exampleLogDelivery", LogDeliveryArgs.builder()
            .deliverySourceName(example.name())
            .deliveryDestinationArn(exampleLogDeliveryDestination.arn())
            .recordFields(
                "date",
                "time",
                "c-ip",
                "sc-status",
                "viewer-request-log-data",
                "viewer-response-log-data")
            .build());

    }
}
resources:
  example:
    type: aws:cloudwatch:LogDeliverySource
    properties:
      name: cloudfront-access-logs
      logType: ACCESS_LOGS
      resourceArn: ${exampleAwsCloudfrontDistribution.arn}
  exampleLogDeliveryDestination:
    type: aws:cloudwatch:LogDeliveryDestination
    name: example
    properties:
      deliveryDestinationConfiguration:
        destinationResourceArn: ${exampleAwsCloudwatchLogGroup.arn}
      name: cloudfront-access-logs
      outputFormat: json
  exampleLogDelivery:
    type: aws:cloudwatch:LogDelivery
    name: example
    properties:
      deliverySourceName: ${example.name}
      deliveryDestinationArn: ${exampleLogDeliveryDestination.arn}
      recordFields:
        - date
        - time
        - c-ip
        - sc-status
        - viewer-request-log-data
        - viewer-response-log-data

Import

Identity Schema

Required

  • id (String) ID of the delivery.

Optional

  • accountId (String) AWS Account where this resource is managed.
  • region (String) Region where this resource is managed.

Using pulumi import, import Deliveries using id. For example:

$ pulumi import aws:cloudwatch/logDelivery:LogDelivery example jsoGVi4Zq8VlYp9n

Constructors

LogDelivery(String name, {LogDeliveryArgs? args, CustomResourceOptions? options})
Creates a new LogDelivery. name The Pulumi resource name. args Arguments used to configure this LogDelivery. The set of arguments for LogDelivery. options Resource options controlling this resource's behavior.
LogDelivery.reference(String urn)
Creates a typed reference to an existing LogDelivery resource.

Properties

arn ↔ Output<String>
ARN of the delivery.
latefinal
childResources → Set<Resource>
finalinherited
completionSources ↔ Map<String, IOutputCompletionSource>
latefinalinherited
deliveryDestinationArn ↔ Output<String>
The ARN of the delivery destination to use for this delivery.
latefinal
deliverySourceName ↔ Output<String>
The name of the delivery source to use for this delivery.
latefinal
fieldDelimiter ↔ Output<String>
The field delimiter to use between record fields when the final output format of a delivery is in plain, w3c, or raw format.
latefinal
hashCode → int
The hash code for this object.
no setterinherited
id ↔ Output<String>
getter/setter pairinherited
isCustom → bool
Returns whether this resource is provider-managed.
no setterinherited
isProtected → bool
Returns whether this resource is protected from deletion.
no setterinherited
isRemote → bool
Whether this resource is registered as remote.
no setterinherited
isResourceReference → bool
Whether this instance represents a resource value returned over RPC.
finalinherited
recordFields ↔ Output<List<String>>
The list of record fields to be delivered to the destination, in order. The valid field names vary by the logType of the delivery source. For a CloudFront ACCESS_LOGS source, see Configure standard logging (v2) for the supported values.
latefinal
region ↔ Output<String>
Region where this resource will be managed. Defaults to the Region set in the provider configuration.
latefinal
resourceTransforms → List<ResourceTransform>
Inherited/explicit async transforms.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
s3DeliveryConfigurations ↔ Output<List<LogDeliveryS3DeliveryConfiguration>>
Parameters that are valid only when the delivery's delivery destination is an S3 bucket.
latefinal
tags ↔ Output<Map<String, String>?>
A map of tags to assign to the resource. If configured with a provider defaultTags configuration block present, tags with matching keys will overwrite those defined at the provider-level.
latefinal
tagsAll ↔ Output<Map<String, String>>
A map of tags assigned to the resource, including those inherited from the provider defaultTags configuration block.
latefinal
transformations → List<ResourceTransformation>
Inherited/explicit legacy transformations.
no setterinherited
urn ↔ Output<String>
latefinalinherited

Methods

failId(Object error) → void
Completes this resource ID with an error when registration fails.
inherited
failOutputs(Object error) → void
Completes all output properties with error.
inherited
failUrn(Object error) → void
Completes this resource URN with an error when registration fails.
inherited
getProvider(String moduleMember) → ProviderResource?
Returns provider for moduleMember's package, if configured.
inherited
getResourceName() → String
Returns this resource's logical name.
inherited
getResourceType() → String
Returns this resource's Pulumi type token.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
registerOutput<T>(String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output<T>
Registers a dynamic output property for this resource.
inherited
resolveId(String? value, {required bool isKnown}) → void
Resolves the provider-assigned ID for this resource.
inherited
resolveOutputs(Struct outputs) → void
Resolves all output properties from a monitor response payload.
inherited
resolveUrn(String value) → void
Resolves this resource's URN once assigned by the engine.
inherited
serializeProperties(Map<String, dynamic> properties) → Future<Struct>
Serializes resource properties for RPC transmission.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

get(String name, Input<String> id, {LogDeliveryState? state, CustomResourceOptions? options}) → LogDelivery
Gets an existing LogDelivery resource's state with the given name and id.