github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/pinpoint/eventStream.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 pinpoint
     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 Pinpoint Event Stream resource.
    16  //
    17  // ## Example Usage
    18  //
    19  // <!--Start PulumiCodeChooser -->
    20  // ```go
    21  // package main
    22  //
    23  // import (
    24  //
    25  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iam"
    26  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/kinesis"
    27  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/pinpoint"
    28  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    29  //
    30  // )
    31  //
    32  //	func main() {
    33  //		pulumi.Run(func(ctx *pulumi.Context) error {
    34  //			app, err := pinpoint.NewApp(ctx, "app", nil)
    35  //			if err != nil {
    36  //				return err
    37  //			}
    38  //			testStream, err := kinesis.NewStream(ctx, "test_stream", &kinesis.StreamArgs{
    39  //				Name:       pulumi.String("pinpoint-kinesis-test"),
    40  //				ShardCount: pulumi.Int(1),
    41  //			})
    42  //			if err != nil {
    43  //				return err
    44  //			}
    45  //			assumeRole, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
    46  //				Statements: []iam.GetPolicyDocumentStatement{
    47  //					{
    48  //						Effect: pulumi.StringRef("Allow"),
    49  //						Principals: []iam.GetPolicyDocumentStatementPrincipal{
    50  //							{
    51  //								Type: "Service",
    52  //								Identifiers: []string{
    53  //									"pinpoint.us-east-1.amazonaws.com",
    54  //								},
    55  //							},
    56  //						},
    57  //						Actions: []string{
    58  //							"sts:AssumeRole",
    59  //						},
    60  //					},
    61  //				},
    62  //			}, nil)
    63  //			if err != nil {
    64  //				return err
    65  //			}
    66  //			testRole, err := iam.NewRole(ctx, "test_role", &iam.RoleArgs{
    67  //				AssumeRolePolicy: pulumi.String(assumeRole.Json),
    68  //			})
    69  //			if err != nil {
    70  //				return err
    71  //			}
    72  //			_, err = pinpoint.NewEventStream(ctx, "stream", &pinpoint.EventStreamArgs{
    73  //				ApplicationId:        app.ApplicationId,
    74  //				DestinationStreamArn: testStream.Arn,
    75  //				RoleArn:              testRole.Arn,
    76  //			})
    77  //			if err != nil {
    78  //				return err
    79  //			}
    80  //			testRolePolicy, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
    81  //				Statements: []iam.GetPolicyDocumentStatement{
    82  //					{
    83  //						Effect: pulumi.StringRef("Allow"),
    84  //						Actions: []string{
    85  //							"kinesis:PutRecords",
    86  //							"kinesis:DescribeStream",
    87  //						},
    88  //						Resources: []string{
    89  //							"arn:aws:kinesis:us-east-1:*:*/*",
    90  //						},
    91  //					},
    92  //				},
    93  //			}, nil)
    94  //			if err != nil {
    95  //				return err
    96  //			}
    97  //			_, err = iam.NewRolePolicy(ctx, "test_role_policy", &iam.RolePolicyArgs{
    98  //				Name:   pulumi.String("test_policy"),
    99  //				Role:   testRole.ID(),
   100  //				Policy: pulumi.String(testRolePolicy.Json),
   101  //			})
   102  //			if err != nil {
   103  //				return err
   104  //			}
   105  //			return nil
   106  //		})
   107  //	}
   108  //
   109  // ```
   110  // <!--End PulumiCodeChooser -->
   111  //
   112  // ## Import
   113  //
   114  // Using `pulumi import`, import Pinpoint Event Stream using the `application-id`. For example:
   115  //
   116  // ```sh
   117  // $ pulumi import aws:pinpoint/eventStream:EventStream stream application-id
   118  // ```
   119  type EventStream struct {
   120  	pulumi.CustomResourceState
   121  
   122  	// The application ID.
   123  	ApplicationId pulumi.StringOutput `pulumi:"applicationId"`
   124  	// The Amazon Resource Name (ARN) of the Amazon Kinesis stream or Firehose delivery stream to which you want to publish events.
   125  	DestinationStreamArn pulumi.StringOutput `pulumi:"destinationStreamArn"`
   126  	// The IAM role that authorizes Amazon Pinpoint to publish events to the stream in your account.
   127  	RoleArn pulumi.StringOutput `pulumi:"roleArn"`
   128  }
   129  
   130  // NewEventStream registers a new resource with the given unique name, arguments, and options.
   131  func NewEventStream(ctx *pulumi.Context,
   132  	name string, args *EventStreamArgs, opts ...pulumi.ResourceOption) (*EventStream, error) {
   133  	if args == nil {
   134  		return nil, errors.New("missing one or more required arguments")
   135  	}
   136  
   137  	if args.ApplicationId == nil {
   138  		return nil, errors.New("invalid value for required argument 'ApplicationId'")
   139  	}
   140  	if args.DestinationStreamArn == nil {
   141  		return nil, errors.New("invalid value for required argument 'DestinationStreamArn'")
   142  	}
   143  	if args.RoleArn == nil {
   144  		return nil, errors.New("invalid value for required argument 'RoleArn'")
   145  	}
   146  	opts = internal.PkgResourceDefaultOpts(opts)
   147  	var resource EventStream
   148  	err := ctx.RegisterResource("aws:pinpoint/eventStream:EventStream", name, args, &resource, opts...)
   149  	if err != nil {
   150  		return nil, err
   151  	}
   152  	return &resource, nil
   153  }
   154  
   155  // GetEventStream gets an existing EventStream resource's state with the given name, ID, and optional
   156  // state properties that are used to uniquely qualify the lookup (nil if not required).
   157  func GetEventStream(ctx *pulumi.Context,
   158  	name string, id pulumi.IDInput, state *EventStreamState, opts ...pulumi.ResourceOption) (*EventStream, error) {
   159  	var resource EventStream
   160  	err := ctx.ReadResource("aws:pinpoint/eventStream:EventStream", name, id, state, &resource, opts...)
   161  	if err != nil {
   162  		return nil, err
   163  	}
   164  	return &resource, nil
   165  }
   166  
   167  // Input properties used for looking up and filtering EventStream resources.
   168  type eventStreamState struct {
   169  	// The application ID.
   170  	ApplicationId *string `pulumi:"applicationId"`
   171  	// The Amazon Resource Name (ARN) of the Amazon Kinesis stream or Firehose delivery stream to which you want to publish events.
   172  	DestinationStreamArn *string `pulumi:"destinationStreamArn"`
   173  	// The IAM role that authorizes Amazon Pinpoint to publish events to the stream in your account.
   174  	RoleArn *string `pulumi:"roleArn"`
   175  }
   176  
   177  type EventStreamState struct {
   178  	// The application ID.
   179  	ApplicationId pulumi.StringPtrInput
   180  	// The Amazon Resource Name (ARN) of the Amazon Kinesis stream or Firehose delivery stream to which you want to publish events.
   181  	DestinationStreamArn pulumi.StringPtrInput
   182  	// The IAM role that authorizes Amazon Pinpoint to publish events to the stream in your account.
   183  	RoleArn pulumi.StringPtrInput
   184  }
   185  
   186  func (EventStreamState) ElementType() reflect.Type {
   187  	return reflect.TypeOf((*eventStreamState)(nil)).Elem()
   188  }
   189  
   190  type eventStreamArgs struct {
   191  	// The application ID.
   192  	ApplicationId string `pulumi:"applicationId"`
   193  	// The Amazon Resource Name (ARN) of the Amazon Kinesis stream or Firehose delivery stream to which you want to publish events.
   194  	DestinationStreamArn string `pulumi:"destinationStreamArn"`
   195  	// The IAM role that authorizes Amazon Pinpoint to publish events to the stream in your account.
   196  	RoleArn string `pulumi:"roleArn"`
   197  }
   198  
   199  // The set of arguments for constructing a EventStream resource.
   200  type EventStreamArgs struct {
   201  	// The application ID.
   202  	ApplicationId pulumi.StringInput
   203  	// The Amazon Resource Name (ARN) of the Amazon Kinesis stream or Firehose delivery stream to which you want to publish events.
   204  	DestinationStreamArn pulumi.StringInput
   205  	// The IAM role that authorizes Amazon Pinpoint to publish events to the stream in your account.
   206  	RoleArn pulumi.StringInput
   207  }
   208  
   209  func (EventStreamArgs) ElementType() reflect.Type {
   210  	return reflect.TypeOf((*eventStreamArgs)(nil)).Elem()
   211  }
   212  
   213  type EventStreamInput interface {
   214  	pulumi.Input
   215  
   216  	ToEventStreamOutput() EventStreamOutput
   217  	ToEventStreamOutputWithContext(ctx context.Context) EventStreamOutput
   218  }
   219  
   220  func (*EventStream) ElementType() reflect.Type {
   221  	return reflect.TypeOf((**EventStream)(nil)).Elem()
   222  }
   223  
   224  func (i *EventStream) ToEventStreamOutput() EventStreamOutput {
   225  	return i.ToEventStreamOutputWithContext(context.Background())
   226  }
   227  
   228  func (i *EventStream) ToEventStreamOutputWithContext(ctx context.Context) EventStreamOutput {
   229  	return pulumi.ToOutputWithContext(ctx, i).(EventStreamOutput)
   230  }
   231  
   232  // EventStreamArrayInput is an input type that accepts EventStreamArray and EventStreamArrayOutput values.
   233  // You can construct a concrete instance of `EventStreamArrayInput` via:
   234  //
   235  //	EventStreamArray{ EventStreamArgs{...} }
   236  type EventStreamArrayInput interface {
   237  	pulumi.Input
   238  
   239  	ToEventStreamArrayOutput() EventStreamArrayOutput
   240  	ToEventStreamArrayOutputWithContext(context.Context) EventStreamArrayOutput
   241  }
   242  
   243  type EventStreamArray []EventStreamInput
   244  
   245  func (EventStreamArray) ElementType() reflect.Type {
   246  	return reflect.TypeOf((*[]*EventStream)(nil)).Elem()
   247  }
   248  
   249  func (i EventStreamArray) ToEventStreamArrayOutput() EventStreamArrayOutput {
   250  	return i.ToEventStreamArrayOutputWithContext(context.Background())
   251  }
   252  
   253  func (i EventStreamArray) ToEventStreamArrayOutputWithContext(ctx context.Context) EventStreamArrayOutput {
   254  	return pulumi.ToOutputWithContext(ctx, i).(EventStreamArrayOutput)
   255  }
   256  
   257  // EventStreamMapInput is an input type that accepts EventStreamMap and EventStreamMapOutput values.
   258  // You can construct a concrete instance of `EventStreamMapInput` via:
   259  //
   260  //	EventStreamMap{ "key": EventStreamArgs{...} }
   261  type EventStreamMapInput interface {
   262  	pulumi.Input
   263  
   264  	ToEventStreamMapOutput() EventStreamMapOutput
   265  	ToEventStreamMapOutputWithContext(context.Context) EventStreamMapOutput
   266  }
   267  
   268  type EventStreamMap map[string]EventStreamInput
   269  
   270  func (EventStreamMap) ElementType() reflect.Type {
   271  	return reflect.TypeOf((*map[string]*EventStream)(nil)).Elem()
   272  }
   273  
   274  func (i EventStreamMap) ToEventStreamMapOutput() EventStreamMapOutput {
   275  	return i.ToEventStreamMapOutputWithContext(context.Background())
   276  }
   277  
   278  func (i EventStreamMap) ToEventStreamMapOutputWithContext(ctx context.Context) EventStreamMapOutput {
   279  	return pulumi.ToOutputWithContext(ctx, i).(EventStreamMapOutput)
   280  }
   281  
   282  type EventStreamOutput struct{ *pulumi.OutputState }
   283  
   284  func (EventStreamOutput) ElementType() reflect.Type {
   285  	return reflect.TypeOf((**EventStream)(nil)).Elem()
   286  }
   287  
   288  func (o EventStreamOutput) ToEventStreamOutput() EventStreamOutput {
   289  	return o
   290  }
   291  
   292  func (o EventStreamOutput) ToEventStreamOutputWithContext(ctx context.Context) EventStreamOutput {
   293  	return o
   294  }
   295  
   296  // The application ID.
   297  func (o EventStreamOutput) ApplicationId() pulumi.StringOutput {
   298  	return o.ApplyT(func(v *EventStream) pulumi.StringOutput { return v.ApplicationId }).(pulumi.StringOutput)
   299  }
   300  
   301  // The Amazon Resource Name (ARN) of the Amazon Kinesis stream or Firehose delivery stream to which you want to publish events.
   302  func (o EventStreamOutput) DestinationStreamArn() pulumi.StringOutput {
   303  	return o.ApplyT(func(v *EventStream) pulumi.StringOutput { return v.DestinationStreamArn }).(pulumi.StringOutput)
   304  }
   305  
   306  // The IAM role that authorizes Amazon Pinpoint to publish events to the stream in your account.
   307  func (o EventStreamOutput) RoleArn() pulumi.StringOutput {
   308  	return o.ApplyT(func(v *EventStream) pulumi.StringOutput { return v.RoleArn }).(pulumi.StringOutput)
   309  }
   310  
   311  type EventStreamArrayOutput struct{ *pulumi.OutputState }
   312  
   313  func (EventStreamArrayOutput) ElementType() reflect.Type {
   314  	return reflect.TypeOf((*[]*EventStream)(nil)).Elem()
   315  }
   316  
   317  func (o EventStreamArrayOutput) ToEventStreamArrayOutput() EventStreamArrayOutput {
   318  	return o
   319  }
   320  
   321  func (o EventStreamArrayOutput) ToEventStreamArrayOutputWithContext(ctx context.Context) EventStreamArrayOutput {
   322  	return o
   323  }
   324  
   325  func (o EventStreamArrayOutput) Index(i pulumi.IntInput) EventStreamOutput {
   326  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *EventStream {
   327  		return vs[0].([]*EventStream)[vs[1].(int)]
   328  	}).(EventStreamOutput)
   329  }
   330  
   331  type EventStreamMapOutput struct{ *pulumi.OutputState }
   332  
   333  func (EventStreamMapOutput) ElementType() reflect.Type {
   334  	return reflect.TypeOf((*map[string]*EventStream)(nil)).Elem()
   335  }
   336  
   337  func (o EventStreamMapOutput) ToEventStreamMapOutput() EventStreamMapOutput {
   338  	return o
   339  }
   340  
   341  func (o EventStreamMapOutput) ToEventStreamMapOutputWithContext(ctx context.Context) EventStreamMapOutput {
   342  	return o
   343  }
   344  
   345  func (o EventStreamMapOutput) MapIndex(k pulumi.StringInput) EventStreamOutput {
   346  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *EventStream {
   347  		return vs[0].(map[string]*EventStream)[vs[1].(string)]
   348  	}).(EventStreamOutput)
   349  }
   350  
   351  func init() {
   352  	pulumi.RegisterInputType(reflect.TypeOf((*EventStreamInput)(nil)).Elem(), &EventStream{})
   353  	pulumi.RegisterInputType(reflect.TypeOf((*EventStreamArrayInput)(nil)).Elem(), EventStreamArray{})
   354  	pulumi.RegisterInputType(reflect.TypeOf((*EventStreamMapInput)(nil)).Elem(), EventStreamMap{})
   355  	pulumi.RegisterOutputType(EventStreamOutput{})
   356  	pulumi.RegisterOutputType(EventStreamArrayOutput{})
   357  	pulumi.RegisterOutputType(EventStreamMapOutput{})
   358  }