github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/cloudwatch/eventBusPolicy.go (about) 1 // Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT. 2 // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! *** 3 4 package cloudwatch 5 6 import ( 7 "context" 8 "reflect" 9 10 "errors" 11 "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal" 12 "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 13 ) 14 15 // Provides a resource to create an EventBridge resource policy to support cross-account events. 16 // 17 // > **Note:** EventBridge was formerly known as CloudWatch Events. The functionality is identical. 18 // 19 // > **Note:** The EventBridge bus policy resource (`cloudwatch.EventBusPolicy`) is incompatible with the EventBridge permission resource (`cloudwatch.EventPermission`) and will overwrite permissions. 20 // 21 // ## Example Usage 22 // 23 // ### Account Access 24 // 25 // <!--Start PulumiCodeChooser --> 26 // ```go 27 // package main 28 // 29 // import ( 30 // 31 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/cloudwatch" 32 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iam" 33 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 34 // 35 // ) 36 // 37 // func main() { 38 // pulumi.Run(func(ctx *pulumi.Context) error { 39 // test, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{ 40 // Statements: []iam.GetPolicyDocumentStatement{ 41 // { 42 // Sid: pulumi.StringRef("DevAccountAccess"), 43 // Effect: pulumi.StringRef("Allow"), 44 // Actions: []string{ 45 // "events:PutEvents", 46 // }, 47 // Resources: []string{ 48 // "arn:aws:events:eu-west-1:123456789012:event-bus/default", 49 // }, 50 // Principals: []iam.GetPolicyDocumentStatementPrincipal{ 51 // { 52 // Type: "AWS", 53 // Identifiers: []string{ 54 // "123456789012", 55 // }, 56 // }, 57 // }, 58 // }, 59 // }, 60 // }, nil) 61 // if err != nil { 62 // return err 63 // } 64 // _, err = cloudwatch.NewEventBusPolicy(ctx, "test", &cloudwatch.EventBusPolicyArgs{ 65 // Policy: pulumi.String(test.Json), 66 // EventBusName: pulumi.Any(testAwsCloudwatchEventBus.Name), 67 // }) 68 // if err != nil { 69 // return err 70 // } 71 // return nil 72 // }) 73 // } 74 // 75 // ``` 76 // <!--End PulumiCodeChooser --> 77 // 78 // ### Organization Access 79 // 80 // <!--Start PulumiCodeChooser --> 81 // ```go 82 // package main 83 // 84 // import ( 85 // 86 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/cloudwatch" 87 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iam" 88 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 89 // 90 // ) 91 // func main() { 92 // pulumi.Run(func(ctx *pulumi.Context) error { 93 // test, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{ 94 // Statements: []iam.GetPolicyDocumentStatement{ 95 // { 96 // Sid: pulumi.StringRef("OrganizationAccess"), 97 // Effect: pulumi.StringRef("Allow"), 98 // Actions: []string{ 99 // "events:DescribeRule", 100 // "events:ListRules", 101 // "events:ListTargetsByRule", 102 // "events:ListTagsForResource", 103 // }, 104 // Resources: []string{ 105 // "arn:aws:events:eu-west-1:123456789012:rule/*", 106 // "arn:aws:events:eu-west-1:123456789012:event-bus/default", 107 // }, 108 // Principals: []iam.GetPolicyDocumentStatementPrincipal{ 109 // { 110 // Type: "AWS", 111 // Identifiers: []string{ 112 // "*", 113 // }, 114 // }, 115 // }, 116 // Conditions: []iam.GetPolicyDocumentStatementCondition{ 117 // { 118 // Test: "StringEquals", 119 // Variable: "aws:PrincipalOrgID", 120 // Values: interface{}{ 121 // example.Id, 122 // }, 123 // }, 124 // }, 125 // }, 126 // }, 127 // }, nil); 128 // if err != nil { 129 // return err 130 // } 131 // _, err = cloudwatch.NewEventBusPolicy(ctx, "test", &cloudwatch.EventBusPolicyArgs{ 132 // Policy: pulumi.String(test.Json), 133 // EventBusName: pulumi.Any(testAwsCloudwatchEventBus.Name), 134 // }) 135 // if err != nil { 136 // return err 137 // } 138 // return nil 139 // }) 140 // } 141 // ``` 142 // <!--End PulumiCodeChooser --> 143 // 144 // ### Multiple Statements 145 // 146 // <!--Start PulumiCodeChooser --> 147 // ```go 148 // package main 149 // 150 // import ( 151 // 152 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/cloudwatch" 153 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iam" 154 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 155 // 156 // ) 157 // func main() { 158 // pulumi.Run(func(ctx *pulumi.Context) error { 159 // test, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{ 160 // Statements: []iam.GetPolicyDocumentStatement{ 161 // { 162 // Sid: pulumi.StringRef("DevAccountAccess"), 163 // Effect: pulumi.StringRef("Allow"), 164 // Actions: []string{ 165 // "events:PutEvents", 166 // }, 167 // Resources: []string{ 168 // "arn:aws:events:eu-west-1:123456789012:event-bus/default", 169 // }, 170 // Principals: []iam.GetPolicyDocumentStatementPrincipal{ 171 // { 172 // Type: "AWS", 173 // Identifiers: []string{ 174 // "123456789012", 175 // }, 176 // }, 177 // }, 178 // }, 179 // { 180 // Sid: pulumi.StringRef("OrganizationAccess"), 181 // Effect: pulumi.StringRef("Allow"), 182 // Actions: []string{ 183 // "events:DescribeRule", 184 // "events:ListRules", 185 // "events:ListTargetsByRule", 186 // "events:ListTagsForResource", 187 // }, 188 // Resources: []string{ 189 // "arn:aws:events:eu-west-1:123456789012:rule/*", 190 // "arn:aws:events:eu-west-1:123456789012:event-bus/default", 191 // }, 192 // Principals: []iam.GetPolicyDocumentStatementPrincipal{ 193 // { 194 // Type: "AWS", 195 // Identifiers: []string{ 196 // "*", 197 // }, 198 // }, 199 // }, 200 // Conditions: []iam.GetPolicyDocumentStatementCondition{ 201 // { 202 // Test: "StringEquals", 203 // Variable: "aws:PrincipalOrgID", 204 // Values: interface{}{ 205 // example.Id, 206 // }, 207 // }, 208 // }, 209 // }, 210 // }, 211 // }, nil); 212 // if err != nil { 213 // return err 214 // } 215 // _, err = cloudwatch.NewEventBusPolicy(ctx, "test", &cloudwatch.EventBusPolicyArgs{ 216 // Policy: pulumi.String(test.Json), 217 // EventBusName: pulumi.Any(testAwsCloudwatchEventBus.Name), 218 // }) 219 // if err != nil { 220 // return err 221 // } 222 // return nil 223 // }) 224 // } 225 // ``` 226 // <!--End PulumiCodeChooser --> 227 // 228 // ## Import 229 // 230 // Using `pulumi import`, import an EventBridge policy using the `event_bus_name`. For example: 231 // 232 // ```sh 233 // $ pulumi import aws:cloudwatch/eventBusPolicy:EventBusPolicy DevAccountAccess example-event-bus 234 // ``` 235 type EventBusPolicy struct { 236 pulumi.CustomResourceState 237 238 // The name of the event bus to set the permissions on. 239 // If you omit this, the permissions are set on the `default` event bus. 240 EventBusName pulumi.StringPtrOutput `pulumi:"eventBusName"` 241 // The text of the policy. 242 Policy pulumi.StringOutput `pulumi:"policy"` 243 } 244 245 // NewEventBusPolicy registers a new resource with the given unique name, arguments, and options. 246 func NewEventBusPolicy(ctx *pulumi.Context, 247 name string, args *EventBusPolicyArgs, opts ...pulumi.ResourceOption) (*EventBusPolicy, error) { 248 if args == nil { 249 return nil, errors.New("missing one or more required arguments") 250 } 251 252 if args.Policy == nil { 253 return nil, errors.New("invalid value for required argument 'Policy'") 254 } 255 opts = internal.PkgResourceDefaultOpts(opts) 256 var resource EventBusPolicy 257 err := ctx.RegisterResource("aws:cloudwatch/eventBusPolicy:EventBusPolicy", name, args, &resource, opts...) 258 if err != nil { 259 return nil, err 260 } 261 return &resource, nil 262 } 263 264 // GetEventBusPolicy gets an existing EventBusPolicy resource's state with the given name, ID, and optional 265 // state properties that are used to uniquely qualify the lookup (nil if not required). 266 func GetEventBusPolicy(ctx *pulumi.Context, 267 name string, id pulumi.IDInput, state *EventBusPolicyState, opts ...pulumi.ResourceOption) (*EventBusPolicy, error) { 268 var resource EventBusPolicy 269 err := ctx.ReadResource("aws:cloudwatch/eventBusPolicy:EventBusPolicy", name, id, state, &resource, opts...) 270 if err != nil { 271 return nil, err 272 } 273 return &resource, nil 274 } 275 276 // Input properties used for looking up and filtering EventBusPolicy resources. 277 type eventBusPolicyState struct { 278 // The name of the event bus to set the permissions on. 279 // If you omit this, the permissions are set on the `default` event bus. 280 EventBusName *string `pulumi:"eventBusName"` 281 // The text of the policy. 282 Policy *string `pulumi:"policy"` 283 } 284 285 type EventBusPolicyState struct { 286 // The name of the event bus to set the permissions on. 287 // If you omit this, the permissions are set on the `default` event bus. 288 EventBusName pulumi.StringPtrInput 289 // The text of the policy. 290 Policy pulumi.StringPtrInput 291 } 292 293 func (EventBusPolicyState) ElementType() reflect.Type { 294 return reflect.TypeOf((*eventBusPolicyState)(nil)).Elem() 295 } 296 297 type eventBusPolicyArgs struct { 298 // The name of the event bus to set the permissions on. 299 // If you omit this, the permissions are set on the `default` event bus. 300 EventBusName *string `pulumi:"eventBusName"` 301 // The text of the policy. 302 Policy string `pulumi:"policy"` 303 } 304 305 // The set of arguments for constructing a EventBusPolicy resource. 306 type EventBusPolicyArgs struct { 307 // The name of the event bus to set the permissions on. 308 // If you omit this, the permissions are set on the `default` event bus. 309 EventBusName pulumi.StringPtrInput 310 // The text of the policy. 311 Policy pulumi.StringInput 312 } 313 314 func (EventBusPolicyArgs) ElementType() reflect.Type { 315 return reflect.TypeOf((*eventBusPolicyArgs)(nil)).Elem() 316 } 317 318 type EventBusPolicyInput interface { 319 pulumi.Input 320 321 ToEventBusPolicyOutput() EventBusPolicyOutput 322 ToEventBusPolicyOutputWithContext(ctx context.Context) EventBusPolicyOutput 323 } 324 325 func (*EventBusPolicy) ElementType() reflect.Type { 326 return reflect.TypeOf((**EventBusPolicy)(nil)).Elem() 327 } 328 329 func (i *EventBusPolicy) ToEventBusPolicyOutput() EventBusPolicyOutput { 330 return i.ToEventBusPolicyOutputWithContext(context.Background()) 331 } 332 333 func (i *EventBusPolicy) ToEventBusPolicyOutputWithContext(ctx context.Context) EventBusPolicyOutput { 334 return pulumi.ToOutputWithContext(ctx, i).(EventBusPolicyOutput) 335 } 336 337 // EventBusPolicyArrayInput is an input type that accepts EventBusPolicyArray and EventBusPolicyArrayOutput values. 338 // You can construct a concrete instance of `EventBusPolicyArrayInput` via: 339 // 340 // EventBusPolicyArray{ EventBusPolicyArgs{...} } 341 type EventBusPolicyArrayInput interface { 342 pulumi.Input 343 344 ToEventBusPolicyArrayOutput() EventBusPolicyArrayOutput 345 ToEventBusPolicyArrayOutputWithContext(context.Context) EventBusPolicyArrayOutput 346 } 347 348 type EventBusPolicyArray []EventBusPolicyInput 349 350 func (EventBusPolicyArray) ElementType() reflect.Type { 351 return reflect.TypeOf((*[]*EventBusPolicy)(nil)).Elem() 352 } 353 354 func (i EventBusPolicyArray) ToEventBusPolicyArrayOutput() EventBusPolicyArrayOutput { 355 return i.ToEventBusPolicyArrayOutputWithContext(context.Background()) 356 } 357 358 func (i EventBusPolicyArray) ToEventBusPolicyArrayOutputWithContext(ctx context.Context) EventBusPolicyArrayOutput { 359 return pulumi.ToOutputWithContext(ctx, i).(EventBusPolicyArrayOutput) 360 } 361 362 // EventBusPolicyMapInput is an input type that accepts EventBusPolicyMap and EventBusPolicyMapOutput values. 363 // You can construct a concrete instance of `EventBusPolicyMapInput` via: 364 // 365 // EventBusPolicyMap{ "key": EventBusPolicyArgs{...} } 366 type EventBusPolicyMapInput interface { 367 pulumi.Input 368 369 ToEventBusPolicyMapOutput() EventBusPolicyMapOutput 370 ToEventBusPolicyMapOutputWithContext(context.Context) EventBusPolicyMapOutput 371 } 372 373 type EventBusPolicyMap map[string]EventBusPolicyInput 374 375 func (EventBusPolicyMap) ElementType() reflect.Type { 376 return reflect.TypeOf((*map[string]*EventBusPolicy)(nil)).Elem() 377 } 378 379 func (i EventBusPolicyMap) ToEventBusPolicyMapOutput() EventBusPolicyMapOutput { 380 return i.ToEventBusPolicyMapOutputWithContext(context.Background()) 381 } 382 383 func (i EventBusPolicyMap) ToEventBusPolicyMapOutputWithContext(ctx context.Context) EventBusPolicyMapOutput { 384 return pulumi.ToOutputWithContext(ctx, i).(EventBusPolicyMapOutput) 385 } 386 387 type EventBusPolicyOutput struct{ *pulumi.OutputState } 388 389 func (EventBusPolicyOutput) ElementType() reflect.Type { 390 return reflect.TypeOf((**EventBusPolicy)(nil)).Elem() 391 } 392 393 func (o EventBusPolicyOutput) ToEventBusPolicyOutput() EventBusPolicyOutput { 394 return o 395 } 396 397 func (o EventBusPolicyOutput) ToEventBusPolicyOutputWithContext(ctx context.Context) EventBusPolicyOutput { 398 return o 399 } 400 401 // The name of the event bus to set the permissions on. 402 // If you omit this, the permissions are set on the `default` event bus. 403 func (o EventBusPolicyOutput) EventBusName() pulumi.StringPtrOutput { 404 return o.ApplyT(func(v *EventBusPolicy) pulumi.StringPtrOutput { return v.EventBusName }).(pulumi.StringPtrOutput) 405 } 406 407 // The text of the policy. 408 func (o EventBusPolicyOutput) Policy() pulumi.StringOutput { 409 return o.ApplyT(func(v *EventBusPolicy) pulumi.StringOutput { return v.Policy }).(pulumi.StringOutput) 410 } 411 412 type EventBusPolicyArrayOutput struct{ *pulumi.OutputState } 413 414 func (EventBusPolicyArrayOutput) ElementType() reflect.Type { 415 return reflect.TypeOf((*[]*EventBusPolicy)(nil)).Elem() 416 } 417 418 func (o EventBusPolicyArrayOutput) ToEventBusPolicyArrayOutput() EventBusPolicyArrayOutput { 419 return o 420 } 421 422 func (o EventBusPolicyArrayOutput) ToEventBusPolicyArrayOutputWithContext(ctx context.Context) EventBusPolicyArrayOutput { 423 return o 424 } 425 426 func (o EventBusPolicyArrayOutput) Index(i pulumi.IntInput) EventBusPolicyOutput { 427 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *EventBusPolicy { 428 return vs[0].([]*EventBusPolicy)[vs[1].(int)] 429 }).(EventBusPolicyOutput) 430 } 431 432 type EventBusPolicyMapOutput struct{ *pulumi.OutputState } 433 434 func (EventBusPolicyMapOutput) ElementType() reflect.Type { 435 return reflect.TypeOf((*map[string]*EventBusPolicy)(nil)).Elem() 436 } 437 438 func (o EventBusPolicyMapOutput) ToEventBusPolicyMapOutput() EventBusPolicyMapOutput { 439 return o 440 } 441 442 func (o EventBusPolicyMapOutput) ToEventBusPolicyMapOutputWithContext(ctx context.Context) EventBusPolicyMapOutput { 443 return o 444 } 445 446 func (o EventBusPolicyMapOutput) MapIndex(k pulumi.StringInput) EventBusPolicyOutput { 447 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *EventBusPolicy { 448 return vs[0].(map[string]*EventBusPolicy)[vs[1].(string)] 449 }).(EventBusPolicyOutput) 450 } 451 452 func init() { 453 pulumi.RegisterInputType(reflect.TypeOf((*EventBusPolicyInput)(nil)).Elem(), &EventBusPolicy{}) 454 pulumi.RegisterInputType(reflect.TypeOf((*EventBusPolicyArrayInput)(nil)).Elem(), EventBusPolicyArray{}) 455 pulumi.RegisterInputType(reflect.TypeOf((*EventBusPolicyMapInput)(nil)).Elem(), EventBusPolicyMap{}) 456 pulumi.RegisterOutputType(EventBusPolicyOutput{}) 457 pulumi.RegisterOutputType(EventBusPolicyArrayOutput{}) 458 pulumi.RegisterOutputType(EventBusPolicyMapOutput{}) 459 }