github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/xray/encryptionConfig.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 xray
     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  // Creates and manages an AWS XRay Encryption Config.
    16  //
    17  // > **NOTE:** Removing this resource from the provider has no effect to the encryption configuration within X-Ray.
    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/xray"
    28  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    29  //
    30  // )
    31  //
    32  //	func main() {
    33  //		pulumi.Run(func(ctx *pulumi.Context) error {
    34  //			_, err := xray.NewEncryptionConfig(ctx, "example", &xray.EncryptionConfigArgs{
    35  //				Type: pulumi.String("NONE"),
    36  //			})
    37  //			if err != nil {
    38  //				return err
    39  //			}
    40  //			return nil
    41  //		})
    42  //	}
    43  //
    44  // ```
    45  // <!--End PulumiCodeChooser -->
    46  //
    47  // ### With KMS Key
    48  //
    49  // <!--Start PulumiCodeChooser -->
    50  // ```go
    51  // package main
    52  //
    53  // import (
    54  //
    55  //	"fmt"
    56  //
    57  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws"
    58  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iam"
    59  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/kms"
    60  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/xray"
    61  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    62  //
    63  // )
    64  //
    65  //	func main() {
    66  //		pulumi.Run(func(ctx *pulumi.Context) error {
    67  //			current, err := aws.GetCallerIdentity(ctx, nil, nil)
    68  //			if err != nil {
    69  //				return err
    70  //			}
    71  //			example, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
    72  //				Statements: []iam.GetPolicyDocumentStatement{
    73  //					{
    74  //						Sid:    pulumi.StringRef("Enable IAM User Permissions"),
    75  //						Effect: pulumi.StringRef("Allow"),
    76  //						Principals: []iam.GetPolicyDocumentStatementPrincipal{
    77  //							{
    78  //								Type: "AWS",
    79  //								Identifiers: []string{
    80  //									fmt.Sprintf("arn:aws:iam::%v:root", current.AccountId),
    81  //								},
    82  //							},
    83  //						},
    84  //						Actions: []string{
    85  //							"kms:*",
    86  //						},
    87  //						Resources: []string{
    88  //							"*",
    89  //						},
    90  //					},
    91  //				},
    92  //			}, nil)
    93  //			if err != nil {
    94  //				return err
    95  //			}
    96  //			exampleKey, err := kms.NewKey(ctx, "example", &kms.KeyArgs{
    97  //				Description:          pulumi.String("Some Key"),
    98  //				DeletionWindowInDays: pulumi.Int(7),
    99  //				Policy:               pulumi.String(example.Json),
   100  //			})
   101  //			if err != nil {
   102  //				return err
   103  //			}
   104  //			_, err = xray.NewEncryptionConfig(ctx, "example", &xray.EncryptionConfigArgs{
   105  //				Type:  pulumi.String("KMS"),
   106  //				KeyId: exampleKey.Arn,
   107  //			})
   108  //			if err != nil {
   109  //				return err
   110  //			}
   111  //			return nil
   112  //		})
   113  //	}
   114  //
   115  // ```
   116  // <!--End PulumiCodeChooser -->
   117  //
   118  // ## Import
   119  //
   120  // Using `pulumi import`, import XRay Encryption Config using the region name. For example:
   121  //
   122  // ```sh
   123  // $ pulumi import aws:xray/encryptionConfig:EncryptionConfig example us-west-2
   124  // ```
   125  type EncryptionConfig struct {
   126  	pulumi.CustomResourceState
   127  
   128  	// An AWS KMS customer master key (CMK) ARN.
   129  	KeyId pulumi.StringPtrOutput `pulumi:"keyId"`
   130  	// The type of encryption. Set to `KMS` to use your own key for encryption. Set to `NONE` for default encryption.
   131  	Type pulumi.StringOutput `pulumi:"type"`
   132  }
   133  
   134  // NewEncryptionConfig registers a new resource with the given unique name, arguments, and options.
   135  func NewEncryptionConfig(ctx *pulumi.Context,
   136  	name string, args *EncryptionConfigArgs, opts ...pulumi.ResourceOption) (*EncryptionConfig, error) {
   137  	if args == nil {
   138  		return nil, errors.New("missing one or more required arguments")
   139  	}
   140  
   141  	if args.Type == nil {
   142  		return nil, errors.New("invalid value for required argument 'Type'")
   143  	}
   144  	opts = internal.PkgResourceDefaultOpts(opts)
   145  	var resource EncryptionConfig
   146  	err := ctx.RegisterResource("aws:xray/encryptionConfig:EncryptionConfig", name, args, &resource, opts...)
   147  	if err != nil {
   148  		return nil, err
   149  	}
   150  	return &resource, nil
   151  }
   152  
   153  // GetEncryptionConfig gets an existing EncryptionConfig resource's state with the given name, ID, and optional
   154  // state properties that are used to uniquely qualify the lookup (nil if not required).
   155  func GetEncryptionConfig(ctx *pulumi.Context,
   156  	name string, id pulumi.IDInput, state *EncryptionConfigState, opts ...pulumi.ResourceOption) (*EncryptionConfig, error) {
   157  	var resource EncryptionConfig
   158  	err := ctx.ReadResource("aws:xray/encryptionConfig:EncryptionConfig", name, id, state, &resource, opts...)
   159  	if err != nil {
   160  		return nil, err
   161  	}
   162  	return &resource, nil
   163  }
   164  
   165  // Input properties used for looking up and filtering EncryptionConfig resources.
   166  type encryptionConfigState struct {
   167  	// An AWS KMS customer master key (CMK) ARN.
   168  	KeyId *string `pulumi:"keyId"`
   169  	// The type of encryption. Set to `KMS` to use your own key for encryption. Set to `NONE` for default encryption.
   170  	Type *string `pulumi:"type"`
   171  }
   172  
   173  type EncryptionConfigState struct {
   174  	// An AWS KMS customer master key (CMK) ARN.
   175  	KeyId pulumi.StringPtrInput
   176  	// The type of encryption. Set to `KMS` to use your own key for encryption. Set to `NONE` for default encryption.
   177  	Type pulumi.StringPtrInput
   178  }
   179  
   180  func (EncryptionConfigState) ElementType() reflect.Type {
   181  	return reflect.TypeOf((*encryptionConfigState)(nil)).Elem()
   182  }
   183  
   184  type encryptionConfigArgs struct {
   185  	// An AWS KMS customer master key (CMK) ARN.
   186  	KeyId *string `pulumi:"keyId"`
   187  	// The type of encryption. Set to `KMS` to use your own key for encryption. Set to `NONE` for default encryption.
   188  	Type string `pulumi:"type"`
   189  }
   190  
   191  // The set of arguments for constructing a EncryptionConfig resource.
   192  type EncryptionConfigArgs struct {
   193  	// An AWS KMS customer master key (CMK) ARN.
   194  	KeyId pulumi.StringPtrInput
   195  	// The type of encryption. Set to `KMS` to use your own key for encryption. Set to `NONE` for default encryption.
   196  	Type pulumi.StringInput
   197  }
   198  
   199  func (EncryptionConfigArgs) ElementType() reflect.Type {
   200  	return reflect.TypeOf((*encryptionConfigArgs)(nil)).Elem()
   201  }
   202  
   203  type EncryptionConfigInput interface {
   204  	pulumi.Input
   205  
   206  	ToEncryptionConfigOutput() EncryptionConfigOutput
   207  	ToEncryptionConfigOutputWithContext(ctx context.Context) EncryptionConfigOutput
   208  }
   209  
   210  func (*EncryptionConfig) ElementType() reflect.Type {
   211  	return reflect.TypeOf((**EncryptionConfig)(nil)).Elem()
   212  }
   213  
   214  func (i *EncryptionConfig) ToEncryptionConfigOutput() EncryptionConfigOutput {
   215  	return i.ToEncryptionConfigOutputWithContext(context.Background())
   216  }
   217  
   218  func (i *EncryptionConfig) ToEncryptionConfigOutputWithContext(ctx context.Context) EncryptionConfigOutput {
   219  	return pulumi.ToOutputWithContext(ctx, i).(EncryptionConfigOutput)
   220  }
   221  
   222  // EncryptionConfigArrayInput is an input type that accepts EncryptionConfigArray and EncryptionConfigArrayOutput values.
   223  // You can construct a concrete instance of `EncryptionConfigArrayInput` via:
   224  //
   225  //	EncryptionConfigArray{ EncryptionConfigArgs{...} }
   226  type EncryptionConfigArrayInput interface {
   227  	pulumi.Input
   228  
   229  	ToEncryptionConfigArrayOutput() EncryptionConfigArrayOutput
   230  	ToEncryptionConfigArrayOutputWithContext(context.Context) EncryptionConfigArrayOutput
   231  }
   232  
   233  type EncryptionConfigArray []EncryptionConfigInput
   234  
   235  func (EncryptionConfigArray) ElementType() reflect.Type {
   236  	return reflect.TypeOf((*[]*EncryptionConfig)(nil)).Elem()
   237  }
   238  
   239  func (i EncryptionConfigArray) ToEncryptionConfigArrayOutput() EncryptionConfigArrayOutput {
   240  	return i.ToEncryptionConfigArrayOutputWithContext(context.Background())
   241  }
   242  
   243  func (i EncryptionConfigArray) ToEncryptionConfigArrayOutputWithContext(ctx context.Context) EncryptionConfigArrayOutput {
   244  	return pulumi.ToOutputWithContext(ctx, i).(EncryptionConfigArrayOutput)
   245  }
   246  
   247  // EncryptionConfigMapInput is an input type that accepts EncryptionConfigMap and EncryptionConfigMapOutput values.
   248  // You can construct a concrete instance of `EncryptionConfigMapInput` via:
   249  //
   250  //	EncryptionConfigMap{ "key": EncryptionConfigArgs{...} }
   251  type EncryptionConfigMapInput interface {
   252  	pulumi.Input
   253  
   254  	ToEncryptionConfigMapOutput() EncryptionConfigMapOutput
   255  	ToEncryptionConfigMapOutputWithContext(context.Context) EncryptionConfigMapOutput
   256  }
   257  
   258  type EncryptionConfigMap map[string]EncryptionConfigInput
   259  
   260  func (EncryptionConfigMap) ElementType() reflect.Type {
   261  	return reflect.TypeOf((*map[string]*EncryptionConfig)(nil)).Elem()
   262  }
   263  
   264  func (i EncryptionConfigMap) ToEncryptionConfigMapOutput() EncryptionConfigMapOutput {
   265  	return i.ToEncryptionConfigMapOutputWithContext(context.Background())
   266  }
   267  
   268  func (i EncryptionConfigMap) ToEncryptionConfigMapOutputWithContext(ctx context.Context) EncryptionConfigMapOutput {
   269  	return pulumi.ToOutputWithContext(ctx, i).(EncryptionConfigMapOutput)
   270  }
   271  
   272  type EncryptionConfigOutput struct{ *pulumi.OutputState }
   273  
   274  func (EncryptionConfigOutput) ElementType() reflect.Type {
   275  	return reflect.TypeOf((**EncryptionConfig)(nil)).Elem()
   276  }
   277  
   278  func (o EncryptionConfigOutput) ToEncryptionConfigOutput() EncryptionConfigOutput {
   279  	return o
   280  }
   281  
   282  func (o EncryptionConfigOutput) ToEncryptionConfigOutputWithContext(ctx context.Context) EncryptionConfigOutput {
   283  	return o
   284  }
   285  
   286  // An AWS KMS customer master key (CMK) ARN.
   287  func (o EncryptionConfigOutput) KeyId() pulumi.StringPtrOutput {
   288  	return o.ApplyT(func(v *EncryptionConfig) pulumi.StringPtrOutput { return v.KeyId }).(pulumi.StringPtrOutput)
   289  }
   290  
   291  // The type of encryption. Set to `KMS` to use your own key for encryption. Set to `NONE` for default encryption.
   292  func (o EncryptionConfigOutput) Type() pulumi.StringOutput {
   293  	return o.ApplyT(func(v *EncryptionConfig) pulumi.StringOutput { return v.Type }).(pulumi.StringOutput)
   294  }
   295  
   296  type EncryptionConfigArrayOutput struct{ *pulumi.OutputState }
   297  
   298  func (EncryptionConfigArrayOutput) ElementType() reflect.Type {
   299  	return reflect.TypeOf((*[]*EncryptionConfig)(nil)).Elem()
   300  }
   301  
   302  func (o EncryptionConfigArrayOutput) ToEncryptionConfigArrayOutput() EncryptionConfigArrayOutput {
   303  	return o
   304  }
   305  
   306  func (o EncryptionConfigArrayOutput) ToEncryptionConfigArrayOutputWithContext(ctx context.Context) EncryptionConfigArrayOutput {
   307  	return o
   308  }
   309  
   310  func (o EncryptionConfigArrayOutput) Index(i pulumi.IntInput) EncryptionConfigOutput {
   311  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *EncryptionConfig {
   312  		return vs[0].([]*EncryptionConfig)[vs[1].(int)]
   313  	}).(EncryptionConfigOutput)
   314  }
   315  
   316  type EncryptionConfigMapOutput struct{ *pulumi.OutputState }
   317  
   318  func (EncryptionConfigMapOutput) ElementType() reflect.Type {
   319  	return reflect.TypeOf((*map[string]*EncryptionConfig)(nil)).Elem()
   320  }
   321  
   322  func (o EncryptionConfigMapOutput) ToEncryptionConfigMapOutput() EncryptionConfigMapOutput {
   323  	return o
   324  }
   325  
   326  func (o EncryptionConfigMapOutput) ToEncryptionConfigMapOutputWithContext(ctx context.Context) EncryptionConfigMapOutput {
   327  	return o
   328  }
   329  
   330  func (o EncryptionConfigMapOutput) MapIndex(k pulumi.StringInput) EncryptionConfigOutput {
   331  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *EncryptionConfig {
   332  		return vs[0].(map[string]*EncryptionConfig)[vs[1].(string)]
   333  	}).(EncryptionConfigOutput)
   334  }
   335  
   336  func init() {
   337  	pulumi.RegisterInputType(reflect.TypeOf((*EncryptionConfigInput)(nil)).Elem(), &EncryptionConfig{})
   338  	pulumi.RegisterInputType(reflect.TypeOf((*EncryptionConfigArrayInput)(nil)).Elem(), EncryptionConfigArray{})
   339  	pulumi.RegisterInputType(reflect.TypeOf((*EncryptionConfigMapInput)(nil)).Elem(), EncryptionConfigMap{})
   340  	pulumi.RegisterOutputType(EncryptionConfigOutput{})
   341  	pulumi.RegisterOutputType(EncryptionConfigArrayOutput{})
   342  	pulumi.RegisterOutputType(EncryptionConfigMapOutput{})
   343  }