github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/cloudwatch/eventArchive.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 an EventBridge event archive resource.
    16  //
    17  // > **Note:** EventBridge was formerly known as CloudWatch Events. The functionality is identical.
    18  //
    19  // ## Example Usage
    20  //
    21  // <!--Start PulumiCodeChooser -->
    22  // ```go
    23  // package main
    24  //
    25  // import (
    26  //
    27  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/cloudwatch"
    28  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    29  //
    30  // )
    31  //
    32  //	func main() {
    33  //		pulumi.Run(func(ctx *pulumi.Context) error {
    34  //			order, err := cloudwatch.NewEventBus(ctx, "order", &cloudwatch.EventBusArgs{
    35  //				Name: pulumi.String("orders"),
    36  //			})
    37  //			if err != nil {
    38  //				return err
    39  //			}
    40  //			_, err = cloudwatch.NewEventArchive(ctx, "order", &cloudwatch.EventArchiveArgs{
    41  //				Name:           pulumi.String("order-archive"),
    42  //				EventSourceArn: order.Arn,
    43  //			})
    44  //			if err != nil {
    45  //				return err
    46  //			}
    47  //			return nil
    48  //		})
    49  //	}
    50  //
    51  // ```
    52  // <!--End PulumiCodeChooser -->
    53  //
    54  // ## Example all optional arguments
    55  //
    56  // <!--Start PulumiCodeChooser -->
    57  // ```go
    58  // package main
    59  //
    60  // import (
    61  //
    62  //	"encoding/json"
    63  //
    64  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/cloudwatch"
    65  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    66  //
    67  // )
    68  //
    69  //	func main() {
    70  //		pulumi.Run(func(ctx *pulumi.Context) error {
    71  //			order, err := cloudwatch.NewEventBus(ctx, "order", &cloudwatch.EventBusArgs{
    72  //				Name: pulumi.String("orders"),
    73  //			})
    74  //			if err != nil {
    75  //				return err
    76  //			}
    77  //			tmpJSON0, err := json.Marshal(map[string]interface{}{
    78  //				"source": []string{
    79  //					"company.team.order",
    80  //				},
    81  //			})
    82  //			if err != nil {
    83  //				return err
    84  //			}
    85  //			json0 := string(tmpJSON0)
    86  //			_, err = cloudwatch.NewEventArchive(ctx, "order", &cloudwatch.EventArchiveArgs{
    87  //				Name:           pulumi.String("order-archive"),
    88  //				Description:    pulumi.String("Archived events from order service"),
    89  //				EventSourceArn: order.Arn,
    90  //				RetentionDays:  pulumi.Int(7),
    91  //				EventPattern:   pulumi.String(json0),
    92  //			})
    93  //			if err != nil {
    94  //				return err
    95  //			}
    96  //			return nil
    97  //		})
    98  //	}
    99  //
   100  // ```
   101  // <!--End PulumiCodeChooser -->
   102  //
   103  // ## Import
   104  //
   105  // Using `pulumi import`, import an EventBridge archive using the `name`. For example:
   106  //
   107  // ```sh
   108  // $ pulumi import aws:cloudwatch/eventArchive:EventArchive imported_event_archive order-archive
   109  // ```
   110  type EventArchive struct {
   111  	pulumi.CustomResourceState
   112  
   113  	// The Amazon Resource Name (ARN) of the event archive.
   114  	Arn pulumi.StringOutput `pulumi:"arn"`
   115  	// The description of the new event archive.
   116  	Description pulumi.StringPtrOutput `pulumi:"description"`
   117  	// Instructs the new event archive to only capture events matched by this pattern. By default, it attempts to archive every event received in the `eventSourceArn`.
   118  	EventPattern pulumi.StringPtrOutput `pulumi:"eventPattern"`
   119  	// Event bus source ARN from where these events should be archived.
   120  	EventSourceArn pulumi.StringOutput `pulumi:"eventSourceArn"`
   121  	// The name of the new event archive. The archive name cannot exceed 48 characters.
   122  	Name pulumi.StringOutput `pulumi:"name"`
   123  	// The maximum number of days to retain events in the new event archive. By default, it archives indefinitely.
   124  	RetentionDays pulumi.IntPtrOutput `pulumi:"retentionDays"`
   125  }
   126  
   127  // NewEventArchive registers a new resource with the given unique name, arguments, and options.
   128  func NewEventArchive(ctx *pulumi.Context,
   129  	name string, args *EventArchiveArgs, opts ...pulumi.ResourceOption) (*EventArchive, error) {
   130  	if args == nil {
   131  		return nil, errors.New("missing one or more required arguments")
   132  	}
   133  
   134  	if args.EventSourceArn == nil {
   135  		return nil, errors.New("invalid value for required argument 'EventSourceArn'")
   136  	}
   137  	opts = internal.PkgResourceDefaultOpts(opts)
   138  	var resource EventArchive
   139  	err := ctx.RegisterResource("aws:cloudwatch/eventArchive:EventArchive", name, args, &resource, opts...)
   140  	if err != nil {
   141  		return nil, err
   142  	}
   143  	return &resource, nil
   144  }
   145  
   146  // GetEventArchive gets an existing EventArchive resource's state with the given name, ID, and optional
   147  // state properties that are used to uniquely qualify the lookup (nil if not required).
   148  func GetEventArchive(ctx *pulumi.Context,
   149  	name string, id pulumi.IDInput, state *EventArchiveState, opts ...pulumi.ResourceOption) (*EventArchive, error) {
   150  	var resource EventArchive
   151  	err := ctx.ReadResource("aws:cloudwatch/eventArchive:EventArchive", name, id, state, &resource, opts...)
   152  	if err != nil {
   153  		return nil, err
   154  	}
   155  	return &resource, nil
   156  }
   157  
   158  // Input properties used for looking up and filtering EventArchive resources.
   159  type eventArchiveState struct {
   160  	// The Amazon Resource Name (ARN) of the event archive.
   161  	Arn *string `pulumi:"arn"`
   162  	// The description of the new event archive.
   163  	Description *string `pulumi:"description"`
   164  	// Instructs the new event archive to only capture events matched by this pattern. By default, it attempts to archive every event received in the `eventSourceArn`.
   165  	EventPattern *string `pulumi:"eventPattern"`
   166  	// Event bus source ARN from where these events should be archived.
   167  	EventSourceArn *string `pulumi:"eventSourceArn"`
   168  	// The name of the new event archive. The archive name cannot exceed 48 characters.
   169  	Name *string `pulumi:"name"`
   170  	// The maximum number of days to retain events in the new event archive. By default, it archives indefinitely.
   171  	RetentionDays *int `pulumi:"retentionDays"`
   172  }
   173  
   174  type EventArchiveState struct {
   175  	// The Amazon Resource Name (ARN) of the event archive.
   176  	Arn pulumi.StringPtrInput
   177  	// The description of the new event archive.
   178  	Description pulumi.StringPtrInput
   179  	// Instructs the new event archive to only capture events matched by this pattern. By default, it attempts to archive every event received in the `eventSourceArn`.
   180  	EventPattern pulumi.StringPtrInput
   181  	// Event bus source ARN from where these events should be archived.
   182  	EventSourceArn pulumi.StringPtrInput
   183  	// The name of the new event archive. The archive name cannot exceed 48 characters.
   184  	Name pulumi.StringPtrInput
   185  	// The maximum number of days to retain events in the new event archive. By default, it archives indefinitely.
   186  	RetentionDays pulumi.IntPtrInput
   187  }
   188  
   189  func (EventArchiveState) ElementType() reflect.Type {
   190  	return reflect.TypeOf((*eventArchiveState)(nil)).Elem()
   191  }
   192  
   193  type eventArchiveArgs struct {
   194  	// The description of the new event archive.
   195  	Description *string `pulumi:"description"`
   196  	// Instructs the new event archive to only capture events matched by this pattern. By default, it attempts to archive every event received in the `eventSourceArn`.
   197  	EventPattern *string `pulumi:"eventPattern"`
   198  	// Event bus source ARN from where these events should be archived.
   199  	EventSourceArn string `pulumi:"eventSourceArn"`
   200  	// The name of the new event archive. The archive name cannot exceed 48 characters.
   201  	Name *string `pulumi:"name"`
   202  	// The maximum number of days to retain events in the new event archive. By default, it archives indefinitely.
   203  	RetentionDays *int `pulumi:"retentionDays"`
   204  }
   205  
   206  // The set of arguments for constructing a EventArchive resource.
   207  type EventArchiveArgs struct {
   208  	// The description of the new event archive.
   209  	Description pulumi.StringPtrInput
   210  	// Instructs the new event archive to only capture events matched by this pattern. By default, it attempts to archive every event received in the `eventSourceArn`.
   211  	EventPattern pulumi.StringPtrInput
   212  	// Event bus source ARN from where these events should be archived.
   213  	EventSourceArn pulumi.StringInput
   214  	// The name of the new event archive. The archive name cannot exceed 48 characters.
   215  	Name pulumi.StringPtrInput
   216  	// The maximum number of days to retain events in the new event archive. By default, it archives indefinitely.
   217  	RetentionDays pulumi.IntPtrInput
   218  }
   219  
   220  func (EventArchiveArgs) ElementType() reflect.Type {
   221  	return reflect.TypeOf((*eventArchiveArgs)(nil)).Elem()
   222  }
   223  
   224  type EventArchiveInput interface {
   225  	pulumi.Input
   226  
   227  	ToEventArchiveOutput() EventArchiveOutput
   228  	ToEventArchiveOutputWithContext(ctx context.Context) EventArchiveOutput
   229  }
   230  
   231  func (*EventArchive) ElementType() reflect.Type {
   232  	return reflect.TypeOf((**EventArchive)(nil)).Elem()
   233  }
   234  
   235  func (i *EventArchive) ToEventArchiveOutput() EventArchiveOutput {
   236  	return i.ToEventArchiveOutputWithContext(context.Background())
   237  }
   238  
   239  func (i *EventArchive) ToEventArchiveOutputWithContext(ctx context.Context) EventArchiveOutput {
   240  	return pulumi.ToOutputWithContext(ctx, i).(EventArchiveOutput)
   241  }
   242  
   243  // EventArchiveArrayInput is an input type that accepts EventArchiveArray and EventArchiveArrayOutput values.
   244  // You can construct a concrete instance of `EventArchiveArrayInput` via:
   245  //
   246  //	EventArchiveArray{ EventArchiveArgs{...} }
   247  type EventArchiveArrayInput interface {
   248  	pulumi.Input
   249  
   250  	ToEventArchiveArrayOutput() EventArchiveArrayOutput
   251  	ToEventArchiveArrayOutputWithContext(context.Context) EventArchiveArrayOutput
   252  }
   253  
   254  type EventArchiveArray []EventArchiveInput
   255  
   256  func (EventArchiveArray) ElementType() reflect.Type {
   257  	return reflect.TypeOf((*[]*EventArchive)(nil)).Elem()
   258  }
   259  
   260  func (i EventArchiveArray) ToEventArchiveArrayOutput() EventArchiveArrayOutput {
   261  	return i.ToEventArchiveArrayOutputWithContext(context.Background())
   262  }
   263  
   264  func (i EventArchiveArray) ToEventArchiveArrayOutputWithContext(ctx context.Context) EventArchiveArrayOutput {
   265  	return pulumi.ToOutputWithContext(ctx, i).(EventArchiveArrayOutput)
   266  }
   267  
   268  // EventArchiveMapInput is an input type that accepts EventArchiveMap and EventArchiveMapOutput values.
   269  // You can construct a concrete instance of `EventArchiveMapInput` via:
   270  //
   271  //	EventArchiveMap{ "key": EventArchiveArgs{...} }
   272  type EventArchiveMapInput interface {
   273  	pulumi.Input
   274  
   275  	ToEventArchiveMapOutput() EventArchiveMapOutput
   276  	ToEventArchiveMapOutputWithContext(context.Context) EventArchiveMapOutput
   277  }
   278  
   279  type EventArchiveMap map[string]EventArchiveInput
   280  
   281  func (EventArchiveMap) ElementType() reflect.Type {
   282  	return reflect.TypeOf((*map[string]*EventArchive)(nil)).Elem()
   283  }
   284  
   285  func (i EventArchiveMap) ToEventArchiveMapOutput() EventArchiveMapOutput {
   286  	return i.ToEventArchiveMapOutputWithContext(context.Background())
   287  }
   288  
   289  func (i EventArchiveMap) ToEventArchiveMapOutputWithContext(ctx context.Context) EventArchiveMapOutput {
   290  	return pulumi.ToOutputWithContext(ctx, i).(EventArchiveMapOutput)
   291  }
   292  
   293  type EventArchiveOutput struct{ *pulumi.OutputState }
   294  
   295  func (EventArchiveOutput) ElementType() reflect.Type {
   296  	return reflect.TypeOf((**EventArchive)(nil)).Elem()
   297  }
   298  
   299  func (o EventArchiveOutput) ToEventArchiveOutput() EventArchiveOutput {
   300  	return o
   301  }
   302  
   303  func (o EventArchiveOutput) ToEventArchiveOutputWithContext(ctx context.Context) EventArchiveOutput {
   304  	return o
   305  }
   306  
   307  // The Amazon Resource Name (ARN) of the event archive.
   308  func (o EventArchiveOutput) Arn() pulumi.StringOutput {
   309  	return o.ApplyT(func(v *EventArchive) pulumi.StringOutput { return v.Arn }).(pulumi.StringOutput)
   310  }
   311  
   312  // The description of the new event archive.
   313  func (o EventArchiveOutput) Description() pulumi.StringPtrOutput {
   314  	return o.ApplyT(func(v *EventArchive) pulumi.StringPtrOutput { return v.Description }).(pulumi.StringPtrOutput)
   315  }
   316  
   317  // Instructs the new event archive to only capture events matched by this pattern. By default, it attempts to archive every event received in the `eventSourceArn`.
   318  func (o EventArchiveOutput) EventPattern() pulumi.StringPtrOutput {
   319  	return o.ApplyT(func(v *EventArchive) pulumi.StringPtrOutput { return v.EventPattern }).(pulumi.StringPtrOutput)
   320  }
   321  
   322  // Event bus source ARN from where these events should be archived.
   323  func (o EventArchiveOutput) EventSourceArn() pulumi.StringOutput {
   324  	return o.ApplyT(func(v *EventArchive) pulumi.StringOutput { return v.EventSourceArn }).(pulumi.StringOutput)
   325  }
   326  
   327  // The name of the new event archive. The archive name cannot exceed 48 characters.
   328  func (o EventArchiveOutput) Name() pulumi.StringOutput {
   329  	return o.ApplyT(func(v *EventArchive) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
   330  }
   331  
   332  // The maximum number of days to retain events in the new event archive. By default, it archives indefinitely.
   333  func (o EventArchiveOutput) RetentionDays() pulumi.IntPtrOutput {
   334  	return o.ApplyT(func(v *EventArchive) pulumi.IntPtrOutput { return v.RetentionDays }).(pulumi.IntPtrOutput)
   335  }
   336  
   337  type EventArchiveArrayOutput struct{ *pulumi.OutputState }
   338  
   339  func (EventArchiveArrayOutput) ElementType() reflect.Type {
   340  	return reflect.TypeOf((*[]*EventArchive)(nil)).Elem()
   341  }
   342  
   343  func (o EventArchiveArrayOutput) ToEventArchiveArrayOutput() EventArchiveArrayOutput {
   344  	return o
   345  }
   346  
   347  func (o EventArchiveArrayOutput) ToEventArchiveArrayOutputWithContext(ctx context.Context) EventArchiveArrayOutput {
   348  	return o
   349  }
   350  
   351  func (o EventArchiveArrayOutput) Index(i pulumi.IntInput) EventArchiveOutput {
   352  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *EventArchive {
   353  		return vs[0].([]*EventArchive)[vs[1].(int)]
   354  	}).(EventArchiveOutput)
   355  }
   356  
   357  type EventArchiveMapOutput struct{ *pulumi.OutputState }
   358  
   359  func (EventArchiveMapOutput) ElementType() reflect.Type {
   360  	return reflect.TypeOf((*map[string]*EventArchive)(nil)).Elem()
   361  }
   362  
   363  func (o EventArchiveMapOutput) ToEventArchiveMapOutput() EventArchiveMapOutput {
   364  	return o
   365  }
   366  
   367  func (o EventArchiveMapOutput) ToEventArchiveMapOutputWithContext(ctx context.Context) EventArchiveMapOutput {
   368  	return o
   369  }
   370  
   371  func (o EventArchiveMapOutput) MapIndex(k pulumi.StringInput) EventArchiveOutput {
   372  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *EventArchive {
   373  		return vs[0].(map[string]*EventArchive)[vs[1].(string)]
   374  	}).(EventArchiveOutput)
   375  }
   376  
   377  func init() {
   378  	pulumi.RegisterInputType(reflect.TypeOf((*EventArchiveInput)(nil)).Elem(), &EventArchive{})
   379  	pulumi.RegisterInputType(reflect.TypeOf((*EventArchiveArrayInput)(nil)).Elem(), EventArchiveArray{})
   380  	pulumi.RegisterInputType(reflect.TypeOf((*EventArchiveMapInput)(nil)).Elem(), EventArchiveMap{})
   381  	pulumi.RegisterOutputType(EventArchiveOutput{})
   382  	pulumi.RegisterOutputType(EventArchiveArrayOutput{})
   383  	pulumi.RegisterOutputType(EventArchiveMapOutput{})
   384  }