github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/ebs/defaultKmsKey.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 ebs
     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 resource to manage the default customer master key (CMK) that your AWS account uses to encrypt EBS volumes.
    16  //
    17  // Your AWS account has an AWS-managed default CMK that is used for encrypting an EBS volume when no CMK is specified in the API call that creates the volume.
    18  // By using the `ebs.DefaultKmsKey` resource, you can specify a customer-managed CMK to use in place of the AWS-managed default CMK.
    19  //
    20  // > **NOTE:** Creating an `ebs.DefaultKmsKey` resource does not enable default EBS encryption. Use the `ebs.EncryptionByDefault` to enable default EBS encryption.
    21  //
    22  // > **NOTE:** Destroying this resource will reset the default CMK to the account's AWS-managed default CMK for EBS.
    23  //
    24  // ## Example Usage
    25  //
    26  // <!--Start PulumiCodeChooser -->
    27  // ```go
    28  // package main
    29  //
    30  // import (
    31  //
    32  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ebs"
    33  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    34  //
    35  // )
    36  //
    37  //	func main() {
    38  //		pulumi.Run(func(ctx *pulumi.Context) error {
    39  //			_, err := ebs.NewDefaultKmsKey(ctx, "example", &ebs.DefaultKmsKeyArgs{
    40  //				KeyArn: pulumi.Any(exampleAwsKmsKey.Arn),
    41  //			})
    42  //			if err != nil {
    43  //				return err
    44  //			}
    45  //			return nil
    46  //		})
    47  //	}
    48  //
    49  // ```
    50  // <!--End PulumiCodeChooser -->
    51  //
    52  // ## Import
    53  //
    54  // Using `pulumi import`, import the EBS default KMS CMK using the KMS key ARN. For example:
    55  //
    56  // ```sh
    57  // $ pulumi import aws:ebs/defaultKmsKey:DefaultKmsKey example arn:aws:kms:us-east-1:123456789012:key/abcd-1234
    58  // ```
    59  type DefaultKmsKey struct {
    60  	pulumi.CustomResourceState
    61  
    62  	// The ARN of the AWS Key Management Service (AWS KMS) customer master key (CMK) to use to encrypt the EBS volume.
    63  	KeyArn pulumi.StringOutput `pulumi:"keyArn"`
    64  }
    65  
    66  // NewDefaultKmsKey registers a new resource with the given unique name, arguments, and options.
    67  func NewDefaultKmsKey(ctx *pulumi.Context,
    68  	name string, args *DefaultKmsKeyArgs, opts ...pulumi.ResourceOption) (*DefaultKmsKey, error) {
    69  	if args == nil {
    70  		return nil, errors.New("missing one or more required arguments")
    71  	}
    72  
    73  	if args.KeyArn == nil {
    74  		return nil, errors.New("invalid value for required argument 'KeyArn'")
    75  	}
    76  	opts = internal.PkgResourceDefaultOpts(opts)
    77  	var resource DefaultKmsKey
    78  	err := ctx.RegisterResource("aws:ebs/defaultKmsKey:DefaultKmsKey", name, args, &resource, opts...)
    79  	if err != nil {
    80  		return nil, err
    81  	}
    82  	return &resource, nil
    83  }
    84  
    85  // GetDefaultKmsKey gets an existing DefaultKmsKey resource's state with the given name, ID, and optional
    86  // state properties that are used to uniquely qualify the lookup (nil if not required).
    87  func GetDefaultKmsKey(ctx *pulumi.Context,
    88  	name string, id pulumi.IDInput, state *DefaultKmsKeyState, opts ...pulumi.ResourceOption) (*DefaultKmsKey, error) {
    89  	var resource DefaultKmsKey
    90  	err := ctx.ReadResource("aws:ebs/defaultKmsKey:DefaultKmsKey", name, id, state, &resource, opts...)
    91  	if err != nil {
    92  		return nil, err
    93  	}
    94  	return &resource, nil
    95  }
    96  
    97  // Input properties used for looking up and filtering DefaultKmsKey resources.
    98  type defaultKmsKeyState struct {
    99  	// The ARN of the AWS Key Management Service (AWS KMS) customer master key (CMK) to use to encrypt the EBS volume.
   100  	KeyArn *string `pulumi:"keyArn"`
   101  }
   102  
   103  type DefaultKmsKeyState struct {
   104  	// The ARN of the AWS Key Management Service (AWS KMS) customer master key (CMK) to use to encrypt the EBS volume.
   105  	KeyArn pulumi.StringPtrInput
   106  }
   107  
   108  func (DefaultKmsKeyState) ElementType() reflect.Type {
   109  	return reflect.TypeOf((*defaultKmsKeyState)(nil)).Elem()
   110  }
   111  
   112  type defaultKmsKeyArgs struct {
   113  	// The ARN of the AWS Key Management Service (AWS KMS) customer master key (CMK) to use to encrypt the EBS volume.
   114  	KeyArn string `pulumi:"keyArn"`
   115  }
   116  
   117  // The set of arguments for constructing a DefaultKmsKey resource.
   118  type DefaultKmsKeyArgs struct {
   119  	// The ARN of the AWS Key Management Service (AWS KMS) customer master key (CMK) to use to encrypt the EBS volume.
   120  	KeyArn pulumi.StringInput
   121  }
   122  
   123  func (DefaultKmsKeyArgs) ElementType() reflect.Type {
   124  	return reflect.TypeOf((*defaultKmsKeyArgs)(nil)).Elem()
   125  }
   126  
   127  type DefaultKmsKeyInput interface {
   128  	pulumi.Input
   129  
   130  	ToDefaultKmsKeyOutput() DefaultKmsKeyOutput
   131  	ToDefaultKmsKeyOutputWithContext(ctx context.Context) DefaultKmsKeyOutput
   132  }
   133  
   134  func (*DefaultKmsKey) ElementType() reflect.Type {
   135  	return reflect.TypeOf((**DefaultKmsKey)(nil)).Elem()
   136  }
   137  
   138  func (i *DefaultKmsKey) ToDefaultKmsKeyOutput() DefaultKmsKeyOutput {
   139  	return i.ToDefaultKmsKeyOutputWithContext(context.Background())
   140  }
   141  
   142  func (i *DefaultKmsKey) ToDefaultKmsKeyOutputWithContext(ctx context.Context) DefaultKmsKeyOutput {
   143  	return pulumi.ToOutputWithContext(ctx, i).(DefaultKmsKeyOutput)
   144  }
   145  
   146  // DefaultKmsKeyArrayInput is an input type that accepts DefaultKmsKeyArray and DefaultKmsKeyArrayOutput values.
   147  // You can construct a concrete instance of `DefaultKmsKeyArrayInput` via:
   148  //
   149  //	DefaultKmsKeyArray{ DefaultKmsKeyArgs{...} }
   150  type DefaultKmsKeyArrayInput interface {
   151  	pulumi.Input
   152  
   153  	ToDefaultKmsKeyArrayOutput() DefaultKmsKeyArrayOutput
   154  	ToDefaultKmsKeyArrayOutputWithContext(context.Context) DefaultKmsKeyArrayOutput
   155  }
   156  
   157  type DefaultKmsKeyArray []DefaultKmsKeyInput
   158  
   159  func (DefaultKmsKeyArray) ElementType() reflect.Type {
   160  	return reflect.TypeOf((*[]*DefaultKmsKey)(nil)).Elem()
   161  }
   162  
   163  func (i DefaultKmsKeyArray) ToDefaultKmsKeyArrayOutput() DefaultKmsKeyArrayOutput {
   164  	return i.ToDefaultKmsKeyArrayOutputWithContext(context.Background())
   165  }
   166  
   167  func (i DefaultKmsKeyArray) ToDefaultKmsKeyArrayOutputWithContext(ctx context.Context) DefaultKmsKeyArrayOutput {
   168  	return pulumi.ToOutputWithContext(ctx, i).(DefaultKmsKeyArrayOutput)
   169  }
   170  
   171  // DefaultKmsKeyMapInput is an input type that accepts DefaultKmsKeyMap and DefaultKmsKeyMapOutput values.
   172  // You can construct a concrete instance of `DefaultKmsKeyMapInput` via:
   173  //
   174  //	DefaultKmsKeyMap{ "key": DefaultKmsKeyArgs{...} }
   175  type DefaultKmsKeyMapInput interface {
   176  	pulumi.Input
   177  
   178  	ToDefaultKmsKeyMapOutput() DefaultKmsKeyMapOutput
   179  	ToDefaultKmsKeyMapOutputWithContext(context.Context) DefaultKmsKeyMapOutput
   180  }
   181  
   182  type DefaultKmsKeyMap map[string]DefaultKmsKeyInput
   183  
   184  func (DefaultKmsKeyMap) ElementType() reflect.Type {
   185  	return reflect.TypeOf((*map[string]*DefaultKmsKey)(nil)).Elem()
   186  }
   187  
   188  func (i DefaultKmsKeyMap) ToDefaultKmsKeyMapOutput() DefaultKmsKeyMapOutput {
   189  	return i.ToDefaultKmsKeyMapOutputWithContext(context.Background())
   190  }
   191  
   192  func (i DefaultKmsKeyMap) ToDefaultKmsKeyMapOutputWithContext(ctx context.Context) DefaultKmsKeyMapOutput {
   193  	return pulumi.ToOutputWithContext(ctx, i).(DefaultKmsKeyMapOutput)
   194  }
   195  
   196  type DefaultKmsKeyOutput struct{ *pulumi.OutputState }
   197  
   198  func (DefaultKmsKeyOutput) ElementType() reflect.Type {
   199  	return reflect.TypeOf((**DefaultKmsKey)(nil)).Elem()
   200  }
   201  
   202  func (o DefaultKmsKeyOutput) ToDefaultKmsKeyOutput() DefaultKmsKeyOutput {
   203  	return o
   204  }
   205  
   206  func (o DefaultKmsKeyOutput) ToDefaultKmsKeyOutputWithContext(ctx context.Context) DefaultKmsKeyOutput {
   207  	return o
   208  }
   209  
   210  // The ARN of the AWS Key Management Service (AWS KMS) customer master key (CMK) to use to encrypt the EBS volume.
   211  func (o DefaultKmsKeyOutput) KeyArn() pulumi.StringOutput {
   212  	return o.ApplyT(func(v *DefaultKmsKey) pulumi.StringOutput { return v.KeyArn }).(pulumi.StringOutput)
   213  }
   214  
   215  type DefaultKmsKeyArrayOutput struct{ *pulumi.OutputState }
   216  
   217  func (DefaultKmsKeyArrayOutput) ElementType() reflect.Type {
   218  	return reflect.TypeOf((*[]*DefaultKmsKey)(nil)).Elem()
   219  }
   220  
   221  func (o DefaultKmsKeyArrayOutput) ToDefaultKmsKeyArrayOutput() DefaultKmsKeyArrayOutput {
   222  	return o
   223  }
   224  
   225  func (o DefaultKmsKeyArrayOutput) ToDefaultKmsKeyArrayOutputWithContext(ctx context.Context) DefaultKmsKeyArrayOutput {
   226  	return o
   227  }
   228  
   229  func (o DefaultKmsKeyArrayOutput) Index(i pulumi.IntInput) DefaultKmsKeyOutput {
   230  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *DefaultKmsKey {
   231  		return vs[0].([]*DefaultKmsKey)[vs[1].(int)]
   232  	}).(DefaultKmsKeyOutput)
   233  }
   234  
   235  type DefaultKmsKeyMapOutput struct{ *pulumi.OutputState }
   236  
   237  func (DefaultKmsKeyMapOutput) ElementType() reflect.Type {
   238  	return reflect.TypeOf((*map[string]*DefaultKmsKey)(nil)).Elem()
   239  }
   240  
   241  func (o DefaultKmsKeyMapOutput) ToDefaultKmsKeyMapOutput() DefaultKmsKeyMapOutput {
   242  	return o
   243  }
   244  
   245  func (o DefaultKmsKeyMapOutput) ToDefaultKmsKeyMapOutputWithContext(ctx context.Context) DefaultKmsKeyMapOutput {
   246  	return o
   247  }
   248  
   249  func (o DefaultKmsKeyMapOutput) MapIndex(k pulumi.StringInput) DefaultKmsKeyOutput {
   250  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *DefaultKmsKey {
   251  		return vs[0].(map[string]*DefaultKmsKey)[vs[1].(string)]
   252  	}).(DefaultKmsKeyOutput)
   253  }
   254  
   255  func init() {
   256  	pulumi.RegisterInputType(reflect.TypeOf((*DefaultKmsKeyInput)(nil)).Elem(), &DefaultKmsKey{})
   257  	pulumi.RegisterInputType(reflect.TypeOf((*DefaultKmsKeyArrayInput)(nil)).Elem(), DefaultKmsKeyArray{})
   258  	pulumi.RegisterInputType(reflect.TypeOf((*DefaultKmsKeyMapInput)(nil)).Elem(), DefaultKmsKeyMap{})
   259  	pulumi.RegisterOutputType(DefaultKmsKeyOutput{})
   260  	pulumi.RegisterOutputType(DefaultKmsKeyArrayOutput{})
   261  	pulumi.RegisterOutputType(DefaultKmsKeyMapOutput{})
   262  }