github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/cloudfront/publicKey.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  // ## Example Usage
    16  //
    17  // The following example below creates a CloudFront public key.
    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-std/sdk/go/std"
    27  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    28  //
    29  // )
    30  //
    31  //	func main() {
    32  //		pulumi.Run(func(ctx *pulumi.Context) error {
    33  //			invokeFile, err := std.File(ctx, &std.FileArgs{
    34  //				Input: "public_key.pem",
    35  //			}, nil)
    36  //			if err != nil {
    37  //				return err
    38  //			}
    39  //			_, err = cloudfront.NewPublicKey(ctx, "example", &cloudfront.PublicKeyArgs{
    40  //				Comment:    pulumi.String("test public key"),
    41  //				EncodedKey: invokeFile.Result,
    42  //				Name:       pulumi.String("test_key"),
    43  //			})
    44  //			if err != nil {
    45  //				return err
    46  //			}
    47  //			return nil
    48  //		})
    49  //	}
    50  //
    51  // ```
    52  // <!--End PulumiCodeChooser -->
    53  //
    54  // ## Import
    55  //
    56  // Using `pulumi import`, import CloudFront Public Key using the `id`. For example:
    57  //
    58  // ```sh
    59  // $ pulumi import aws:cloudfront/publicKey:PublicKey example K3D5EWEUDCCXON
    60  // ```
    61  type PublicKey struct {
    62  	pulumi.CustomResourceState
    63  
    64  	// Internal value used by CloudFront to allow future updates to the public key configuration.
    65  	CallerReference pulumi.StringOutput `pulumi:"callerReference"`
    66  	// An optional comment about the public key.
    67  	Comment pulumi.StringPtrOutput `pulumi:"comment"`
    68  	// The encoded public key that you want to add to CloudFront to use with features like field-level encryption.
    69  	EncodedKey pulumi.StringOutput `pulumi:"encodedKey"`
    70  	// The current version of the public key. For example: `E2QWRUHAPOMQZL`.
    71  	Etag pulumi.StringOutput `pulumi:"etag"`
    72  	// The name for the public key. By default generated by this provider.
    73  	Name pulumi.StringOutput `pulumi:"name"`
    74  	// The name for the public key. Conflicts with `name`.
    75  	//
    76  	// **NOTE:** When setting `encodedKey` value, there needs a newline at the end of string. Otherwise, multiple runs of pulumi will want to recreate the `cloudfront.PublicKey` resource.
    77  	NamePrefix pulumi.StringOutput `pulumi:"namePrefix"`
    78  }
    79  
    80  // NewPublicKey registers a new resource with the given unique name, arguments, and options.
    81  func NewPublicKey(ctx *pulumi.Context,
    82  	name string, args *PublicKeyArgs, opts ...pulumi.ResourceOption) (*PublicKey, error) {
    83  	if args == nil {
    84  		return nil, errors.New("missing one or more required arguments")
    85  	}
    86  
    87  	if args.EncodedKey == nil {
    88  		return nil, errors.New("invalid value for required argument 'EncodedKey'")
    89  	}
    90  	opts = internal.PkgResourceDefaultOpts(opts)
    91  	var resource PublicKey
    92  	err := ctx.RegisterResource("aws:cloudfront/publicKey:PublicKey", name, args, &resource, opts...)
    93  	if err != nil {
    94  		return nil, err
    95  	}
    96  	return &resource, nil
    97  }
    98  
    99  // GetPublicKey gets an existing PublicKey resource's state with the given name, ID, and optional
   100  // state properties that are used to uniquely qualify the lookup (nil if not required).
   101  func GetPublicKey(ctx *pulumi.Context,
   102  	name string, id pulumi.IDInput, state *PublicKeyState, opts ...pulumi.ResourceOption) (*PublicKey, error) {
   103  	var resource PublicKey
   104  	err := ctx.ReadResource("aws:cloudfront/publicKey:PublicKey", name, id, state, &resource, opts...)
   105  	if err != nil {
   106  		return nil, err
   107  	}
   108  	return &resource, nil
   109  }
   110  
   111  // Input properties used for looking up and filtering PublicKey resources.
   112  type publicKeyState struct {
   113  	// Internal value used by CloudFront to allow future updates to the public key configuration.
   114  	CallerReference *string `pulumi:"callerReference"`
   115  	// An optional comment about the public key.
   116  	Comment *string `pulumi:"comment"`
   117  	// The encoded public key that you want to add to CloudFront to use with features like field-level encryption.
   118  	EncodedKey *string `pulumi:"encodedKey"`
   119  	// The current version of the public key. For example: `E2QWRUHAPOMQZL`.
   120  	Etag *string `pulumi:"etag"`
   121  	// The name for the public key. By default generated by this provider.
   122  	Name *string `pulumi:"name"`
   123  	// The name for the public key. Conflicts with `name`.
   124  	//
   125  	// **NOTE:** When setting `encodedKey` value, there needs a newline at the end of string. Otherwise, multiple runs of pulumi will want to recreate the `cloudfront.PublicKey` resource.
   126  	NamePrefix *string `pulumi:"namePrefix"`
   127  }
   128  
   129  type PublicKeyState struct {
   130  	// Internal value used by CloudFront to allow future updates to the public key configuration.
   131  	CallerReference pulumi.StringPtrInput
   132  	// An optional comment about the public key.
   133  	Comment pulumi.StringPtrInput
   134  	// The encoded public key that you want to add to CloudFront to use with features like field-level encryption.
   135  	EncodedKey pulumi.StringPtrInput
   136  	// The current version of the public key. For example: `E2QWRUHAPOMQZL`.
   137  	Etag pulumi.StringPtrInput
   138  	// The name for the public key. By default generated by this provider.
   139  	Name pulumi.StringPtrInput
   140  	// The name for the public key. Conflicts with `name`.
   141  	//
   142  	// **NOTE:** When setting `encodedKey` value, there needs a newline at the end of string. Otherwise, multiple runs of pulumi will want to recreate the `cloudfront.PublicKey` resource.
   143  	NamePrefix pulumi.StringPtrInput
   144  }
   145  
   146  func (PublicKeyState) ElementType() reflect.Type {
   147  	return reflect.TypeOf((*publicKeyState)(nil)).Elem()
   148  }
   149  
   150  type publicKeyArgs struct {
   151  	// An optional comment about the public key.
   152  	Comment *string `pulumi:"comment"`
   153  	// The encoded public key that you want to add to CloudFront to use with features like field-level encryption.
   154  	EncodedKey string `pulumi:"encodedKey"`
   155  	// The name for the public key. By default generated by this provider.
   156  	Name *string `pulumi:"name"`
   157  	// The name for the public key. Conflicts with `name`.
   158  	//
   159  	// **NOTE:** When setting `encodedKey` value, there needs a newline at the end of string. Otherwise, multiple runs of pulumi will want to recreate the `cloudfront.PublicKey` resource.
   160  	NamePrefix *string `pulumi:"namePrefix"`
   161  }
   162  
   163  // The set of arguments for constructing a PublicKey resource.
   164  type PublicKeyArgs struct {
   165  	// An optional comment about the public key.
   166  	Comment pulumi.StringPtrInput
   167  	// The encoded public key that you want to add to CloudFront to use with features like field-level encryption.
   168  	EncodedKey pulumi.StringInput
   169  	// The name for the public key. By default generated by this provider.
   170  	Name pulumi.StringPtrInput
   171  	// The name for the public key. Conflicts with `name`.
   172  	//
   173  	// **NOTE:** When setting `encodedKey` value, there needs a newline at the end of string. Otherwise, multiple runs of pulumi will want to recreate the `cloudfront.PublicKey` resource.
   174  	NamePrefix pulumi.StringPtrInput
   175  }
   176  
   177  func (PublicKeyArgs) ElementType() reflect.Type {
   178  	return reflect.TypeOf((*publicKeyArgs)(nil)).Elem()
   179  }
   180  
   181  type PublicKeyInput interface {
   182  	pulumi.Input
   183  
   184  	ToPublicKeyOutput() PublicKeyOutput
   185  	ToPublicKeyOutputWithContext(ctx context.Context) PublicKeyOutput
   186  }
   187  
   188  func (*PublicKey) ElementType() reflect.Type {
   189  	return reflect.TypeOf((**PublicKey)(nil)).Elem()
   190  }
   191  
   192  func (i *PublicKey) ToPublicKeyOutput() PublicKeyOutput {
   193  	return i.ToPublicKeyOutputWithContext(context.Background())
   194  }
   195  
   196  func (i *PublicKey) ToPublicKeyOutputWithContext(ctx context.Context) PublicKeyOutput {
   197  	return pulumi.ToOutputWithContext(ctx, i).(PublicKeyOutput)
   198  }
   199  
   200  // PublicKeyArrayInput is an input type that accepts PublicKeyArray and PublicKeyArrayOutput values.
   201  // You can construct a concrete instance of `PublicKeyArrayInput` via:
   202  //
   203  //	PublicKeyArray{ PublicKeyArgs{...} }
   204  type PublicKeyArrayInput interface {
   205  	pulumi.Input
   206  
   207  	ToPublicKeyArrayOutput() PublicKeyArrayOutput
   208  	ToPublicKeyArrayOutputWithContext(context.Context) PublicKeyArrayOutput
   209  }
   210  
   211  type PublicKeyArray []PublicKeyInput
   212  
   213  func (PublicKeyArray) ElementType() reflect.Type {
   214  	return reflect.TypeOf((*[]*PublicKey)(nil)).Elem()
   215  }
   216  
   217  func (i PublicKeyArray) ToPublicKeyArrayOutput() PublicKeyArrayOutput {
   218  	return i.ToPublicKeyArrayOutputWithContext(context.Background())
   219  }
   220  
   221  func (i PublicKeyArray) ToPublicKeyArrayOutputWithContext(ctx context.Context) PublicKeyArrayOutput {
   222  	return pulumi.ToOutputWithContext(ctx, i).(PublicKeyArrayOutput)
   223  }
   224  
   225  // PublicKeyMapInput is an input type that accepts PublicKeyMap and PublicKeyMapOutput values.
   226  // You can construct a concrete instance of `PublicKeyMapInput` via:
   227  //
   228  //	PublicKeyMap{ "key": PublicKeyArgs{...} }
   229  type PublicKeyMapInput interface {
   230  	pulumi.Input
   231  
   232  	ToPublicKeyMapOutput() PublicKeyMapOutput
   233  	ToPublicKeyMapOutputWithContext(context.Context) PublicKeyMapOutput
   234  }
   235  
   236  type PublicKeyMap map[string]PublicKeyInput
   237  
   238  func (PublicKeyMap) ElementType() reflect.Type {
   239  	return reflect.TypeOf((*map[string]*PublicKey)(nil)).Elem()
   240  }
   241  
   242  func (i PublicKeyMap) ToPublicKeyMapOutput() PublicKeyMapOutput {
   243  	return i.ToPublicKeyMapOutputWithContext(context.Background())
   244  }
   245  
   246  func (i PublicKeyMap) ToPublicKeyMapOutputWithContext(ctx context.Context) PublicKeyMapOutput {
   247  	return pulumi.ToOutputWithContext(ctx, i).(PublicKeyMapOutput)
   248  }
   249  
   250  type PublicKeyOutput struct{ *pulumi.OutputState }
   251  
   252  func (PublicKeyOutput) ElementType() reflect.Type {
   253  	return reflect.TypeOf((**PublicKey)(nil)).Elem()
   254  }
   255  
   256  func (o PublicKeyOutput) ToPublicKeyOutput() PublicKeyOutput {
   257  	return o
   258  }
   259  
   260  func (o PublicKeyOutput) ToPublicKeyOutputWithContext(ctx context.Context) PublicKeyOutput {
   261  	return o
   262  }
   263  
   264  // Internal value used by CloudFront to allow future updates to the public key configuration.
   265  func (o PublicKeyOutput) CallerReference() pulumi.StringOutput {
   266  	return o.ApplyT(func(v *PublicKey) pulumi.StringOutput { return v.CallerReference }).(pulumi.StringOutput)
   267  }
   268  
   269  // An optional comment about the public key.
   270  func (o PublicKeyOutput) Comment() pulumi.StringPtrOutput {
   271  	return o.ApplyT(func(v *PublicKey) pulumi.StringPtrOutput { return v.Comment }).(pulumi.StringPtrOutput)
   272  }
   273  
   274  // The encoded public key that you want to add to CloudFront to use with features like field-level encryption.
   275  func (o PublicKeyOutput) EncodedKey() pulumi.StringOutput {
   276  	return o.ApplyT(func(v *PublicKey) pulumi.StringOutput { return v.EncodedKey }).(pulumi.StringOutput)
   277  }
   278  
   279  // The current version of the public key. For example: `E2QWRUHAPOMQZL`.
   280  func (o PublicKeyOutput) Etag() pulumi.StringOutput {
   281  	return o.ApplyT(func(v *PublicKey) pulumi.StringOutput { return v.Etag }).(pulumi.StringOutput)
   282  }
   283  
   284  // The name for the public key. By default generated by this provider.
   285  func (o PublicKeyOutput) Name() pulumi.StringOutput {
   286  	return o.ApplyT(func(v *PublicKey) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
   287  }
   288  
   289  // The name for the public key. Conflicts with `name`.
   290  //
   291  // **NOTE:** When setting `encodedKey` value, there needs a newline at the end of string. Otherwise, multiple runs of pulumi will want to recreate the `cloudfront.PublicKey` resource.
   292  func (o PublicKeyOutput) NamePrefix() pulumi.StringOutput {
   293  	return o.ApplyT(func(v *PublicKey) pulumi.StringOutput { return v.NamePrefix }).(pulumi.StringOutput)
   294  }
   295  
   296  type PublicKeyArrayOutput struct{ *pulumi.OutputState }
   297  
   298  func (PublicKeyArrayOutput) ElementType() reflect.Type {
   299  	return reflect.TypeOf((*[]*PublicKey)(nil)).Elem()
   300  }
   301  
   302  func (o PublicKeyArrayOutput) ToPublicKeyArrayOutput() PublicKeyArrayOutput {
   303  	return o
   304  }
   305  
   306  func (o PublicKeyArrayOutput) ToPublicKeyArrayOutputWithContext(ctx context.Context) PublicKeyArrayOutput {
   307  	return o
   308  }
   309  
   310  func (o PublicKeyArrayOutput) Index(i pulumi.IntInput) PublicKeyOutput {
   311  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *PublicKey {
   312  		return vs[0].([]*PublicKey)[vs[1].(int)]
   313  	}).(PublicKeyOutput)
   314  }
   315  
   316  type PublicKeyMapOutput struct{ *pulumi.OutputState }
   317  
   318  func (PublicKeyMapOutput) ElementType() reflect.Type {
   319  	return reflect.TypeOf((*map[string]*PublicKey)(nil)).Elem()
   320  }
   321  
   322  func (o PublicKeyMapOutput) ToPublicKeyMapOutput() PublicKeyMapOutput {
   323  	return o
   324  }
   325  
   326  func (o PublicKeyMapOutput) ToPublicKeyMapOutputWithContext(ctx context.Context) PublicKeyMapOutput {
   327  	return o
   328  }
   329  
   330  func (o PublicKeyMapOutput) MapIndex(k pulumi.StringInput) PublicKeyOutput {
   331  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *PublicKey {
   332  		return vs[0].(map[string]*PublicKey)[vs[1].(string)]
   333  	}).(PublicKeyOutput)
   334  }
   335  
   336  func init() {
   337  	pulumi.RegisterInputType(reflect.TypeOf((*PublicKeyInput)(nil)).Elem(), &PublicKey{})
   338  	pulumi.RegisterInputType(reflect.TypeOf((*PublicKeyArrayInput)(nil)).Elem(), PublicKeyArray{})
   339  	pulumi.RegisterInputType(reflect.TypeOf((*PublicKeyMapInput)(nil)).Elem(), PublicKeyMap{})
   340  	pulumi.RegisterOutputType(PublicKeyOutput{})
   341  	pulumi.RegisterOutputType(PublicKeyArrayOutput{})
   342  	pulumi.RegisterOutputType(PublicKeyMapOutput{})
   343  }