github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/cloudwatch/eventPermission.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 permission to support cross-account events in the current account default event bus. 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/sdk/v3/go/pulumi" 33 // 34 // ) 35 // 36 // func main() { 37 // pulumi.Run(func(ctx *pulumi.Context) error { 38 // _, err := cloudwatch.NewEventPermission(ctx, "DevAccountAccess", &cloudwatch.EventPermissionArgs{ 39 // Principal: pulumi.String("123456789012"), 40 // StatementId: pulumi.String("DevAccountAccess"), 41 // }) 42 // if err != nil { 43 // return err 44 // } 45 // return nil 46 // }) 47 // } 48 // 49 // ``` 50 // <!--End PulumiCodeChooser --> 51 // 52 // ### Organization Access 53 // 54 // <!--Start PulumiCodeChooser --> 55 // ```go 56 // package main 57 // 58 // import ( 59 // 60 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/cloudwatch" 61 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 62 // 63 // ) 64 // 65 // func main() { 66 // pulumi.Run(func(ctx *pulumi.Context) error { 67 // _, err := cloudwatch.NewEventPermission(ctx, "OrganizationAccess", &cloudwatch.EventPermissionArgs{ 68 // Principal: pulumi.String("*"), 69 // StatementId: pulumi.String("OrganizationAccess"), 70 // Condition: &cloudwatch.EventPermissionConditionArgs{ 71 // Key: pulumi.String("aws:PrincipalOrgID"), 72 // Type: pulumi.String("StringEquals"), 73 // Value: pulumi.Any(example.Id), 74 // }, 75 // }) 76 // if err != nil { 77 // return err 78 // } 79 // return nil 80 // }) 81 // } 82 // 83 // ``` 84 // <!--End PulumiCodeChooser --> 85 // 86 // ## Import 87 // 88 // Using `pulumi import`, import EventBridge permissions using the `event_bus_name/statement_id` (if you omit `event_bus_name`, the `default` event bus will be used). For example: 89 // 90 // ```sh 91 // $ pulumi import aws:cloudwatch/eventPermission:EventPermission DevAccountAccess example-event-bus/DevAccountAccess 92 // ``` 93 type EventPermission struct { 94 pulumi.CustomResourceState 95 96 // The action that you are enabling the other account to perform. Defaults to `events:PutEvents`. 97 Action pulumi.StringPtrOutput `pulumi:"action"` 98 // Configuration block to limit the event bus permissions you are granting to only accounts that fulfill the condition. Specified below. 99 Condition EventPermissionConditionPtrOutput `pulumi:"condition"` 100 // The name of the event bus to set the permissions on. 101 // If you omit this, the permissions are set on the `default` event bus. 102 EventBusName pulumi.StringPtrOutput `pulumi:"eventBusName"` 103 // The 12-digit AWS account ID that you are permitting to put events to your default event bus. Specify `*` to permit any account to put events to your default event bus, optionally limited by `condition`. 104 Principal pulumi.StringOutput `pulumi:"principal"` 105 // An identifier string for the external account that you are granting permissions to. 106 StatementId pulumi.StringOutput `pulumi:"statementId"` 107 } 108 109 // NewEventPermission registers a new resource with the given unique name, arguments, and options. 110 func NewEventPermission(ctx *pulumi.Context, 111 name string, args *EventPermissionArgs, opts ...pulumi.ResourceOption) (*EventPermission, error) { 112 if args == nil { 113 return nil, errors.New("missing one or more required arguments") 114 } 115 116 if args.Principal == nil { 117 return nil, errors.New("invalid value for required argument 'Principal'") 118 } 119 if args.StatementId == nil { 120 return nil, errors.New("invalid value for required argument 'StatementId'") 121 } 122 opts = internal.PkgResourceDefaultOpts(opts) 123 var resource EventPermission 124 err := ctx.RegisterResource("aws:cloudwatch/eventPermission:EventPermission", name, args, &resource, opts...) 125 if err != nil { 126 return nil, err 127 } 128 return &resource, nil 129 } 130 131 // GetEventPermission gets an existing EventPermission resource's state with the given name, ID, and optional 132 // state properties that are used to uniquely qualify the lookup (nil if not required). 133 func GetEventPermission(ctx *pulumi.Context, 134 name string, id pulumi.IDInput, state *EventPermissionState, opts ...pulumi.ResourceOption) (*EventPermission, error) { 135 var resource EventPermission 136 err := ctx.ReadResource("aws:cloudwatch/eventPermission:EventPermission", name, id, state, &resource, opts...) 137 if err != nil { 138 return nil, err 139 } 140 return &resource, nil 141 } 142 143 // Input properties used for looking up and filtering EventPermission resources. 144 type eventPermissionState struct { 145 // The action that you are enabling the other account to perform. Defaults to `events:PutEvents`. 146 Action *string `pulumi:"action"` 147 // Configuration block to limit the event bus permissions you are granting to only accounts that fulfill the condition. Specified below. 148 Condition *EventPermissionCondition `pulumi:"condition"` 149 // The name of the event bus to set the permissions on. 150 // If you omit this, the permissions are set on the `default` event bus. 151 EventBusName *string `pulumi:"eventBusName"` 152 // The 12-digit AWS account ID that you are permitting to put events to your default event bus. Specify `*` to permit any account to put events to your default event bus, optionally limited by `condition`. 153 Principal *string `pulumi:"principal"` 154 // An identifier string for the external account that you are granting permissions to. 155 StatementId *string `pulumi:"statementId"` 156 } 157 158 type EventPermissionState struct { 159 // The action that you are enabling the other account to perform. Defaults to `events:PutEvents`. 160 Action pulumi.StringPtrInput 161 // Configuration block to limit the event bus permissions you are granting to only accounts that fulfill the condition. Specified below. 162 Condition EventPermissionConditionPtrInput 163 // The name of the event bus to set the permissions on. 164 // If you omit this, the permissions are set on the `default` event bus. 165 EventBusName pulumi.StringPtrInput 166 // The 12-digit AWS account ID that you are permitting to put events to your default event bus. Specify `*` to permit any account to put events to your default event bus, optionally limited by `condition`. 167 Principal pulumi.StringPtrInput 168 // An identifier string for the external account that you are granting permissions to. 169 StatementId pulumi.StringPtrInput 170 } 171 172 func (EventPermissionState) ElementType() reflect.Type { 173 return reflect.TypeOf((*eventPermissionState)(nil)).Elem() 174 } 175 176 type eventPermissionArgs struct { 177 // The action that you are enabling the other account to perform. Defaults to `events:PutEvents`. 178 Action *string `pulumi:"action"` 179 // Configuration block to limit the event bus permissions you are granting to only accounts that fulfill the condition. Specified below. 180 Condition *EventPermissionCondition `pulumi:"condition"` 181 // The name of the event bus to set the permissions on. 182 // If you omit this, the permissions are set on the `default` event bus. 183 EventBusName *string `pulumi:"eventBusName"` 184 // The 12-digit AWS account ID that you are permitting to put events to your default event bus. Specify `*` to permit any account to put events to your default event bus, optionally limited by `condition`. 185 Principal string `pulumi:"principal"` 186 // An identifier string for the external account that you are granting permissions to. 187 StatementId string `pulumi:"statementId"` 188 } 189 190 // The set of arguments for constructing a EventPermission resource. 191 type EventPermissionArgs struct { 192 // The action that you are enabling the other account to perform. Defaults to `events:PutEvents`. 193 Action pulumi.StringPtrInput 194 // Configuration block to limit the event bus permissions you are granting to only accounts that fulfill the condition. Specified below. 195 Condition EventPermissionConditionPtrInput 196 // The name of the event bus to set the permissions on. 197 // If you omit this, the permissions are set on the `default` event bus. 198 EventBusName pulumi.StringPtrInput 199 // The 12-digit AWS account ID that you are permitting to put events to your default event bus. Specify `*` to permit any account to put events to your default event bus, optionally limited by `condition`. 200 Principal pulumi.StringInput 201 // An identifier string for the external account that you are granting permissions to. 202 StatementId pulumi.StringInput 203 } 204 205 func (EventPermissionArgs) ElementType() reflect.Type { 206 return reflect.TypeOf((*eventPermissionArgs)(nil)).Elem() 207 } 208 209 type EventPermissionInput interface { 210 pulumi.Input 211 212 ToEventPermissionOutput() EventPermissionOutput 213 ToEventPermissionOutputWithContext(ctx context.Context) EventPermissionOutput 214 } 215 216 func (*EventPermission) ElementType() reflect.Type { 217 return reflect.TypeOf((**EventPermission)(nil)).Elem() 218 } 219 220 func (i *EventPermission) ToEventPermissionOutput() EventPermissionOutput { 221 return i.ToEventPermissionOutputWithContext(context.Background()) 222 } 223 224 func (i *EventPermission) ToEventPermissionOutputWithContext(ctx context.Context) EventPermissionOutput { 225 return pulumi.ToOutputWithContext(ctx, i).(EventPermissionOutput) 226 } 227 228 // EventPermissionArrayInput is an input type that accepts EventPermissionArray and EventPermissionArrayOutput values. 229 // You can construct a concrete instance of `EventPermissionArrayInput` via: 230 // 231 // EventPermissionArray{ EventPermissionArgs{...} } 232 type EventPermissionArrayInput interface { 233 pulumi.Input 234 235 ToEventPermissionArrayOutput() EventPermissionArrayOutput 236 ToEventPermissionArrayOutputWithContext(context.Context) EventPermissionArrayOutput 237 } 238 239 type EventPermissionArray []EventPermissionInput 240 241 func (EventPermissionArray) ElementType() reflect.Type { 242 return reflect.TypeOf((*[]*EventPermission)(nil)).Elem() 243 } 244 245 func (i EventPermissionArray) ToEventPermissionArrayOutput() EventPermissionArrayOutput { 246 return i.ToEventPermissionArrayOutputWithContext(context.Background()) 247 } 248 249 func (i EventPermissionArray) ToEventPermissionArrayOutputWithContext(ctx context.Context) EventPermissionArrayOutput { 250 return pulumi.ToOutputWithContext(ctx, i).(EventPermissionArrayOutput) 251 } 252 253 // EventPermissionMapInput is an input type that accepts EventPermissionMap and EventPermissionMapOutput values. 254 // You can construct a concrete instance of `EventPermissionMapInput` via: 255 // 256 // EventPermissionMap{ "key": EventPermissionArgs{...} } 257 type EventPermissionMapInput interface { 258 pulumi.Input 259 260 ToEventPermissionMapOutput() EventPermissionMapOutput 261 ToEventPermissionMapOutputWithContext(context.Context) EventPermissionMapOutput 262 } 263 264 type EventPermissionMap map[string]EventPermissionInput 265 266 func (EventPermissionMap) ElementType() reflect.Type { 267 return reflect.TypeOf((*map[string]*EventPermission)(nil)).Elem() 268 } 269 270 func (i EventPermissionMap) ToEventPermissionMapOutput() EventPermissionMapOutput { 271 return i.ToEventPermissionMapOutputWithContext(context.Background()) 272 } 273 274 func (i EventPermissionMap) ToEventPermissionMapOutputWithContext(ctx context.Context) EventPermissionMapOutput { 275 return pulumi.ToOutputWithContext(ctx, i).(EventPermissionMapOutput) 276 } 277 278 type EventPermissionOutput struct{ *pulumi.OutputState } 279 280 func (EventPermissionOutput) ElementType() reflect.Type { 281 return reflect.TypeOf((**EventPermission)(nil)).Elem() 282 } 283 284 func (o EventPermissionOutput) ToEventPermissionOutput() EventPermissionOutput { 285 return o 286 } 287 288 func (o EventPermissionOutput) ToEventPermissionOutputWithContext(ctx context.Context) EventPermissionOutput { 289 return o 290 } 291 292 // The action that you are enabling the other account to perform. Defaults to `events:PutEvents`. 293 func (o EventPermissionOutput) Action() pulumi.StringPtrOutput { 294 return o.ApplyT(func(v *EventPermission) pulumi.StringPtrOutput { return v.Action }).(pulumi.StringPtrOutput) 295 } 296 297 // Configuration block to limit the event bus permissions you are granting to only accounts that fulfill the condition. Specified below. 298 func (o EventPermissionOutput) Condition() EventPermissionConditionPtrOutput { 299 return o.ApplyT(func(v *EventPermission) EventPermissionConditionPtrOutput { return v.Condition }).(EventPermissionConditionPtrOutput) 300 } 301 302 // The name of the event bus to set the permissions on. 303 // If you omit this, the permissions are set on the `default` event bus. 304 func (o EventPermissionOutput) EventBusName() pulumi.StringPtrOutput { 305 return o.ApplyT(func(v *EventPermission) pulumi.StringPtrOutput { return v.EventBusName }).(pulumi.StringPtrOutput) 306 } 307 308 // The 12-digit AWS account ID that you are permitting to put events to your default event bus. Specify `*` to permit any account to put events to your default event bus, optionally limited by `condition`. 309 func (o EventPermissionOutput) Principal() pulumi.StringOutput { 310 return o.ApplyT(func(v *EventPermission) pulumi.StringOutput { return v.Principal }).(pulumi.StringOutput) 311 } 312 313 // An identifier string for the external account that you are granting permissions to. 314 func (o EventPermissionOutput) StatementId() pulumi.StringOutput { 315 return o.ApplyT(func(v *EventPermission) pulumi.StringOutput { return v.StatementId }).(pulumi.StringOutput) 316 } 317 318 type EventPermissionArrayOutput struct{ *pulumi.OutputState } 319 320 func (EventPermissionArrayOutput) ElementType() reflect.Type { 321 return reflect.TypeOf((*[]*EventPermission)(nil)).Elem() 322 } 323 324 func (o EventPermissionArrayOutput) ToEventPermissionArrayOutput() EventPermissionArrayOutput { 325 return o 326 } 327 328 func (o EventPermissionArrayOutput) ToEventPermissionArrayOutputWithContext(ctx context.Context) EventPermissionArrayOutput { 329 return o 330 } 331 332 func (o EventPermissionArrayOutput) Index(i pulumi.IntInput) EventPermissionOutput { 333 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *EventPermission { 334 return vs[0].([]*EventPermission)[vs[1].(int)] 335 }).(EventPermissionOutput) 336 } 337 338 type EventPermissionMapOutput struct{ *pulumi.OutputState } 339 340 func (EventPermissionMapOutput) ElementType() reflect.Type { 341 return reflect.TypeOf((*map[string]*EventPermission)(nil)).Elem() 342 } 343 344 func (o EventPermissionMapOutput) ToEventPermissionMapOutput() EventPermissionMapOutput { 345 return o 346 } 347 348 func (o EventPermissionMapOutput) ToEventPermissionMapOutputWithContext(ctx context.Context) EventPermissionMapOutput { 349 return o 350 } 351 352 func (o EventPermissionMapOutput) MapIndex(k pulumi.StringInput) EventPermissionOutput { 353 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *EventPermission { 354 return vs[0].(map[string]*EventPermission)[vs[1].(string)] 355 }).(EventPermissionOutput) 356 } 357 358 func init() { 359 pulumi.RegisterInputType(reflect.TypeOf((*EventPermissionInput)(nil)).Elem(), &EventPermission{}) 360 pulumi.RegisterInputType(reflect.TypeOf((*EventPermissionArrayInput)(nil)).Elem(), EventPermissionArray{}) 361 pulumi.RegisterInputType(reflect.TypeOf((*EventPermissionMapInput)(nil)).Elem(), EventPermissionMap{}) 362 pulumi.RegisterOutputType(EventPermissionOutput{}) 363 pulumi.RegisterOutputType(EventPermissionArrayOutput{}) 364 pulumi.RegisterOutputType(EventPermissionMapOutput{}) 365 }