github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/cloudfront/realtimeLogConfig.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 cloudfront
     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 CloudFront real-time log configuration 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/cloudfront"
    26  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iam"
    27  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    28  //
    29  // )
    30  // func main() {
    31  // pulumi.Run(func(ctx *pulumi.Context) error {
    32  // assumeRole, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
    33  // Statements: []iam.GetPolicyDocumentStatement{
    34  // {
    35  // Effect: pulumi.StringRef("Allow"),
    36  // Principals: []iam.GetPolicyDocumentStatementPrincipal{
    37  // {
    38  // Type: "Service",
    39  // Identifiers: []string{
    40  // "cloudfront.amazonaws.com",
    41  // },
    42  // },
    43  // },
    44  // Actions: []string{
    45  // "sts:AssumeRole",
    46  // },
    47  // },
    48  // },
    49  // }, nil);
    50  // if err != nil {
    51  // return err
    52  // }
    53  // exampleRole, err := iam.NewRole(ctx, "example", &iam.RoleArgs{
    54  // Name: pulumi.String("cloudfront-realtime-log-config-example"),
    55  // AssumeRolePolicy: pulumi.String(assumeRole.Json),
    56  // })
    57  // if err != nil {
    58  // return err
    59  // }
    60  // example, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
    61  // Statements: []iam.GetPolicyDocumentStatement{
    62  // {
    63  // Effect: pulumi.StringRef("Allow"),
    64  // Actions: []string{
    65  // "kinesis:DescribeStreamSummary",
    66  // "kinesis:DescribeStream",
    67  // "kinesis:PutRecord",
    68  // "kinesis:PutRecords",
    69  // },
    70  // Resources: interface{}{
    71  // exampleAwsKinesisStream.Arn,
    72  // },
    73  // },
    74  // },
    75  // }, nil);
    76  // if err != nil {
    77  // return err
    78  // }
    79  // exampleRolePolicy, err := iam.NewRolePolicy(ctx, "example", &iam.RolePolicyArgs{
    80  // Name: pulumi.String("cloudfront-realtime-log-config-example"),
    81  // Role: exampleRole.ID(),
    82  // Policy: pulumi.String(example.Json),
    83  // })
    84  // if err != nil {
    85  // return err
    86  // }
    87  // _, err = cloudfront.NewRealtimeLogConfig(ctx, "example", &cloudfront.RealtimeLogConfigArgs{
    88  // Name: pulumi.String("example"),
    89  // SamplingRate: pulumi.Int(75),
    90  // Fields: pulumi.StringArray{
    91  // pulumi.String("timestamp"),
    92  // pulumi.String("c-ip"),
    93  // },
    94  // Endpoint: &cloudfront.RealtimeLogConfigEndpointArgs{
    95  // StreamType: pulumi.String("Kinesis"),
    96  // KinesisStreamConfig: &cloudfront.RealtimeLogConfigEndpointKinesisStreamConfigArgs{
    97  // RoleArn: exampleRole.Arn,
    98  // StreamArn: pulumi.Any(exampleAwsKinesisStream.Arn),
    99  // },
   100  // },
   101  // }, pulumi.DependsOn([]pulumi.Resource{
   102  // exampleRolePolicy,
   103  // }))
   104  // if err != nil {
   105  // return err
   106  // }
   107  // return nil
   108  // })
   109  // }
   110  // ```
   111  // <!--End PulumiCodeChooser -->
   112  //
   113  // ## Import
   114  //
   115  // Using `pulumi import`, import CloudFront real-time log configurations using the ARN. For example:
   116  //
   117  // ```sh
   118  // $ pulumi import aws:cloudfront/realtimeLogConfig:RealtimeLogConfig example arn:aws:cloudfront::111122223333:realtime-log-config/ExampleNameForRealtimeLogConfig
   119  // ```
   120  type RealtimeLogConfig struct {
   121  	pulumi.CustomResourceState
   122  
   123  	// The ARN (Amazon Resource Name) of the CloudFront real-time log configuration.
   124  	Arn pulumi.StringOutput `pulumi:"arn"`
   125  	// The Amazon Kinesis data streams where real-time log data is sent.
   126  	Endpoint RealtimeLogConfigEndpointOutput `pulumi:"endpoint"`
   127  	// The fields that are included in each real-time log record. See the [AWS documentation](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/real-time-logs.html#understand-real-time-log-config-fields) for supported values.
   128  	Fields pulumi.StringArrayOutput `pulumi:"fields"`
   129  	// The unique name to identify this real-time log configuration.
   130  	Name pulumi.StringOutput `pulumi:"name"`
   131  	// The sampling rate for this real-time log configuration. The sampling rate determines the percentage of viewer requests that are represented in the real-time log data. An integer between `1` and `100`, inclusive.
   132  	SamplingRate pulumi.IntOutput `pulumi:"samplingRate"`
   133  }
   134  
   135  // NewRealtimeLogConfig registers a new resource with the given unique name, arguments, and options.
   136  func NewRealtimeLogConfig(ctx *pulumi.Context,
   137  	name string, args *RealtimeLogConfigArgs, opts ...pulumi.ResourceOption) (*RealtimeLogConfig, error) {
   138  	if args == nil {
   139  		return nil, errors.New("missing one or more required arguments")
   140  	}
   141  
   142  	if args.Endpoint == nil {
   143  		return nil, errors.New("invalid value for required argument 'Endpoint'")
   144  	}
   145  	if args.Fields == nil {
   146  		return nil, errors.New("invalid value for required argument 'Fields'")
   147  	}
   148  	if args.SamplingRate == nil {
   149  		return nil, errors.New("invalid value for required argument 'SamplingRate'")
   150  	}
   151  	opts = internal.PkgResourceDefaultOpts(opts)
   152  	var resource RealtimeLogConfig
   153  	err := ctx.RegisterResource("aws:cloudfront/realtimeLogConfig:RealtimeLogConfig", name, args, &resource, opts...)
   154  	if err != nil {
   155  		return nil, err
   156  	}
   157  	return &resource, nil
   158  }
   159  
   160  // GetRealtimeLogConfig gets an existing RealtimeLogConfig resource's state with the given name, ID, and optional
   161  // state properties that are used to uniquely qualify the lookup (nil if not required).
   162  func GetRealtimeLogConfig(ctx *pulumi.Context,
   163  	name string, id pulumi.IDInput, state *RealtimeLogConfigState, opts ...pulumi.ResourceOption) (*RealtimeLogConfig, error) {
   164  	var resource RealtimeLogConfig
   165  	err := ctx.ReadResource("aws:cloudfront/realtimeLogConfig:RealtimeLogConfig", name, id, state, &resource, opts...)
   166  	if err != nil {
   167  		return nil, err
   168  	}
   169  	return &resource, nil
   170  }
   171  
   172  // Input properties used for looking up and filtering RealtimeLogConfig resources.
   173  type realtimeLogConfigState struct {
   174  	// The ARN (Amazon Resource Name) of the CloudFront real-time log configuration.
   175  	Arn *string `pulumi:"arn"`
   176  	// The Amazon Kinesis data streams where real-time log data is sent.
   177  	Endpoint *RealtimeLogConfigEndpoint `pulumi:"endpoint"`
   178  	// The fields that are included in each real-time log record. See the [AWS documentation](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/real-time-logs.html#understand-real-time-log-config-fields) for supported values.
   179  	Fields []string `pulumi:"fields"`
   180  	// The unique name to identify this real-time log configuration.
   181  	Name *string `pulumi:"name"`
   182  	// The sampling rate for this real-time log configuration. The sampling rate determines the percentage of viewer requests that are represented in the real-time log data. An integer between `1` and `100`, inclusive.
   183  	SamplingRate *int `pulumi:"samplingRate"`
   184  }
   185  
   186  type RealtimeLogConfigState struct {
   187  	// The ARN (Amazon Resource Name) of the CloudFront real-time log configuration.
   188  	Arn pulumi.StringPtrInput
   189  	// The Amazon Kinesis data streams where real-time log data is sent.
   190  	Endpoint RealtimeLogConfigEndpointPtrInput
   191  	// The fields that are included in each real-time log record. See the [AWS documentation](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/real-time-logs.html#understand-real-time-log-config-fields) for supported values.
   192  	Fields pulumi.StringArrayInput
   193  	// The unique name to identify this real-time log configuration.
   194  	Name pulumi.StringPtrInput
   195  	// The sampling rate for this real-time log configuration. The sampling rate determines the percentage of viewer requests that are represented in the real-time log data. An integer between `1` and `100`, inclusive.
   196  	SamplingRate pulumi.IntPtrInput
   197  }
   198  
   199  func (RealtimeLogConfigState) ElementType() reflect.Type {
   200  	return reflect.TypeOf((*realtimeLogConfigState)(nil)).Elem()
   201  }
   202  
   203  type realtimeLogConfigArgs struct {
   204  	// The Amazon Kinesis data streams where real-time log data is sent.
   205  	Endpoint RealtimeLogConfigEndpoint `pulumi:"endpoint"`
   206  	// The fields that are included in each real-time log record. See the [AWS documentation](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/real-time-logs.html#understand-real-time-log-config-fields) for supported values.
   207  	Fields []string `pulumi:"fields"`
   208  	// The unique name to identify this real-time log configuration.
   209  	Name *string `pulumi:"name"`
   210  	// The sampling rate for this real-time log configuration. The sampling rate determines the percentage of viewer requests that are represented in the real-time log data. An integer between `1` and `100`, inclusive.
   211  	SamplingRate int `pulumi:"samplingRate"`
   212  }
   213  
   214  // The set of arguments for constructing a RealtimeLogConfig resource.
   215  type RealtimeLogConfigArgs struct {
   216  	// The Amazon Kinesis data streams where real-time log data is sent.
   217  	Endpoint RealtimeLogConfigEndpointInput
   218  	// The fields that are included in each real-time log record. See the [AWS documentation](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/real-time-logs.html#understand-real-time-log-config-fields) for supported values.
   219  	Fields pulumi.StringArrayInput
   220  	// The unique name to identify this real-time log configuration.
   221  	Name pulumi.StringPtrInput
   222  	// The sampling rate for this real-time log configuration. The sampling rate determines the percentage of viewer requests that are represented in the real-time log data. An integer between `1` and `100`, inclusive.
   223  	SamplingRate pulumi.IntInput
   224  }
   225  
   226  func (RealtimeLogConfigArgs) ElementType() reflect.Type {
   227  	return reflect.TypeOf((*realtimeLogConfigArgs)(nil)).Elem()
   228  }
   229  
   230  type RealtimeLogConfigInput interface {
   231  	pulumi.Input
   232  
   233  	ToRealtimeLogConfigOutput() RealtimeLogConfigOutput
   234  	ToRealtimeLogConfigOutputWithContext(ctx context.Context) RealtimeLogConfigOutput
   235  }
   236  
   237  func (*RealtimeLogConfig) ElementType() reflect.Type {
   238  	return reflect.TypeOf((**RealtimeLogConfig)(nil)).Elem()
   239  }
   240  
   241  func (i *RealtimeLogConfig) ToRealtimeLogConfigOutput() RealtimeLogConfigOutput {
   242  	return i.ToRealtimeLogConfigOutputWithContext(context.Background())
   243  }
   244  
   245  func (i *RealtimeLogConfig) ToRealtimeLogConfigOutputWithContext(ctx context.Context) RealtimeLogConfigOutput {
   246  	return pulumi.ToOutputWithContext(ctx, i).(RealtimeLogConfigOutput)
   247  }
   248  
   249  // RealtimeLogConfigArrayInput is an input type that accepts RealtimeLogConfigArray and RealtimeLogConfigArrayOutput values.
   250  // You can construct a concrete instance of `RealtimeLogConfigArrayInput` via:
   251  //
   252  //	RealtimeLogConfigArray{ RealtimeLogConfigArgs{...} }
   253  type RealtimeLogConfigArrayInput interface {
   254  	pulumi.Input
   255  
   256  	ToRealtimeLogConfigArrayOutput() RealtimeLogConfigArrayOutput
   257  	ToRealtimeLogConfigArrayOutputWithContext(context.Context) RealtimeLogConfigArrayOutput
   258  }
   259  
   260  type RealtimeLogConfigArray []RealtimeLogConfigInput
   261  
   262  func (RealtimeLogConfigArray) ElementType() reflect.Type {
   263  	return reflect.TypeOf((*[]*RealtimeLogConfig)(nil)).Elem()
   264  }
   265  
   266  func (i RealtimeLogConfigArray) ToRealtimeLogConfigArrayOutput() RealtimeLogConfigArrayOutput {
   267  	return i.ToRealtimeLogConfigArrayOutputWithContext(context.Background())
   268  }
   269  
   270  func (i RealtimeLogConfigArray) ToRealtimeLogConfigArrayOutputWithContext(ctx context.Context) RealtimeLogConfigArrayOutput {
   271  	return pulumi.ToOutputWithContext(ctx, i).(RealtimeLogConfigArrayOutput)
   272  }
   273  
   274  // RealtimeLogConfigMapInput is an input type that accepts RealtimeLogConfigMap and RealtimeLogConfigMapOutput values.
   275  // You can construct a concrete instance of `RealtimeLogConfigMapInput` via:
   276  //
   277  //	RealtimeLogConfigMap{ "key": RealtimeLogConfigArgs{...} }
   278  type RealtimeLogConfigMapInput interface {
   279  	pulumi.Input
   280  
   281  	ToRealtimeLogConfigMapOutput() RealtimeLogConfigMapOutput
   282  	ToRealtimeLogConfigMapOutputWithContext(context.Context) RealtimeLogConfigMapOutput
   283  }
   284  
   285  type RealtimeLogConfigMap map[string]RealtimeLogConfigInput
   286  
   287  func (RealtimeLogConfigMap) ElementType() reflect.Type {
   288  	return reflect.TypeOf((*map[string]*RealtimeLogConfig)(nil)).Elem()
   289  }
   290  
   291  func (i RealtimeLogConfigMap) ToRealtimeLogConfigMapOutput() RealtimeLogConfigMapOutput {
   292  	return i.ToRealtimeLogConfigMapOutputWithContext(context.Background())
   293  }
   294  
   295  func (i RealtimeLogConfigMap) ToRealtimeLogConfigMapOutputWithContext(ctx context.Context) RealtimeLogConfigMapOutput {
   296  	return pulumi.ToOutputWithContext(ctx, i).(RealtimeLogConfigMapOutput)
   297  }
   298  
   299  type RealtimeLogConfigOutput struct{ *pulumi.OutputState }
   300  
   301  func (RealtimeLogConfigOutput) ElementType() reflect.Type {
   302  	return reflect.TypeOf((**RealtimeLogConfig)(nil)).Elem()
   303  }
   304  
   305  func (o RealtimeLogConfigOutput) ToRealtimeLogConfigOutput() RealtimeLogConfigOutput {
   306  	return o
   307  }
   308  
   309  func (o RealtimeLogConfigOutput) ToRealtimeLogConfigOutputWithContext(ctx context.Context) RealtimeLogConfigOutput {
   310  	return o
   311  }
   312  
   313  // The ARN (Amazon Resource Name) of the CloudFront real-time log configuration.
   314  func (o RealtimeLogConfigOutput) Arn() pulumi.StringOutput {
   315  	return o.ApplyT(func(v *RealtimeLogConfig) pulumi.StringOutput { return v.Arn }).(pulumi.StringOutput)
   316  }
   317  
   318  // The Amazon Kinesis data streams where real-time log data is sent.
   319  func (o RealtimeLogConfigOutput) Endpoint() RealtimeLogConfigEndpointOutput {
   320  	return o.ApplyT(func(v *RealtimeLogConfig) RealtimeLogConfigEndpointOutput { return v.Endpoint }).(RealtimeLogConfigEndpointOutput)
   321  }
   322  
   323  // The fields that are included in each real-time log record. See the [AWS documentation](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/real-time-logs.html#understand-real-time-log-config-fields) for supported values.
   324  func (o RealtimeLogConfigOutput) Fields() pulumi.StringArrayOutput {
   325  	return o.ApplyT(func(v *RealtimeLogConfig) pulumi.StringArrayOutput { return v.Fields }).(pulumi.StringArrayOutput)
   326  }
   327  
   328  // The unique name to identify this real-time log configuration.
   329  func (o RealtimeLogConfigOutput) Name() pulumi.StringOutput {
   330  	return o.ApplyT(func(v *RealtimeLogConfig) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
   331  }
   332  
   333  // The sampling rate for this real-time log configuration. The sampling rate determines the percentage of viewer requests that are represented in the real-time log data. An integer between `1` and `100`, inclusive.
   334  func (o RealtimeLogConfigOutput) SamplingRate() pulumi.IntOutput {
   335  	return o.ApplyT(func(v *RealtimeLogConfig) pulumi.IntOutput { return v.SamplingRate }).(pulumi.IntOutput)
   336  }
   337  
   338  type RealtimeLogConfigArrayOutput struct{ *pulumi.OutputState }
   339  
   340  func (RealtimeLogConfigArrayOutput) ElementType() reflect.Type {
   341  	return reflect.TypeOf((*[]*RealtimeLogConfig)(nil)).Elem()
   342  }
   343  
   344  func (o RealtimeLogConfigArrayOutput) ToRealtimeLogConfigArrayOutput() RealtimeLogConfigArrayOutput {
   345  	return o
   346  }
   347  
   348  func (o RealtimeLogConfigArrayOutput) ToRealtimeLogConfigArrayOutputWithContext(ctx context.Context) RealtimeLogConfigArrayOutput {
   349  	return o
   350  }
   351  
   352  func (o RealtimeLogConfigArrayOutput) Index(i pulumi.IntInput) RealtimeLogConfigOutput {
   353  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *RealtimeLogConfig {
   354  		return vs[0].([]*RealtimeLogConfig)[vs[1].(int)]
   355  	}).(RealtimeLogConfigOutput)
   356  }
   357  
   358  type RealtimeLogConfigMapOutput struct{ *pulumi.OutputState }
   359  
   360  func (RealtimeLogConfigMapOutput) ElementType() reflect.Type {
   361  	return reflect.TypeOf((*map[string]*RealtimeLogConfig)(nil)).Elem()
   362  }
   363  
   364  func (o RealtimeLogConfigMapOutput) ToRealtimeLogConfigMapOutput() RealtimeLogConfigMapOutput {
   365  	return o
   366  }
   367  
   368  func (o RealtimeLogConfigMapOutput) ToRealtimeLogConfigMapOutputWithContext(ctx context.Context) RealtimeLogConfigMapOutput {
   369  	return o
   370  }
   371  
   372  func (o RealtimeLogConfigMapOutput) MapIndex(k pulumi.StringInput) RealtimeLogConfigOutput {
   373  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *RealtimeLogConfig {
   374  		return vs[0].(map[string]*RealtimeLogConfig)[vs[1].(string)]
   375  	}).(RealtimeLogConfigOutput)
   376  }
   377  
   378  func init() {
   379  	pulumi.RegisterInputType(reflect.TypeOf((*RealtimeLogConfigInput)(nil)).Elem(), &RealtimeLogConfig{})
   380  	pulumi.RegisterInputType(reflect.TypeOf((*RealtimeLogConfigArrayInput)(nil)).Elem(), RealtimeLogConfigArray{})
   381  	pulumi.RegisterInputType(reflect.TypeOf((*RealtimeLogConfigMapInput)(nil)).Elem(), RealtimeLogConfigMap{})
   382  	pulumi.RegisterOutputType(RealtimeLogConfigOutput{})
   383  	pulumi.RegisterOutputType(RealtimeLogConfigArrayOutput{})
   384  	pulumi.RegisterOutputType(RealtimeLogConfigMapOutput{})
   385  }