github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/cfg/deliveryChannel.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 cfg
     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 AWS Config Delivery Channel.
    16  //
    17  // > **Note:** Delivery Channel requires a Configuration Recorder to be present. Use of `dependsOn` (as shown below) is recommended to avoid race conditions.
    18  //
    19  // ## Example Usage
    20  //
    21  // <!--Start PulumiCodeChooser -->
    22  // ```go
    23  // package main
    24  //
    25  // import (
    26  //
    27  //	"fmt"
    28  //
    29  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/cfg"
    30  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iam"
    31  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/s3"
    32  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    33  //
    34  // )
    35  //
    36  //	func main() {
    37  //		pulumi.Run(func(ctx *pulumi.Context) error {
    38  //			b, err := s3.NewBucketV2(ctx, "b", &s3.BucketV2Args{
    39  //				Bucket:       pulumi.String("example-awsconfig"),
    40  //				ForceDestroy: pulumi.Bool(true),
    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  //									"config.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  //			r, err := iam.NewRole(ctx, "r", &iam.RoleArgs{
    67  //				Name:             pulumi.String("awsconfig-example"),
    68  //				AssumeRolePolicy: pulumi.String(assumeRole.Json),
    69  //			})
    70  //			if err != nil {
    71  //				return err
    72  //			}
    73  //			fooRecorder, err := cfg.NewRecorder(ctx, "foo", &cfg.RecorderArgs{
    74  //				Name:    pulumi.String("example"),
    75  //				RoleArn: r.Arn,
    76  //			})
    77  //			if err != nil {
    78  //				return err
    79  //			}
    80  //			_, err = cfg.NewDeliveryChannel(ctx, "foo", &cfg.DeliveryChannelArgs{
    81  //				Name:         pulumi.String("example"),
    82  //				S3BucketName: b.Bucket,
    83  //			}, pulumi.DependsOn([]pulumi.Resource{
    84  //				fooRecorder,
    85  //			}))
    86  //			if err != nil {
    87  //				return err
    88  //			}
    89  //			p := iam.GetPolicyDocumentOutput(ctx, iam.GetPolicyDocumentOutputArgs{
    90  //				Statements: iam.GetPolicyDocumentStatementArray{
    91  //					&iam.GetPolicyDocumentStatementArgs{
    92  //						Effect: pulumi.String("Allow"),
    93  //						Actions: pulumi.StringArray{
    94  //							pulumi.String("s3:*"),
    95  //						},
    96  //						Resources: pulumi.StringArray{
    97  //							b.Arn,
    98  //							b.Arn.ApplyT(func(arn string) (string, error) {
    99  //								return fmt.Sprintf("%v/*", arn), nil
   100  //							}).(pulumi.StringOutput),
   101  //						},
   102  //					},
   103  //				},
   104  //			}, nil)
   105  //			_, err = iam.NewRolePolicy(ctx, "p", &iam.RolePolicyArgs{
   106  //				Name: pulumi.String("awsconfig-example"),
   107  //				Role: r.ID(),
   108  //				Policy: p.ApplyT(func(p iam.GetPolicyDocumentResult) (*string, error) {
   109  //					return &p.Json, nil
   110  //				}).(pulumi.StringPtrOutput),
   111  //			})
   112  //			if err != nil {
   113  //				return err
   114  //			}
   115  //			return nil
   116  //		})
   117  //	}
   118  //
   119  // ```
   120  // <!--End PulumiCodeChooser -->
   121  //
   122  // ## Import
   123  //
   124  // Using `pulumi import`, import Delivery Channel using the name. For example:
   125  //
   126  // ```sh
   127  // $ pulumi import aws:cfg/deliveryChannel:DeliveryChannel foo example
   128  // ```
   129  type DeliveryChannel struct {
   130  	pulumi.CustomResourceState
   131  
   132  	// The name of the delivery channel. Defaults to `default`. Changing it recreates the resource.
   133  	Name pulumi.StringOutput `pulumi:"name"`
   134  	// The name of the S3 bucket used to store the configuration history.
   135  	S3BucketName pulumi.StringOutput `pulumi:"s3BucketName"`
   136  	// The prefix for the specified S3 bucket.
   137  	S3KeyPrefix pulumi.StringPtrOutput `pulumi:"s3KeyPrefix"`
   138  	// The ARN of the AWS KMS key used to encrypt objects delivered by AWS Config. Must belong to the same Region as the destination S3 bucket.
   139  	S3KmsKeyArn pulumi.StringPtrOutput `pulumi:"s3KmsKeyArn"`
   140  	// Options for how AWS Config delivers configuration snapshots. See below
   141  	SnapshotDeliveryProperties DeliveryChannelSnapshotDeliveryPropertiesPtrOutput `pulumi:"snapshotDeliveryProperties"`
   142  	// The ARN of the SNS topic that AWS Config delivers notifications to.
   143  	SnsTopicArn pulumi.StringPtrOutput `pulumi:"snsTopicArn"`
   144  }
   145  
   146  // NewDeliveryChannel registers a new resource with the given unique name, arguments, and options.
   147  func NewDeliveryChannel(ctx *pulumi.Context,
   148  	name string, args *DeliveryChannelArgs, opts ...pulumi.ResourceOption) (*DeliveryChannel, error) {
   149  	if args == nil {
   150  		return nil, errors.New("missing one or more required arguments")
   151  	}
   152  
   153  	if args.S3BucketName == nil {
   154  		return nil, errors.New("invalid value for required argument 'S3BucketName'")
   155  	}
   156  	opts = internal.PkgResourceDefaultOpts(opts)
   157  	var resource DeliveryChannel
   158  	err := ctx.RegisterResource("aws:cfg/deliveryChannel:DeliveryChannel", name, args, &resource, opts...)
   159  	if err != nil {
   160  		return nil, err
   161  	}
   162  	return &resource, nil
   163  }
   164  
   165  // GetDeliveryChannel gets an existing DeliveryChannel resource's state with the given name, ID, and optional
   166  // state properties that are used to uniquely qualify the lookup (nil if not required).
   167  func GetDeliveryChannel(ctx *pulumi.Context,
   168  	name string, id pulumi.IDInput, state *DeliveryChannelState, opts ...pulumi.ResourceOption) (*DeliveryChannel, error) {
   169  	var resource DeliveryChannel
   170  	err := ctx.ReadResource("aws:cfg/deliveryChannel:DeliveryChannel", name, id, state, &resource, opts...)
   171  	if err != nil {
   172  		return nil, err
   173  	}
   174  	return &resource, nil
   175  }
   176  
   177  // Input properties used for looking up and filtering DeliveryChannel resources.
   178  type deliveryChannelState struct {
   179  	// The name of the delivery channel. Defaults to `default`. Changing it recreates the resource.
   180  	Name *string `pulumi:"name"`
   181  	// The name of the S3 bucket used to store the configuration history.
   182  	S3BucketName *string `pulumi:"s3BucketName"`
   183  	// The prefix for the specified S3 bucket.
   184  	S3KeyPrefix *string `pulumi:"s3KeyPrefix"`
   185  	// The ARN of the AWS KMS key used to encrypt objects delivered by AWS Config. Must belong to the same Region as the destination S3 bucket.
   186  	S3KmsKeyArn *string `pulumi:"s3KmsKeyArn"`
   187  	// Options for how AWS Config delivers configuration snapshots. See below
   188  	SnapshotDeliveryProperties *DeliveryChannelSnapshotDeliveryProperties `pulumi:"snapshotDeliveryProperties"`
   189  	// The ARN of the SNS topic that AWS Config delivers notifications to.
   190  	SnsTopicArn *string `pulumi:"snsTopicArn"`
   191  }
   192  
   193  type DeliveryChannelState struct {
   194  	// The name of the delivery channel. Defaults to `default`. Changing it recreates the resource.
   195  	Name pulumi.StringPtrInput
   196  	// The name of the S3 bucket used to store the configuration history.
   197  	S3BucketName pulumi.StringPtrInput
   198  	// The prefix for the specified S3 bucket.
   199  	S3KeyPrefix pulumi.StringPtrInput
   200  	// The ARN of the AWS KMS key used to encrypt objects delivered by AWS Config. Must belong to the same Region as the destination S3 bucket.
   201  	S3KmsKeyArn pulumi.StringPtrInput
   202  	// Options for how AWS Config delivers configuration snapshots. See below
   203  	SnapshotDeliveryProperties DeliveryChannelSnapshotDeliveryPropertiesPtrInput
   204  	// The ARN of the SNS topic that AWS Config delivers notifications to.
   205  	SnsTopicArn pulumi.StringPtrInput
   206  }
   207  
   208  func (DeliveryChannelState) ElementType() reflect.Type {
   209  	return reflect.TypeOf((*deliveryChannelState)(nil)).Elem()
   210  }
   211  
   212  type deliveryChannelArgs struct {
   213  	// The name of the delivery channel. Defaults to `default`. Changing it recreates the resource.
   214  	Name *string `pulumi:"name"`
   215  	// The name of the S3 bucket used to store the configuration history.
   216  	S3BucketName string `pulumi:"s3BucketName"`
   217  	// The prefix for the specified S3 bucket.
   218  	S3KeyPrefix *string `pulumi:"s3KeyPrefix"`
   219  	// The ARN of the AWS KMS key used to encrypt objects delivered by AWS Config. Must belong to the same Region as the destination S3 bucket.
   220  	S3KmsKeyArn *string `pulumi:"s3KmsKeyArn"`
   221  	// Options for how AWS Config delivers configuration snapshots. See below
   222  	SnapshotDeliveryProperties *DeliveryChannelSnapshotDeliveryProperties `pulumi:"snapshotDeliveryProperties"`
   223  	// The ARN of the SNS topic that AWS Config delivers notifications to.
   224  	SnsTopicArn *string `pulumi:"snsTopicArn"`
   225  }
   226  
   227  // The set of arguments for constructing a DeliveryChannel resource.
   228  type DeliveryChannelArgs struct {
   229  	// The name of the delivery channel. Defaults to `default`. Changing it recreates the resource.
   230  	Name pulumi.StringPtrInput
   231  	// The name of the S3 bucket used to store the configuration history.
   232  	S3BucketName pulumi.StringInput
   233  	// The prefix for the specified S3 bucket.
   234  	S3KeyPrefix pulumi.StringPtrInput
   235  	// The ARN of the AWS KMS key used to encrypt objects delivered by AWS Config. Must belong to the same Region as the destination S3 bucket.
   236  	S3KmsKeyArn pulumi.StringPtrInput
   237  	// Options for how AWS Config delivers configuration snapshots. See below
   238  	SnapshotDeliveryProperties DeliveryChannelSnapshotDeliveryPropertiesPtrInput
   239  	// The ARN of the SNS topic that AWS Config delivers notifications to.
   240  	SnsTopicArn pulumi.StringPtrInput
   241  }
   242  
   243  func (DeliveryChannelArgs) ElementType() reflect.Type {
   244  	return reflect.TypeOf((*deliveryChannelArgs)(nil)).Elem()
   245  }
   246  
   247  type DeliveryChannelInput interface {
   248  	pulumi.Input
   249  
   250  	ToDeliveryChannelOutput() DeliveryChannelOutput
   251  	ToDeliveryChannelOutputWithContext(ctx context.Context) DeliveryChannelOutput
   252  }
   253  
   254  func (*DeliveryChannel) ElementType() reflect.Type {
   255  	return reflect.TypeOf((**DeliveryChannel)(nil)).Elem()
   256  }
   257  
   258  func (i *DeliveryChannel) ToDeliveryChannelOutput() DeliveryChannelOutput {
   259  	return i.ToDeliveryChannelOutputWithContext(context.Background())
   260  }
   261  
   262  func (i *DeliveryChannel) ToDeliveryChannelOutputWithContext(ctx context.Context) DeliveryChannelOutput {
   263  	return pulumi.ToOutputWithContext(ctx, i).(DeliveryChannelOutput)
   264  }
   265  
   266  // DeliveryChannelArrayInput is an input type that accepts DeliveryChannelArray and DeliveryChannelArrayOutput values.
   267  // You can construct a concrete instance of `DeliveryChannelArrayInput` via:
   268  //
   269  //	DeliveryChannelArray{ DeliveryChannelArgs{...} }
   270  type DeliveryChannelArrayInput interface {
   271  	pulumi.Input
   272  
   273  	ToDeliveryChannelArrayOutput() DeliveryChannelArrayOutput
   274  	ToDeliveryChannelArrayOutputWithContext(context.Context) DeliveryChannelArrayOutput
   275  }
   276  
   277  type DeliveryChannelArray []DeliveryChannelInput
   278  
   279  func (DeliveryChannelArray) ElementType() reflect.Type {
   280  	return reflect.TypeOf((*[]*DeliveryChannel)(nil)).Elem()
   281  }
   282  
   283  func (i DeliveryChannelArray) ToDeliveryChannelArrayOutput() DeliveryChannelArrayOutput {
   284  	return i.ToDeliveryChannelArrayOutputWithContext(context.Background())
   285  }
   286  
   287  func (i DeliveryChannelArray) ToDeliveryChannelArrayOutputWithContext(ctx context.Context) DeliveryChannelArrayOutput {
   288  	return pulumi.ToOutputWithContext(ctx, i).(DeliveryChannelArrayOutput)
   289  }
   290  
   291  // DeliveryChannelMapInput is an input type that accepts DeliveryChannelMap and DeliveryChannelMapOutput values.
   292  // You can construct a concrete instance of `DeliveryChannelMapInput` via:
   293  //
   294  //	DeliveryChannelMap{ "key": DeliveryChannelArgs{...} }
   295  type DeliveryChannelMapInput interface {
   296  	pulumi.Input
   297  
   298  	ToDeliveryChannelMapOutput() DeliveryChannelMapOutput
   299  	ToDeliveryChannelMapOutputWithContext(context.Context) DeliveryChannelMapOutput
   300  }
   301  
   302  type DeliveryChannelMap map[string]DeliveryChannelInput
   303  
   304  func (DeliveryChannelMap) ElementType() reflect.Type {
   305  	return reflect.TypeOf((*map[string]*DeliveryChannel)(nil)).Elem()
   306  }
   307  
   308  func (i DeliveryChannelMap) ToDeliveryChannelMapOutput() DeliveryChannelMapOutput {
   309  	return i.ToDeliveryChannelMapOutputWithContext(context.Background())
   310  }
   311  
   312  func (i DeliveryChannelMap) ToDeliveryChannelMapOutputWithContext(ctx context.Context) DeliveryChannelMapOutput {
   313  	return pulumi.ToOutputWithContext(ctx, i).(DeliveryChannelMapOutput)
   314  }
   315  
   316  type DeliveryChannelOutput struct{ *pulumi.OutputState }
   317  
   318  func (DeliveryChannelOutput) ElementType() reflect.Type {
   319  	return reflect.TypeOf((**DeliveryChannel)(nil)).Elem()
   320  }
   321  
   322  func (o DeliveryChannelOutput) ToDeliveryChannelOutput() DeliveryChannelOutput {
   323  	return o
   324  }
   325  
   326  func (o DeliveryChannelOutput) ToDeliveryChannelOutputWithContext(ctx context.Context) DeliveryChannelOutput {
   327  	return o
   328  }
   329  
   330  // The name of the delivery channel. Defaults to `default`. Changing it recreates the resource.
   331  func (o DeliveryChannelOutput) Name() pulumi.StringOutput {
   332  	return o.ApplyT(func(v *DeliveryChannel) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
   333  }
   334  
   335  // The name of the S3 bucket used to store the configuration history.
   336  func (o DeliveryChannelOutput) S3BucketName() pulumi.StringOutput {
   337  	return o.ApplyT(func(v *DeliveryChannel) pulumi.StringOutput { return v.S3BucketName }).(pulumi.StringOutput)
   338  }
   339  
   340  // The prefix for the specified S3 bucket.
   341  func (o DeliveryChannelOutput) S3KeyPrefix() pulumi.StringPtrOutput {
   342  	return o.ApplyT(func(v *DeliveryChannel) pulumi.StringPtrOutput { return v.S3KeyPrefix }).(pulumi.StringPtrOutput)
   343  }
   344  
   345  // The ARN of the AWS KMS key used to encrypt objects delivered by AWS Config. Must belong to the same Region as the destination S3 bucket.
   346  func (o DeliveryChannelOutput) S3KmsKeyArn() pulumi.StringPtrOutput {
   347  	return o.ApplyT(func(v *DeliveryChannel) pulumi.StringPtrOutput { return v.S3KmsKeyArn }).(pulumi.StringPtrOutput)
   348  }
   349  
   350  // Options for how AWS Config delivers configuration snapshots. See below
   351  func (o DeliveryChannelOutput) SnapshotDeliveryProperties() DeliveryChannelSnapshotDeliveryPropertiesPtrOutput {
   352  	return o.ApplyT(func(v *DeliveryChannel) DeliveryChannelSnapshotDeliveryPropertiesPtrOutput {
   353  		return v.SnapshotDeliveryProperties
   354  	}).(DeliveryChannelSnapshotDeliveryPropertiesPtrOutput)
   355  }
   356  
   357  // The ARN of the SNS topic that AWS Config delivers notifications to.
   358  func (o DeliveryChannelOutput) SnsTopicArn() pulumi.StringPtrOutput {
   359  	return o.ApplyT(func(v *DeliveryChannel) pulumi.StringPtrOutput { return v.SnsTopicArn }).(pulumi.StringPtrOutput)
   360  }
   361  
   362  type DeliveryChannelArrayOutput struct{ *pulumi.OutputState }
   363  
   364  func (DeliveryChannelArrayOutput) ElementType() reflect.Type {
   365  	return reflect.TypeOf((*[]*DeliveryChannel)(nil)).Elem()
   366  }
   367  
   368  func (o DeliveryChannelArrayOutput) ToDeliveryChannelArrayOutput() DeliveryChannelArrayOutput {
   369  	return o
   370  }
   371  
   372  func (o DeliveryChannelArrayOutput) ToDeliveryChannelArrayOutputWithContext(ctx context.Context) DeliveryChannelArrayOutput {
   373  	return o
   374  }
   375  
   376  func (o DeliveryChannelArrayOutput) Index(i pulumi.IntInput) DeliveryChannelOutput {
   377  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *DeliveryChannel {
   378  		return vs[0].([]*DeliveryChannel)[vs[1].(int)]
   379  	}).(DeliveryChannelOutput)
   380  }
   381  
   382  type DeliveryChannelMapOutput struct{ *pulumi.OutputState }
   383  
   384  func (DeliveryChannelMapOutput) ElementType() reflect.Type {
   385  	return reflect.TypeOf((*map[string]*DeliveryChannel)(nil)).Elem()
   386  }
   387  
   388  func (o DeliveryChannelMapOutput) ToDeliveryChannelMapOutput() DeliveryChannelMapOutput {
   389  	return o
   390  }
   391  
   392  func (o DeliveryChannelMapOutput) ToDeliveryChannelMapOutputWithContext(ctx context.Context) DeliveryChannelMapOutput {
   393  	return o
   394  }
   395  
   396  func (o DeliveryChannelMapOutput) MapIndex(k pulumi.StringInput) DeliveryChannelOutput {
   397  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *DeliveryChannel {
   398  		return vs[0].(map[string]*DeliveryChannel)[vs[1].(string)]
   399  	}).(DeliveryChannelOutput)
   400  }
   401  
   402  func init() {
   403  	pulumi.RegisterInputType(reflect.TypeOf((*DeliveryChannelInput)(nil)).Elem(), &DeliveryChannel{})
   404  	pulumi.RegisterInputType(reflect.TypeOf((*DeliveryChannelArrayInput)(nil)).Elem(), DeliveryChannelArray{})
   405  	pulumi.RegisterInputType(reflect.TypeOf((*DeliveryChannelMapInput)(nil)).Elem(), DeliveryChannelMap{})
   406  	pulumi.RegisterOutputType(DeliveryChannelOutput{})
   407  	pulumi.RegisterOutputType(DeliveryChannelArrayOutput{})
   408  	pulumi.RegisterOutputType(DeliveryChannelMapOutput{})
   409  }