import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; /** * Provides a CloudFront real-time log configuration resource. * * ## Example Usage * * ### Basic Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const assumeRole = aws.iam.getPolicyDocument({ * statements: [{ * principals: [{ * type: "Service", * identifiers: ["cloudfront.amazonaws.com"], * }], * effect: "Allow", * actions: ["sts:AssumeRole"], * }], * }); * const exampleRole = new aws.iam.Role("example", { * name: "cloudfront-realtime-log-config-example", * assumeRolePolicy: assumeRole.then(assumeRole => assumeRole.json), * }); * const example = aws.iam.getPolicyDocument({ * statements: [{ * effect: "Allow", * actions: [ * "kinesis:DescribeStreamSummary", * "kinesis:DescribeStream", * "kinesis:PutRecord", * "kinesis:PutRecords", * ], * resources: [exampleAwsKinesisStream.arn], * }], * }); * const exampleRolePolicy = new aws.iam.RolePolicy("example", { * name: "cloudfront-realtime-log-config-example", * role: exampleRole.id, * policy: example.then(example => example.json), * }); * const exampleRealtimeLogConfig = new aws.cloudfront.RealtimeLogConfig("example", { * endpoint: { * kinesisStreamConfig: { * roleArn: exampleRole.arn, * streamArn: exampleAwsKinesisStream.arn, * }, * streamType: "Kinesis", * }, * name: "example", * samplingRate: 75, * fields: [ * "timestamp", * "c-ip", * ], * }, { * dependsOn: [exampleRolePolicy], * }); * ``` * * ### Logging Custom Data From a CloudFront Function * * A viewer request or viewer response CloudFront Function can write arbitrary data into the log record for the request by calling the `cf.logCustomData()` helper method, which requires JavaScript runtime 2.0 (`cloudfront-js-2.0`) and the `cloudfront` module. The data is surfaced in the `viewer-request-log-data` and `viewer-response-log-data` fields, which must be selected in the real-time log configuration for them to be delivered. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.cloudfront.Function("example", { * name: "tag-request", * runtime: "cloudfront-js-2.0", * publish: true, * code: `import cf from 'cloudfront'; * * function handler(event) { * var variant = event.request.uri.indexOf(\\"/beta\\") === 0 ? \\"b\\" : \\"a\\"; * cf.logCustomData(\\"variant=\\" + variant); * return event.request; * } * `, * }); * const exampleRealtimeLogConfig = new aws.cloudfront.RealtimeLogConfig("example", { * endpoint: { * kinesisStreamConfig: { * roleArn: exampleAwsIamRole.arn, * streamArn: exampleAwsKinesisStream.arn, * }, * streamType: "Kinesis", * }, * name: "example", * samplingRate: 100, * fields: [ * "timestamp", * "c-ip", * "sc-status", * "viewer-request-log-data", * "viewer-response-log-data", * ], * }, { * dependsOn: [exampleAwsIamRolePolicy], * }); * ``` * * Associate the function with a cache behavior on the distribution (`functionAssociation` with `eventType = "viewer-request"`) and attach the real-time log configuration to the same cache behavior via `realtimeLogConfigArn`. The field is `-` for any request whose viewer request or viewer response function did not call `cf.logCustomData()`. * * ## Import * * ### Identity Schema * * #### Required * * - `arn` (String) ARN of the CloudFront real-time log configuration. * * Using `pulumi import`, import CloudFront real-time log configurations using the ARN. For example: * * ```sh * $ pulumi import aws:cloudfront/realtimeLogConfig:RealtimeLogConfig example arn:aws:cloudfront::111122223333:realtime-log-config/ExampleNameForRealtimeLogConfig * ``` */ export declare class RealtimeLogConfig extends pulumi.CustomResource { /** * Get an existing RealtimeLogConfig resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state Any extra arguments used during the lookup. * @param opts Optional settings to control the behavior of the CustomResource. */ static get(name: string, id: pulumi.Input, state?: RealtimeLogConfigState, opts?: pulumi.CustomResourceOptions): RealtimeLogConfig; /** * Returns true if the given object is an instance of RealtimeLogConfig. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj: any): obj is RealtimeLogConfig; /** * ARN of the CloudFront real-time log configuration. */ readonly arn: pulumi.Output; /** * The Amazon Kinesis data streams where real-time log data is sent. */ readonly endpoint: pulumi.Output; /** * The fields that are included in each real-time log record. See the [AWS documentation](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/real-time-logs.html#understand-real-time-log-config-fields) for supported values. This includes `viewer-request-log-data` and `viewer-response-log-data`, which carry the custom data that a CloudFront Function logs with `cf.logCustomData()`. */ readonly fields: pulumi.Output; /** * The unique name to identify this real-time log configuration. */ readonly name: pulumi.Output; /** * The sampling rate for this real-time log configuration. The sampling rate determines the percentage of viewer requests that are represented in the real-time log data. An integer between `1` and `100`, inclusive. */ readonly samplingRate: pulumi.Output; /** * Create a RealtimeLogConfig resource with the given unique name, arguments, and options. * * @param name The _unique_ name of the resource. * @param args The arguments to use to populate this resource's properties. * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args: RealtimeLogConfigArgs, opts?: pulumi.CustomResourceOptions); } /** * Input properties used for looking up and filtering RealtimeLogConfig resources. */ export interface RealtimeLogConfigState { /** * ARN of the CloudFront real-time log configuration. */ arn?: pulumi.Input; /** * The Amazon Kinesis data streams where real-time log data is sent. */ endpoint?: pulumi.Input; /** * The fields that are included in each real-time log record. See the [AWS documentation](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/real-time-logs.html#understand-real-time-log-config-fields) for supported values. This includes `viewer-request-log-data` and `viewer-response-log-data`, which carry the custom data that a CloudFront Function logs with `cf.logCustomData()`. */ fields?: pulumi.Input[] | undefined>; /** * The unique name to identify this real-time log configuration. */ name?: pulumi.Input; /** * The sampling rate for this real-time log configuration. The sampling rate determines the percentage of viewer requests that are represented in the real-time log data. An integer between `1` and `100`, inclusive. */ samplingRate?: pulumi.Input; } /** * The set of arguments for constructing a RealtimeLogConfig resource. */ export interface RealtimeLogConfigArgs { /** * The Amazon Kinesis data streams where real-time log data is sent. */ endpoint: pulumi.Input; /** * The fields that are included in each real-time log record. See the [AWS documentation](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/real-time-logs.html#understand-real-time-log-config-fields) for supported values. This includes `viewer-request-log-data` and `viewer-response-log-data`, which carry the custom data that a CloudFront Function logs with `cf.logCustomData()`. */ fields: pulumi.Input[]>; /** * The unique name to identify this real-time log configuration. */ name?: pulumi.Input; /** * The sampling rate for this real-time log configuration. The sampling rate determines the percentage of viewer requests that are represented in the real-time log data. An integer between `1` and `100`, inclusive. */ samplingRate: pulumi.Input; } //# sourceMappingURL=realtimeLogConfig.d.ts.map