github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/kms/ciphertext.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 kms
     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  // The KMS ciphertext resource allows you to encrypt plaintext into ciphertext
    16  // by using an AWS KMS customer master key. The value returned by this resource
    17  // is stable across every apply. For a changing ciphertext value each apply, see
    18  // the `kms.Ciphertext` data source.
    19  //
    20  // ## Example Usage
    21  //
    22  // <!--Start PulumiCodeChooser -->
    23  // ```go
    24  // package main
    25  //
    26  // import (
    27  //
    28  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/kms"
    29  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    30  //
    31  // )
    32  //
    33  //	func main() {
    34  //		pulumi.Run(func(ctx *pulumi.Context) error {
    35  //			oauthConfig, err := kms.NewKey(ctx, "oauth_config", &kms.KeyArgs{
    36  //				Description: pulumi.String("oauth config"),
    37  //				IsEnabled:   pulumi.Bool(true),
    38  //			})
    39  //			if err != nil {
    40  //				return err
    41  //			}
    42  //			_, err = kms.NewCiphertext(ctx, "oauth", &kms.CiphertextArgs{
    43  //				KeyId:     oauthConfig.KeyId,
    44  //				Plaintext: pulumi.String("{\n  \"client_id\": \"e587dbae22222f55da22\",\n  \"client_secret\": \"8289575d00000ace55e1815ec13673955721b8a5\"\n}\n"),
    45  //			})
    46  //			if err != nil {
    47  //				return err
    48  //			}
    49  //			return nil
    50  //		})
    51  //	}
    52  //
    53  // ```
    54  // <!--End PulumiCodeChooser -->
    55  type Ciphertext struct {
    56  	pulumi.CustomResourceState
    57  
    58  	// Base64 encoded ciphertext
    59  	CiphertextBlob pulumi.StringOutput `pulumi:"ciphertextBlob"`
    60  	// An optional mapping that makes up the encryption context.
    61  	Context pulumi.StringMapOutput `pulumi:"context"`
    62  	// Globally unique key ID for the customer master key.
    63  	KeyId pulumi.StringOutput `pulumi:"keyId"`
    64  	// Data to be encrypted. Note that this may show up in logs, and it will be stored in the state file.
    65  	Plaintext pulumi.StringOutput `pulumi:"plaintext"`
    66  }
    67  
    68  // NewCiphertext registers a new resource with the given unique name, arguments, and options.
    69  func NewCiphertext(ctx *pulumi.Context,
    70  	name string, args *CiphertextArgs, opts ...pulumi.ResourceOption) (*Ciphertext, error) {
    71  	if args == nil {
    72  		return nil, errors.New("missing one or more required arguments")
    73  	}
    74  
    75  	if args.KeyId == nil {
    76  		return nil, errors.New("invalid value for required argument 'KeyId'")
    77  	}
    78  	if args.Plaintext == nil {
    79  		return nil, errors.New("invalid value for required argument 'Plaintext'")
    80  	}
    81  	if args.Plaintext != nil {
    82  		args.Plaintext = pulumi.ToSecret(args.Plaintext).(pulumi.StringInput)
    83  	}
    84  	secrets := pulumi.AdditionalSecretOutputs([]string{
    85  		"plaintext",
    86  	})
    87  	opts = append(opts, secrets)
    88  	opts = internal.PkgResourceDefaultOpts(opts)
    89  	var resource Ciphertext
    90  	err := ctx.RegisterResource("aws:kms/ciphertext:Ciphertext", name, args, &resource, opts...)
    91  	if err != nil {
    92  		return nil, err
    93  	}
    94  	return &resource, nil
    95  }
    96  
    97  // GetCiphertext gets an existing Ciphertext resource's state with the given name, ID, and optional
    98  // state properties that are used to uniquely qualify the lookup (nil if not required).
    99  func GetCiphertext(ctx *pulumi.Context,
   100  	name string, id pulumi.IDInput, state *CiphertextState, opts ...pulumi.ResourceOption) (*Ciphertext, error) {
   101  	var resource Ciphertext
   102  	err := ctx.ReadResource("aws:kms/ciphertext:Ciphertext", name, id, state, &resource, opts...)
   103  	if err != nil {
   104  		return nil, err
   105  	}
   106  	return &resource, nil
   107  }
   108  
   109  // Input properties used for looking up and filtering Ciphertext resources.
   110  type ciphertextState struct {
   111  	// Base64 encoded ciphertext
   112  	CiphertextBlob *string `pulumi:"ciphertextBlob"`
   113  	// An optional mapping that makes up the encryption context.
   114  	Context map[string]string `pulumi:"context"`
   115  	// Globally unique key ID for the customer master key.
   116  	KeyId *string `pulumi:"keyId"`
   117  	// Data to be encrypted. Note that this may show up in logs, and it will be stored in the state file.
   118  	Plaintext *string `pulumi:"plaintext"`
   119  }
   120  
   121  type CiphertextState struct {
   122  	// Base64 encoded ciphertext
   123  	CiphertextBlob pulumi.StringPtrInput
   124  	// An optional mapping that makes up the encryption context.
   125  	Context pulumi.StringMapInput
   126  	// Globally unique key ID for the customer master key.
   127  	KeyId pulumi.StringPtrInput
   128  	// Data to be encrypted. Note that this may show up in logs, and it will be stored in the state file.
   129  	Plaintext pulumi.StringPtrInput
   130  }
   131  
   132  func (CiphertextState) ElementType() reflect.Type {
   133  	return reflect.TypeOf((*ciphertextState)(nil)).Elem()
   134  }
   135  
   136  type ciphertextArgs struct {
   137  	// An optional mapping that makes up the encryption context.
   138  	Context map[string]string `pulumi:"context"`
   139  	// Globally unique key ID for the customer master key.
   140  	KeyId string `pulumi:"keyId"`
   141  	// Data to be encrypted. Note that this may show up in logs, and it will be stored in the state file.
   142  	Plaintext string `pulumi:"plaintext"`
   143  }
   144  
   145  // The set of arguments for constructing a Ciphertext resource.
   146  type CiphertextArgs struct {
   147  	// An optional mapping that makes up the encryption context.
   148  	Context pulumi.StringMapInput
   149  	// Globally unique key ID for the customer master key.
   150  	KeyId pulumi.StringInput
   151  	// Data to be encrypted. Note that this may show up in logs, and it will be stored in the state file.
   152  	Plaintext pulumi.StringInput
   153  }
   154  
   155  func (CiphertextArgs) ElementType() reflect.Type {
   156  	return reflect.TypeOf((*ciphertextArgs)(nil)).Elem()
   157  }
   158  
   159  type CiphertextInput interface {
   160  	pulumi.Input
   161  
   162  	ToCiphertextOutput() CiphertextOutput
   163  	ToCiphertextOutputWithContext(ctx context.Context) CiphertextOutput
   164  }
   165  
   166  func (*Ciphertext) ElementType() reflect.Type {
   167  	return reflect.TypeOf((**Ciphertext)(nil)).Elem()
   168  }
   169  
   170  func (i *Ciphertext) ToCiphertextOutput() CiphertextOutput {
   171  	return i.ToCiphertextOutputWithContext(context.Background())
   172  }
   173  
   174  func (i *Ciphertext) ToCiphertextOutputWithContext(ctx context.Context) CiphertextOutput {
   175  	return pulumi.ToOutputWithContext(ctx, i).(CiphertextOutput)
   176  }
   177  
   178  // CiphertextArrayInput is an input type that accepts CiphertextArray and CiphertextArrayOutput values.
   179  // You can construct a concrete instance of `CiphertextArrayInput` via:
   180  //
   181  //	CiphertextArray{ CiphertextArgs{...} }
   182  type CiphertextArrayInput interface {
   183  	pulumi.Input
   184  
   185  	ToCiphertextArrayOutput() CiphertextArrayOutput
   186  	ToCiphertextArrayOutputWithContext(context.Context) CiphertextArrayOutput
   187  }
   188  
   189  type CiphertextArray []CiphertextInput
   190  
   191  func (CiphertextArray) ElementType() reflect.Type {
   192  	return reflect.TypeOf((*[]*Ciphertext)(nil)).Elem()
   193  }
   194  
   195  func (i CiphertextArray) ToCiphertextArrayOutput() CiphertextArrayOutput {
   196  	return i.ToCiphertextArrayOutputWithContext(context.Background())
   197  }
   198  
   199  func (i CiphertextArray) ToCiphertextArrayOutputWithContext(ctx context.Context) CiphertextArrayOutput {
   200  	return pulumi.ToOutputWithContext(ctx, i).(CiphertextArrayOutput)
   201  }
   202  
   203  // CiphertextMapInput is an input type that accepts CiphertextMap and CiphertextMapOutput values.
   204  // You can construct a concrete instance of `CiphertextMapInput` via:
   205  //
   206  //	CiphertextMap{ "key": CiphertextArgs{...} }
   207  type CiphertextMapInput interface {
   208  	pulumi.Input
   209  
   210  	ToCiphertextMapOutput() CiphertextMapOutput
   211  	ToCiphertextMapOutputWithContext(context.Context) CiphertextMapOutput
   212  }
   213  
   214  type CiphertextMap map[string]CiphertextInput
   215  
   216  func (CiphertextMap) ElementType() reflect.Type {
   217  	return reflect.TypeOf((*map[string]*Ciphertext)(nil)).Elem()
   218  }
   219  
   220  func (i CiphertextMap) ToCiphertextMapOutput() CiphertextMapOutput {
   221  	return i.ToCiphertextMapOutputWithContext(context.Background())
   222  }
   223  
   224  func (i CiphertextMap) ToCiphertextMapOutputWithContext(ctx context.Context) CiphertextMapOutput {
   225  	return pulumi.ToOutputWithContext(ctx, i).(CiphertextMapOutput)
   226  }
   227  
   228  type CiphertextOutput struct{ *pulumi.OutputState }
   229  
   230  func (CiphertextOutput) ElementType() reflect.Type {
   231  	return reflect.TypeOf((**Ciphertext)(nil)).Elem()
   232  }
   233  
   234  func (o CiphertextOutput) ToCiphertextOutput() CiphertextOutput {
   235  	return o
   236  }
   237  
   238  func (o CiphertextOutput) ToCiphertextOutputWithContext(ctx context.Context) CiphertextOutput {
   239  	return o
   240  }
   241  
   242  // Base64 encoded ciphertext
   243  func (o CiphertextOutput) CiphertextBlob() pulumi.StringOutput {
   244  	return o.ApplyT(func(v *Ciphertext) pulumi.StringOutput { return v.CiphertextBlob }).(pulumi.StringOutput)
   245  }
   246  
   247  // An optional mapping that makes up the encryption context.
   248  func (o CiphertextOutput) Context() pulumi.StringMapOutput {
   249  	return o.ApplyT(func(v *Ciphertext) pulumi.StringMapOutput { return v.Context }).(pulumi.StringMapOutput)
   250  }
   251  
   252  // Globally unique key ID for the customer master key.
   253  func (o CiphertextOutput) KeyId() pulumi.StringOutput {
   254  	return o.ApplyT(func(v *Ciphertext) pulumi.StringOutput { return v.KeyId }).(pulumi.StringOutput)
   255  }
   256  
   257  // Data to be encrypted. Note that this may show up in logs, and it will be stored in the state file.
   258  func (o CiphertextOutput) Plaintext() pulumi.StringOutput {
   259  	return o.ApplyT(func(v *Ciphertext) pulumi.StringOutput { return v.Plaintext }).(pulumi.StringOutput)
   260  }
   261  
   262  type CiphertextArrayOutput struct{ *pulumi.OutputState }
   263  
   264  func (CiphertextArrayOutput) ElementType() reflect.Type {
   265  	return reflect.TypeOf((*[]*Ciphertext)(nil)).Elem()
   266  }
   267  
   268  func (o CiphertextArrayOutput) ToCiphertextArrayOutput() CiphertextArrayOutput {
   269  	return o
   270  }
   271  
   272  func (o CiphertextArrayOutput) ToCiphertextArrayOutputWithContext(ctx context.Context) CiphertextArrayOutput {
   273  	return o
   274  }
   275  
   276  func (o CiphertextArrayOutput) Index(i pulumi.IntInput) CiphertextOutput {
   277  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Ciphertext {
   278  		return vs[0].([]*Ciphertext)[vs[1].(int)]
   279  	}).(CiphertextOutput)
   280  }
   281  
   282  type CiphertextMapOutput struct{ *pulumi.OutputState }
   283  
   284  func (CiphertextMapOutput) ElementType() reflect.Type {
   285  	return reflect.TypeOf((*map[string]*Ciphertext)(nil)).Elem()
   286  }
   287  
   288  func (o CiphertextMapOutput) ToCiphertextMapOutput() CiphertextMapOutput {
   289  	return o
   290  }
   291  
   292  func (o CiphertextMapOutput) ToCiphertextMapOutputWithContext(ctx context.Context) CiphertextMapOutput {
   293  	return o
   294  }
   295  
   296  func (o CiphertextMapOutput) MapIndex(k pulumi.StringInput) CiphertextOutput {
   297  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Ciphertext {
   298  		return vs[0].(map[string]*Ciphertext)[vs[1].(string)]
   299  	}).(CiphertextOutput)
   300  }
   301  
   302  func init() {
   303  	pulumi.RegisterInputType(reflect.TypeOf((*CiphertextInput)(nil)).Elem(), &Ciphertext{})
   304  	pulumi.RegisterInputType(reflect.TypeOf((*CiphertextArrayInput)(nil)).Elem(), CiphertextArray{})
   305  	pulumi.RegisterInputType(reflect.TypeOf((*CiphertextMapInput)(nil)).Elem(), CiphertextMap{})
   306  	pulumi.RegisterOutputType(CiphertextOutput{})
   307  	pulumi.RegisterOutputType(CiphertextArrayOutput{})
   308  	pulumi.RegisterOutputType(CiphertextMapOutput{})
   309  }