1. Packages
  2. AWS Classic
  3. API Docs
  4. cloudwatch
  5. EventBusPolicy

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.41.0 published on Tuesday, Jun 18, 2024 by Pulumi

aws.cloudwatch.EventBusPolicy

Explore with Pulumi AI

aws logo

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.41.0 published on Tuesday, Jun 18, 2024 by Pulumi

    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

    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,
    });
    
    import pulumi
    import pulumi_aws as aws
    
    test = aws.iam.get_policy_document(statements=[aws.iam.GetPolicyDocumentStatementArgs(
        sid="DevAccountAccess",
        effect="Allow",
        actions=["events:PutEvents"],
        resources=["arn:aws:events:eu-west-1:123456789012:event-bus/default"],
        principals=[aws.iam.GetPolicyDocumentStatementPrincipalArgs(
            type="AWS",
            identifiers=["123456789012"],
        )],
    )])
    test_event_bus_policy = aws.cloudwatch.EventBusPolicy("test",
        policy=test.json,
        event_bus_name=test_aws_cloudwatch_event_bus["name"])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/cloudwatch"
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iam"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		test, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
    			Statements: []iam.GetPolicyDocumentStatement{
    				{
    					Sid:    pulumi.StringRef("DevAccountAccess"),
    					Effect: pulumi.StringRef("Allow"),
    					Actions: []string{
    						"events:PutEvents",
    					},
    					Resources: []string{
    						"arn:aws:events:eu-west-1:123456789012:event-bus/default",
    					},
    					Principals: []iam.GetPolicyDocumentStatementPrincipal{
    						{
    							Type: "AWS",
    							Identifiers: []string{
    								"123456789012",
    							},
    						},
    					},
    				},
    			},
    		}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = cloudwatch.NewEventBusPolicy(ctx, "test", &cloudwatch.EventBusPolicyArgs{
    			Policy:       pulumi.String(test.Json),
    			EventBusName: pulumi.Any(testAwsCloudwatchEventBus.Name),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var test = Aws.Iam.GetPolicyDocument.Invoke(new()
        {
            Statements = new[]
            {
                new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
                {
                    Sid = "DevAccountAccess",
                    Effect = "Allow",
                    Actions = new[]
                    {
                        "events:PutEvents",
                    },
                    Resources = new[]
                    {
                        "arn:aws:events:eu-west-1:123456789012:event-bus/default",
                    },
                    Principals = new[]
                    {
                        new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalInputArgs
                        {
                            Type = "AWS",
                            Identifiers = new[]
                            {
                                "123456789012",
                            },
                        },
                    },
                },
            },
        });
    
        var testEventBusPolicy = new Aws.CloudWatch.EventBusPolicy("test", new()
        {
            Policy = test.Apply(getPolicyDocumentResult => getPolicyDocumentResult.Json),
            EventBusName = testAwsCloudwatchEventBus.Name,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.iam.IamFunctions;
    import com.pulumi.aws.iam.inputs.GetPolicyDocumentArgs;
    import com.pulumi.aws.cloudwatch.EventBusPolicy;
    import com.pulumi.aws.cloudwatch.EventBusPolicyArgs;
    import java.util.List;
    import java.util.ArrayList;
    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) {
            final var test = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
                .statements(GetPolicyDocumentStatementArgs.builder()
                    .sid("DevAccountAccess")
                    .effect("Allow")
                    .actions("events:PutEvents")
                    .resources("arn:aws:events:eu-west-1:123456789012:event-bus/default")
                    .principals(GetPolicyDocumentStatementPrincipalArgs.builder()
                        .type("AWS")
                        .identifiers("123456789012")
                        .build())
                    .build())
                .build());
    
            var testEventBusPolicy = new EventBusPolicy("testEventBusPolicy", EventBusPolicyArgs.builder()
                .policy(test.applyValue(getPolicyDocumentResult -> getPolicyDocumentResult.json()))
                .eventBusName(testAwsCloudwatchEventBus.name())
                .build());
    
        }
    }
    
    resources:
      testEventBusPolicy:
        type: aws:cloudwatch:EventBusPolicy
        name: test
        properties:
          policy: ${test.json}
          eventBusName: ${testAwsCloudwatchEventBus.name}
    variables:
      test:
        fn::invoke:
          Function: aws:iam:getPolicyDocument
          Arguments:
            statements:
              - sid: DevAccountAccess
                effect: Allow
                actions:
                  - events:PutEvents
                resources:
                  - arn:aws:events:eu-west-1:123456789012:event-bus/default
                principals:
                  - type: AWS
                    identifiers:
                      - '123456789012'
    

    Organization Access

    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,
    });
    
    import pulumi
    import pulumi_aws as aws
    
    test = aws.iam.get_policy_document(statements=[aws.iam.GetPolicyDocumentStatementArgs(
        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=[aws.iam.GetPolicyDocumentStatementPrincipalArgs(
            type="AWS",
            identifiers=["*"],
        )],
        conditions=[aws.iam.GetPolicyDocumentStatementConditionArgs(
            test="StringEquals",
            variable="aws:PrincipalOrgID",
            values=[example["id"]],
        )],
    )])
    test_event_bus_policy = aws.cloudwatch.EventBusPolicy("test",
        policy=test.json,
        event_bus_name=test_aws_cloudwatch_event_bus["name"])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/cloudwatch"
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iam"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
    test, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
    Statements: []iam.GetPolicyDocumentStatement{
    {
    Sid: pulumi.StringRef("OrganizationAccess"),
    Effect: pulumi.StringRef("Allow"),
    Actions: []string{
    "events:DescribeRule",
    "events:ListRules",
    "events:ListTargetsByRule",
    "events:ListTagsForResource",
    },
    Resources: []string{
    "arn:aws:events:eu-west-1:123456789012:rule/*",
    "arn:aws:events:eu-west-1:123456789012:event-bus/default",
    },
    Principals: []iam.GetPolicyDocumentStatementPrincipal{
    {
    Type: "AWS",
    Identifiers: []string{
    "*",
    },
    },
    },
    Conditions: []iam.GetPolicyDocumentStatementCondition{
    {
    Test: "StringEquals",
    Variable: "aws:PrincipalOrgID",
    Values: interface{}{
    example.Id,
    },
    },
    },
    },
    },
    }, nil);
    if err != nil {
    return err
    }
    _, err = cloudwatch.NewEventBusPolicy(ctx, "test", &cloudwatch.EventBusPolicyArgs{
    Policy: pulumi.String(test.Json),
    EventBusName: pulumi.Any(testAwsCloudwatchEventBus.Name),
    })
    if err != nil {
    return err
    }
    return nil
    })
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var test = Aws.Iam.GetPolicyDocument.Invoke(new()
        {
            Statements = new[]
            {
                new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
                {
                    Sid = "OrganizationAccess",
                    Effect = "Allow",
                    Actions = new[]
                    {
                        "events:DescribeRule",
                        "events:ListRules",
                        "events:ListTargetsByRule",
                        "events:ListTagsForResource",
                    },
                    Resources = new[]
                    {
                        "arn:aws:events:eu-west-1:123456789012:rule/*",
                        "arn:aws:events:eu-west-1:123456789012:event-bus/default",
                    },
                    Principals = new[]
                    {
                        new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalInputArgs
                        {
                            Type = "AWS",
                            Identifiers = new[]
                            {
                                "*",
                            },
                        },
                    },
                    Conditions = new[]
                    {
                        new Aws.Iam.Inputs.GetPolicyDocumentStatementConditionInputArgs
                        {
                            Test = "StringEquals",
                            Variable = "aws:PrincipalOrgID",
                            Values = new[]
                            {
                                example.Id,
                            },
                        },
                    },
                },
            },
        });
    
        var testEventBusPolicy = new Aws.CloudWatch.EventBusPolicy("test", new()
        {
            Policy = test.Apply(getPolicyDocumentResult => getPolicyDocumentResult.Json),
            EventBusName = testAwsCloudwatchEventBus.Name,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.iam.IamFunctions;
    import com.pulumi.aws.iam.inputs.GetPolicyDocumentArgs;
    import com.pulumi.aws.cloudwatch.EventBusPolicy;
    import com.pulumi.aws.cloudwatch.EventBusPolicyArgs;
    import java.util.List;
    import java.util.ArrayList;
    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) {
            final var test = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
                .statements(GetPolicyDocumentStatementArgs.builder()
                    .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(GetPolicyDocumentStatementPrincipalArgs.builder()
                        .type("AWS")
                        .identifiers("*")
                        .build())
                    .conditions(GetPolicyDocumentStatementConditionArgs.builder()
                        .test("StringEquals")
                        .variable("aws:PrincipalOrgID")
                        .values(example.id())
                        .build())
                    .build())
                .build());
    
            var testEventBusPolicy = new EventBusPolicy("testEventBusPolicy", EventBusPolicyArgs.builder()
                .policy(test.applyValue(getPolicyDocumentResult -> getPolicyDocumentResult.json()))
                .eventBusName(testAwsCloudwatchEventBus.name())
                .build());
    
        }
    }
    
    resources:
      testEventBusPolicy:
        type: aws:cloudwatch:EventBusPolicy
        name: test
        properties:
          policy: ${test.json}
          eventBusName: ${testAwsCloudwatchEventBus.name}
    variables:
      test:
        fn::invoke:
          Function: aws:iam:getPolicyDocument
          Arguments:
            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}
    

    Multiple Statements

    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 pulumi
    import pulumi_aws as aws
    
    test = aws.iam.get_policy_document(statements=[
        aws.iam.GetPolicyDocumentStatementArgs(
            sid="DevAccountAccess",
            effect="Allow",
            actions=["events:PutEvents"],
            resources=["arn:aws:events:eu-west-1:123456789012:event-bus/default"],
            principals=[aws.iam.GetPolicyDocumentStatementPrincipalArgs(
                type="AWS",
                identifiers=["123456789012"],
            )],
        ),
        aws.iam.GetPolicyDocumentStatementArgs(
            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=[aws.iam.GetPolicyDocumentStatementPrincipalArgs(
                type="AWS",
                identifiers=["*"],
            )],
            conditions=[aws.iam.GetPolicyDocumentStatementConditionArgs(
                test="StringEquals",
                variable="aws:PrincipalOrgID",
                values=[example["id"]],
            )],
        ),
    ])
    test_event_bus_policy = aws.cloudwatch.EventBusPolicy("test",
        policy=test.json,
        event_bus_name=test_aws_cloudwatch_event_bus["name"])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/cloudwatch"
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iam"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
    test, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
    Statements: []iam.GetPolicyDocumentStatement{
    {
    Sid: pulumi.StringRef("DevAccountAccess"),
    Effect: pulumi.StringRef("Allow"),
    Actions: []string{
    "events:PutEvents",
    },
    Resources: []string{
    "arn:aws:events:eu-west-1:123456789012:event-bus/default",
    },
    Principals: []iam.GetPolicyDocumentStatementPrincipal{
    {
    Type: "AWS",
    Identifiers: []string{
    "123456789012",
    },
    },
    },
    },
    {
    Sid: pulumi.StringRef("OrganizationAccess"),
    Effect: pulumi.StringRef("Allow"),
    Actions: []string{
    "events:DescribeRule",
    "events:ListRules",
    "events:ListTargetsByRule",
    "events:ListTagsForResource",
    },
    Resources: []string{
    "arn:aws:events:eu-west-1:123456789012:rule/*",
    "arn:aws:events:eu-west-1:123456789012:event-bus/default",
    },
    Principals: []iam.GetPolicyDocumentStatementPrincipal{
    {
    Type: "AWS",
    Identifiers: []string{
    "*",
    },
    },
    },
    Conditions: []iam.GetPolicyDocumentStatementCondition{
    {
    Test: "StringEquals",
    Variable: "aws:PrincipalOrgID",
    Values: interface{}{
    example.Id,
    },
    },
    },
    },
    },
    }, nil);
    if err != nil {
    return err
    }
    _, err = cloudwatch.NewEventBusPolicy(ctx, "test", &cloudwatch.EventBusPolicyArgs{
    Policy: pulumi.String(test.Json),
    EventBusName: pulumi.Any(testAwsCloudwatchEventBus.Name),
    })
    if err != nil {
    return err
    }
    return nil
    })
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var test = Aws.Iam.GetPolicyDocument.Invoke(new()
        {
            Statements = new[]
            {
                new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
                {
                    Sid = "DevAccountAccess",
                    Effect = "Allow",
                    Actions = new[]
                    {
                        "events:PutEvents",
                    },
                    Resources = new[]
                    {
                        "arn:aws:events:eu-west-1:123456789012:event-bus/default",
                    },
                    Principals = new[]
                    {
                        new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalInputArgs
                        {
                            Type = "AWS",
                            Identifiers = new[]
                            {
                                "123456789012",
                            },
                        },
                    },
                },
                new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
                {
                    Sid = "OrganizationAccess",
                    Effect = "Allow",
                    Actions = new[]
                    {
                        "events:DescribeRule",
                        "events:ListRules",
                        "events:ListTargetsByRule",
                        "events:ListTagsForResource",
                    },
                    Resources = new[]
                    {
                        "arn:aws:events:eu-west-1:123456789012:rule/*",
                        "arn:aws:events:eu-west-1:123456789012:event-bus/default",
                    },
                    Principals = new[]
                    {
                        new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalInputArgs
                        {
                            Type = "AWS",
                            Identifiers = new[]
                            {
                                "*",
                            },
                        },
                    },
                    Conditions = new[]
                    {
                        new Aws.Iam.Inputs.GetPolicyDocumentStatementConditionInputArgs
                        {
                            Test = "StringEquals",
                            Variable = "aws:PrincipalOrgID",
                            Values = new[]
                            {
                                example.Id,
                            },
                        },
                    },
                },
            },
        });
    
        var testEventBusPolicy = new Aws.CloudWatch.EventBusPolicy("test", new()
        {
            Policy = test.Apply(getPolicyDocumentResult => getPolicyDocumentResult.Json),
            EventBusName = testAwsCloudwatchEventBus.Name,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.iam.IamFunctions;
    import com.pulumi.aws.iam.inputs.GetPolicyDocumentArgs;
    import com.pulumi.aws.cloudwatch.EventBusPolicy;
    import com.pulumi.aws.cloudwatch.EventBusPolicyArgs;
    import java.util.List;
    import java.util.ArrayList;
    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) {
            final var test = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
                .statements(            
                    GetPolicyDocumentStatementArgs.builder()
                        .sid("DevAccountAccess")
                        .effect("Allow")
                        .actions("events:PutEvents")
                        .resources("arn:aws:events:eu-west-1:123456789012:event-bus/default")
                        .principals(GetPolicyDocumentStatementPrincipalArgs.builder()
                            .type("AWS")
                            .identifiers("123456789012")
                            .build())
                        .build(),
                    GetPolicyDocumentStatementArgs.builder()
                        .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(GetPolicyDocumentStatementPrincipalArgs.builder()
                            .type("AWS")
                            .identifiers("*")
                            .build())
                        .conditions(GetPolicyDocumentStatementConditionArgs.builder()
                            .test("StringEquals")
                            .variable("aws:PrincipalOrgID")
                            .values(example.id())
                            .build())
                        .build())
                .build());
    
            var testEventBusPolicy = new EventBusPolicy("testEventBusPolicy", EventBusPolicyArgs.builder()
                .policy(test.applyValue(getPolicyDocumentResult -> getPolicyDocumentResult.json()))
                .eventBusName(testAwsCloudwatchEventBus.name())
                .build());
    
        }
    }
    
    resources:
      testEventBusPolicy:
        type: aws:cloudwatch:EventBusPolicy
        name: test
        properties:
          policy: ${test.json}
          eventBusName: ${testAwsCloudwatchEventBus.name}
    variables:
      test:
        fn::invoke:
          Function: aws:iam:getPolicyDocument
          Arguments:
            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}
    

    Create EventBusPolicy Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new EventBusPolicy(name: string, args: EventBusPolicyArgs, opts?: CustomResourceOptions);
    @overload
    def EventBusPolicy(resource_name: str,
                       args: EventBusPolicyArgs,
                       opts: Optional[ResourceOptions] = None)
    
    @overload
    def EventBusPolicy(resource_name: str,
                       opts: Optional[ResourceOptions] = None,
                       policy: Optional[str] = None,
                       event_bus_name: Optional[str] = None)
    func NewEventBusPolicy(ctx *Context, name string, args EventBusPolicyArgs, opts ...ResourceOption) (*EventBusPolicy, error)
    public EventBusPolicy(string name, EventBusPolicyArgs args, CustomResourceOptions? opts = null)
    public EventBusPolicy(String name, EventBusPolicyArgs args)
    public EventBusPolicy(String name, EventBusPolicyArgs args, CustomResourceOptions options)
    
    type: aws:cloudwatch:EventBusPolicy
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args EventBusPolicyArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args EventBusPolicyArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args EventBusPolicyArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args EventBusPolicyArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args EventBusPolicyArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Example

    The following reference example uses placeholder values for all input properties.

    var eventBusPolicyResource = new Aws.CloudWatch.EventBusPolicy("eventBusPolicyResource", new()
    {
        Policy = "string",
        EventBusName = "string",
    });
    
    example, err := cloudwatch.NewEventBusPolicy(ctx, "eventBusPolicyResource", &cloudwatch.EventBusPolicyArgs{
    	Policy:       pulumi.String("string"),
    	EventBusName: pulumi.String("string"),
    })
    
    var eventBusPolicyResource = new EventBusPolicy("eventBusPolicyResource", EventBusPolicyArgs.builder()
        .policy("string")
        .eventBusName("string")
        .build());
    
    event_bus_policy_resource = aws.cloudwatch.EventBusPolicy("eventBusPolicyResource",
        policy="string",
        event_bus_name="string")
    
    const eventBusPolicyResource = new aws.cloudwatch.EventBusPolicy("eventBusPolicyResource", {
        policy: "string",
        eventBusName: "string",
    });
    
    type: aws:cloudwatch:EventBusPolicy
    properties:
        eventBusName: string
        policy: string
    

    EventBusPolicy Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    The EventBusPolicy resource accepts the following input properties:

    Policy string
    The text of the policy.
    EventBusName string
    The name of the event bus to set the permissions on. If you omit this, the permissions are set on the default event bus.
    Policy string
    The text of the policy.
    EventBusName string
    The name of the event bus to set the permissions on. If you omit this, the permissions are set on the default event bus.
    policy String
    The text of the policy.
    eventBusName String
    The name of the event bus to set the permissions on. If you omit this, the permissions are set on the default event bus.
    policy string
    The text of the policy.
    eventBusName string
    The name of the event bus to set the permissions on. If you omit this, the permissions are set on the default event bus.
    policy str
    The text of the policy.
    event_bus_name str
    The name of the event bus to set the permissions on. If you omit this, the permissions are set on the default event bus.
    policy String
    The text of the policy.
    eventBusName String
    The name of the event bus to set the permissions on. If you omit this, the permissions are set on the default event bus.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the EventBusPolicy resource produces the following output properties:

    Id string
    The provider-assigned unique ID for this managed resource.
    Id string
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.
    id string
    The provider-assigned unique ID for this managed resource.
    id str
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.

    Look up Existing EventBusPolicy Resource

    Get an existing EventBusPolicy resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

    public static get(name: string, id: Input<ID>, state?: EventBusPolicyState, opts?: CustomResourceOptions): EventBusPolicy
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            event_bus_name: Optional[str] = None,
            policy: Optional[str] = None) -> EventBusPolicy
    func GetEventBusPolicy(ctx *Context, name string, id IDInput, state *EventBusPolicyState, opts ...ResourceOption) (*EventBusPolicy, error)
    public static EventBusPolicy Get(string name, Input<string> id, EventBusPolicyState? state, CustomResourceOptions? opts = null)
    public static EventBusPolicy get(String name, Output<String> id, EventBusPolicyState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    EventBusName string
    The name of the event bus to set the permissions on. If you omit this, the permissions are set on the default event bus.
    Policy string
    The text of the policy.
    EventBusName string
    The name of the event bus to set the permissions on. If you omit this, the permissions are set on the default event bus.
    Policy string
    The text of the policy.
    eventBusName String
    The name of the event bus to set the permissions on. If you omit this, the permissions are set on the default event bus.
    policy String
    The text of the policy.
    eventBusName string
    The name of the event bus to set the permissions on. If you omit this, the permissions are set on the default event bus.
    policy string
    The text of the policy.
    event_bus_name str
    The name of the event bus to set the permissions on. If you omit this, the permissions are set on the default event bus.
    policy str
    The text of the policy.
    eventBusName String
    The name of the event bus to set the permissions on. If you omit this, the permissions are set on the default event bus.
    policy String
    The text of the policy.

    Import

    Using pulumi import, import an EventBridge policy using the event_bus_name. For example:

    $ pulumi import aws:cloudwatch/eventBusPolicy:EventBusPolicy DevAccountAccess example-event-bus
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    AWS Classic pulumi/pulumi-aws
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the aws Terraform Provider.
    aws logo

    Try AWS Native preview for resources not in the classic version.

    AWS Classic v6.41.0 published on Tuesday, Jun 18, 2024 by Pulumi