"use strict";
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.EventBus = void 0;
const pulumi = __importStar(require("@pulumi/pulumi"));
const utilities = __importStar(require("../utilities"));
/**
 * Provides an EventBridge event bus resource.
 *
 * > **Note:** EventBridge was formerly known as CloudWatch Events. The functionality is identical.
 *
 * ## Example Usage
 *
 * ### Basic Usages
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as aws from "@pulumi/aws";
 *
 * const messenger = new aws.cloudwatch.EventBus("messenger", {name: "chat-messages"});
 * ```
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as aws from "@pulumi/aws";
 *
 * const examplepartner = aws.cloudwatch.getEventSource({
 *     namePrefix: "aws.partner/examplepartner.com",
 * });
 * const examplepartnerEventBus = new aws.cloudwatch.EventBus("examplepartner", {
 *     name: examplepartner.then(examplepartner => examplepartner.name),
 *     description: "Event bus for example partner events",
 *     eventSourceName: examplepartner.then(examplepartner => examplepartner.name),
 * });
 * ```
 *
 * ### Logging to CloudWatch Logs, S3, and Data Firehose
 *
 * See [Configuring logs for Amazon EventBridge event buses](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-event-bus-logs.html) for more details.
 *
 * #### Required Resources
 *
 * * EventBridge Event Bus with `logConfig` configured
 * * Log destinations:
 *
 *     * CloudWatch Logs log group
 *     * S3 bucket
 *     * Data Firehose delivery stream
 *
 * * Resource-based policy or tagging for the service-linked role:
 *
 *     * CloudWatch Logs log group - `aws.cloudwatch.LogResourcePolicy` to allow `delivery.logs.amazonaws.com` to put logs into the log group
 *     * S3 bucket - `aws.s3.BucketPolicy` to allow `delivery.logs.amazonaws.com` to put logs into the bucket
 *     * Data Firehose delivery stream - tagging the delivery stream with `LogDeliveryEnabled = "true"` to allow the service-linked role `AWSServiceRoleForLogDelivery` to deliver logs
 *
 * * CloudWatch Logs Delivery:
 *
 *     * `aws.cloudwatch.LogDeliverySource` for each log type (INFO, ERROR, TRACE)
 *     * `aws.cloudwatch.LogDeliveryDestination` for the log destination (S3 bucket, CloudWatch Logs log group, or Data Firehose delivery stream)
 *     * `aws.cloudwatch.LogDelivery` to link each log type’s delivery source to the delivery destination
 *
 * ### Example Usage
 *
 * The following example demonstrates how to set up logging for an EventBridge event bus to all three destinations: CloudWatch Logs, S3, and Data Firehose.
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as aws from "@pulumi/aws";
 *
 * const current = aws.getCallerIdentity({});
 * const example = new aws.cloudwatch.EventBus("example", {
 *     name: "example-event-bus",
 *     logConfig: {
 *         includeDetail: "FULL",
 *         level: "TRACE",
 *     },
 * });
 * // CloudWatch Log Delivery Sources for INFO, ERROR, and TRACE logs
 * const infoLogs = new aws.cloudwatch.LogDeliverySource("info_logs", {
 *     name: pulumi.interpolate`EventBusSource-${example.name}-INFO_LOGS`,
 *     logType: "INFO_LOGS",
 *     resourceArn: example.arn,
 * });
 * const errorLogs = new aws.cloudwatch.LogDeliverySource("error_logs", {
 *     name: pulumi.interpolate`EventBusSource-${example.name}-ERROR_LOGS`,
 *     logType: "ERROR_LOGS",
 *     resourceArn: example.arn,
 * });
 * const traceLogs = new aws.cloudwatch.LogDeliverySource("trace_logs", {
 *     name: pulumi.interpolate`EventBusSource-${example.name}-TRACE_LOGS`,
 *     logType: "TRACE_LOGS",
 *     resourceArn: example.arn,
 * });
 * // Logging to S3 Bucket
 * const exampleBucket = new aws.s3.Bucket("example", {bucket: "example-event-bus-logs"});
 * const bucket = aws.iam.getPolicyDocumentOutput({
 *     statements: [{
 *         effect: "Allow",
 *         principals: [{
 *             type: "Service",
 *             identifiers: ["delivery.logs.amazonaws.com"],
 *         }],
 *         actions: ["s3:PutObject"],
 *         resources: [Promise.all([exampleBucket.arn, current]).then(([arn, current]) => `${arn}/AWSLogs/${current.accountId}/EventBusLogs/*`)],
 *         conditions: [
 *             {
 *                 test: "StringEquals",
 *                 variable: "s3:x-amz-acl",
 *                 values: ["bucket-owner-full-control"],
 *             },
 *             {
 *                 test: "StringEquals",
 *                 variable: "aws:SourceAccount",
 *                 values: [current.then(current => current.accountId)],
 *             },
 *             {
 *                 test: "ArnLike",
 *                 variable: "aws:SourceArn",
 *                 values: [
 *                     infoLogs.arn,
 *                     errorLogs.arn,
 *                     traceLogs.arn,
 *                 ],
 *             },
 *         ],
 *     }],
 * });
 * const exampleBucketPolicy = new aws.s3.BucketPolicy("example", {
 *     bucket: exampleBucket.bucket,
 *     policy: bucket.apply(bucket => bucket.json),
 * });
 * const s3 = new aws.cloudwatch.LogDeliveryDestination("s3", {
 *     name: pulumi.interpolate`EventsDeliveryDestination-${example.name}-S3`,
 *     deliveryDestinationConfiguration: {
 *         destinationResourceArn: exampleBucket.arn,
 *     },
 * });
 * const s3InfoLogs = new aws.cloudwatch.LogDelivery("s3_info_logs", {
 *     deliveryDestinationArn: s3.arn,
 *     deliverySourceName: infoLogs.name,
 * });
 * const s3ErrorLogs = new aws.cloudwatch.LogDelivery("s3_error_logs", {
 *     deliveryDestinationArn: s3.arn,
 *     deliverySourceName: errorLogs.name,
 * }, {
 *     dependsOn: [s3InfoLogs],
 * });
 * const s3TraceLogs = new aws.cloudwatch.LogDelivery("s3_trace_logs", {
 *     deliveryDestinationArn: s3.arn,
 *     deliverySourceName: traceLogs.name,
 * }, {
 *     dependsOn: [s3ErrorLogs],
 * });
 * // Logging to CloudWatch Log Group
 * const eventBusLogs = new aws.cloudwatch.LogGroup("event_bus_logs", {name: pulumi.interpolate`/aws/vendedlogs/events/event-bus/${example.name}`});
 * const cwlogs = aws.iam.getPolicyDocumentOutput({
 *     statements: [{
 *         effect: "Allow",
 *         principals: [{
 *             type: "Service",
 *             identifiers: ["delivery.logs.amazonaws.com"],
 *         }],
 *         actions: [
 *             "logs:CreateLogStream",
 *             "logs:PutLogEvents",
 *         ],
 *         resources: [pulumi.interpolate`${eventBusLogs.arn}:log-stream:*`],
 *         conditions: [
 *             {
 *                 test: "StringEquals",
 *                 variable: "aws:SourceAccount",
 *                 values: [current.then(current => current.accountId)],
 *             },
 *             {
 *                 test: "ArnLike",
 *                 variable: "aws:SourceArn",
 *                 values: [
 *                     infoLogs.arn,
 *                     errorLogs.arn,
 *                     traceLogs.arn,
 *                 ],
 *             },
 *         ],
 *     }],
 * });
 * const exampleLogResourcePolicy = new aws.cloudwatch.LogResourcePolicy("example", {
 *     policyDocument: cwlogs.apply(cwlogs => cwlogs.json),
 *     policyName: pulumi.interpolate`AWSLogDeliveryWrite-${example.name}`,
 * });
 * const cwlogsLogDeliveryDestination = new aws.cloudwatch.LogDeliveryDestination("cwlogs", {
 *     name: pulumi.interpolate`EventsDeliveryDestination-${example.name}-CWLogs`,
 *     deliveryDestinationConfiguration: {
 *         destinationResourceArn: eventBusLogs.arn,
 *     },
 * });
 * const cwlogsInfoLogs = new aws.cloudwatch.LogDelivery("cwlogs_info_logs", {
 *     deliveryDestinationArn: cwlogsLogDeliveryDestination.arn,
 *     deliverySourceName: infoLogs.name,
 * }, {
 *     dependsOn: [s3InfoLogs],
 * });
 * const cwlogsErrorLogs = new aws.cloudwatch.LogDelivery("cwlogs_error_logs", {
 *     deliveryDestinationArn: cwlogsLogDeliveryDestination.arn,
 *     deliverySourceName: errorLogs.name,
 * }, {
 *     dependsOn: [
 *         s3ErrorLogs,
 *         cwlogsInfoLogs,
 *     ],
 * });
 * const cwlogsTraceLogs = new aws.cloudwatch.LogDelivery("cwlogs_trace_logs", {
 *     deliveryDestinationArn: cwlogsLogDeliveryDestination.arn,
 *     deliverySourceName: traceLogs.name,
 * }, {
 *     dependsOn: [
 *         s3TraceLogs,
 *         cwlogsErrorLogs,
 *     ],
 * });
 * // Logging to Data Firehose
 * const cloudfrontLogs = new aws.kinesis.FirehoseDeliveryStream("cloudfront_logs", {tags: {
 *     LogDeliveryEnabled: "true",
 * }});
 * const firehose = new aws.cloudwatch.LogDeliveryDestination("firehose", {
 *     name: pulumi.interpolate`EventsDeliveryDestination-${example.name}-Firehose`,
 *     deliveryDestinationConfiguration: {
 *         destinationResourceArn: cloudfrontLogs.arn,
 *     },
 * });
 * const firehoseInfoLogs = new aws.cloudwatch.LogDelivery("firehose_info_logs", {
 *     deliveryDestinationArn: firehose.arn,
 *     deliverySourceName: infoLogs.name,
 * }, {
 *     dependsOn: [cwlogsInfoLogs],
 * });
 * const firehoseErrorLogs = new aws.cloudwatch.LogDelivery("firehose_error_logs", {
 *     deliveryDestinationArn: firehose.arn,
 *     deliverySourceName: errorLogs.name,
 * }, {
 *     dependsOn: [
 *         cwlogsErrorLogs,
 *         firehoseInfoLogs,
 *     ],
 * });
 * const firehoseTraceLogs = new aws.cloudwatch.LogDelivery("firehose_trace_logs", {
 *     deliveryDestinationArn: firehose.arn,
 *     deliverySourceName: traceLogs.name,
 * }, {
 *     dependsOn: [
 *         cwlogsTraceLogs,
 *         firehoseErrorLogs,
 *     ],
 * });
 * ```
 *
 * ## Import
 *
 * Using `pulumi import`, import EventBridge event buses using the name of the event bus (which can also be a partner event source name). For example:
 *
 * ```sh
 * $ pulumi import aws:cloudwatch/eventBus:EventBus messenger chat-messages
 * ```
 */
class EventBus extends pulumi.CustomResource {
    /**
     * Get an existing EventBus 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, id, state, opts) {
        return new EventBus(name, state, { ...opts, id: id });
    }
    /** @internal */
    static __pulumiType = 'aws:cloudwatch/eventBus:EventBus';
    /**
     * Returns true if the given object is an instance of EventBus.  This is designed to work even
     * when multiple copies of the Pulumi SDK have been loaded into the same process.
     */
    static isInstance(obj) {
        if (obj === undefined || obj === null) {
            return false;
        }
        return obj['__pulumiType'] === EventBus.__pulumiType;
    }
    constructor(name, argsOrState, opts) {
        let resourceInputs = {};
        opts = opts || {};
        if (opts.id) {
            const state = argsOrState;
            resourceInputs["arn"] = state?.arn;
            resourceInputs["deadLetterConfig"] = state?.deadLetterConfig;
            resourceInputs["description"] = state?.description;
            resourceInputs["eventSourceName"] = state?.eventSourceName;
            resourceInputs["kmsKeyIdentifier"] = state?.kmsKeyIdentifier;
            resourceInputs["logConfig"] = state?.logConfig;
            resourceInputs["name"] = state?.name;
            resourceInputs["region"] = state?.region;
            resourceInputs["tags"] = state?.tags;
            resourceInputs["tagsAll"] = state?.tagsAll;
        }
        else {
            const args = argsOrState;
            resourceInputs["deadLetterConfig"] = args?.deadLetterConfig;
            resourceInputs["description"] = args?.description;
            resourceInputs["eventSourceName"] = args?.eventSourceName;
            resourceInputs["kmsKeyIdentifier"] = args?.kmsKeyIdentifier;
            resourceInputs["logConfig"] = args?.logConfig;
            resourceInputs["name"] = args?.name;
            resourceInputs["region"] = args?.region;
            resourceInputs["tags"] = args?.tags;
            resourceInputs["arn"] = undefined /*out*/;
            resourceInputs["tagsAll"] = undefined /*out*/;
        }
        opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
        super(EventBus.__pulumiType, name, resourceInputs, opts);
    }
}
exports.EventBus = EventBus;
//# sourceMappingURL=eventBus.js.map