UNPKG

@pulumi/aws

Version:

A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.

183 lines 6.5 kB
"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! *** Object.defineProperty(exports, "__esModule", { value: true }); exports.EventBusPolicy = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * Provides a resource to create an EventBridge resource policy to support cross-account events. * * > **Note:** EventBridge was formerly known as CloudWatch Events. The functionality is identical. * * > **Note:** The EventBridge bus policy resource (`aws.cloudwatch.EventBusPolicy`) is incompatible with the EventBridge permission resource (`aws.cloudwatch.EventPermission`) and will overwrite permissions. * * ## Example Usage * * ### Account Access * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const test = aws.iam.getPolicyDocument({ * statements: [{ * sid: "DevAccountAccess", * effect: "Allow", * actions: ["events:PutEvents"], * resources: ["arn:aws:events:eu-west-1:123456789012:event-bus/default"], * principals: [{ * type: "AWS", * identifiers: ["123456789012"], * }], * }], * }); * const testEventBusPolicy = new aws.cloudwatch.EventBusPolicy("test", { * policy: test.then(test => test.json), * eventBusName: testAwsCloudwatchEventBus.name, * }); * ``` * * ### Organization Access * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const test = aws.iam.getPolicyDocument({ * statements: [{ * sid: "OrganizationAccess", * effect: "Allow", * actions: [ * "events:DescribeRule", * "events:ListRules", * "events:ListTargetsByRule", * "events:ListTagsForResource", * ], * resources: [ * "arn:aws:events:eu-west-1:123456789012:rule/*", * "arn:aws:events:eu-west-1:123456789012:event-bus/default", * ], * principals: [{ * type: "AWS", * identifiers: ["*"], * }], * conditions: [{ * test: "StringEquals", * variable: "aws:PrincipalOrgID", * values: [example.id], * }], * }], * }); * const testEventBusPolicy = new aws.cloudwatch.EventBusPolicy("test", { * policy: test.then(test => test.json), * eventBusName: testAwsCloudwatchEventBus.name, * }); * ``` * * ### Multiple Statements * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const test = aws.iam.getPolicyDocument({ * statements: [ * { * sid: "DevAccountAccess", * effect: "Allow", * actions: ["events:PutEvents"], * resources: ["arn:aws:events:eu-west-1:123456789012:event-bus/default"], * principals: [{ * type: "AWS", * identifiers: ["123456789012"], * }], * }, * { * sid: "OrganizationAccess", * effect: "Allow", * actions: [ * "events:DescribeRule", * "events:ListRules", * "events:ListTargetsByRule", * "events:ListTagsForResource", * ], * resources: [ * "arn:aws:events:eu-west-1:123456789012:rule/*", * "arn:aws:events:eu-west-1:123456789012:event-bus/default", * ], * principals: [{ * type: "AWS", * identifiers: ["*"], * }], * conditions: [{ * test: "StringEquals", * variable: "aws:PrincipalOrgID", * values: [example.id], * }], * }, * ], * }); * const testEventBusPolicy = new aws.cloudwatch.EventBusPolicy("test", { * policy: test.then(test => test.json), * eventBusName: testAwsCloudwatchEventBus.name, * }); * ``` * * ## Import * * Using `pulumi import`, import an EventBridge policy using the `event_bus_name`. For example: * * ```sh * $ pulumi import aws:cloudwatch/eventBusPolicy:EventBusPolicy DevAccountAccess example-event-bus * ``` */ class EventBusPolicy extends pulumi.CustomResource { /** * Get an existing EventBusPolicy 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 EventBusPolicy(name, state, { ...opts, id: id }); } /** * Returns true if the given object is an instance of EventBusPolicy. 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'] === EventBusPolicy.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["eventBusName"] = state?.eventBusName; resourceInputs["policy"] = state?.policy; resourceInputs["region"] = state?.region; } else { const args = argsOrState; if (args?.policy === undefined && !opts.urn) { throw new Error("Missing required property 'policy'"); } resourceInputs["eventBusName"] = args?.eventBusName; resourceInputs["policy"] = args?.policy; resourceInputs["region"] = args?.region; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(EventBusPolicy.__pulumiType, name, resourceInputs, opts); } } exports.EventBusPolicy = EventBusPolicy; /** @internal */ EventBusPolicy.__pulumiType = 'aws:cloudwatch/eventBusPolicy:EventBusPolicy'; //# sourceMappingURL=eventBusPolicy.js.map