github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/lightsail/keyPair.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 lightsail
     5  
     6  import (
     7  	"context"
     8  	"reflect"
     9  
    10  	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal"
    11  	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    12  )
    13  
    14  // Provides a Lightsail Key Pair, for use with Lightsail Instances. These key pairs
    15  // are separate from EC2 Key Pairs, and must be created or imported for use with
    16  // Lightsail.
    17  //
    18  // > **Note:** Lightsail is currently only supported in a limited number of AWS Regions, please see ["Regions and Availability Zones in Amazon Lightsail"](https://lightsail.aws.amazon.com/ls/docs/overview/article/understanding-regions-and-availability-zones-in-amazon-lightsail) for more details
    19  //
    20  // ## Example Usage
    21  //
    22  // ### Create New Key Pair
    23  //
    24  // <!--Start PulumiCodeChooser -->
    25  // ```go
    26  // package main
    27  //
    28  // import (
    29  //
    30  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/lightsail"
    31  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    32  //
    33  // )
    34  //
    35  //	func main() {
    36  //		pulumi.Run(func(ctx *pulumi.Context) error {
    37  //			// Create a new Lightsail Key Pair
    38  //			_, err := lightsail.NewKeyPair(ctx, "lg_key_pair", &lightsail.KeyPairArgs{
    39  //				Name: pulumi.String("lg_key_pair"),
    40  //			})
    41  //			if err != nil {
    42  //				return err
    43  //			}
    44  //			return nil
    45  //		})
    46  //	}
    47  //
    48  // ```
    49  // <!--End PulumiCodeChooser -->
    50  //
    51  // ### Create New Key Pair with PGP Encrypted Private Key
    52  //
    53  // <!--Start PulumiCodeChooser -->
    54  // ```go
    55  // package main
    56  //
    57  // import (
    58  //
    59  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/lightsail"
    60  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    61  //
    62  // )
    63  //
    64  //	func main() {
    65  //		pulumi.Run(func(ctx *pulumi.Context) error {
    66  //			_, err := lightsail.NewKeyPair(ctx, "lg_key_pair", &lightsail.KeyPairArgs{
    67  //				Name:   pulumi.String("lg_key_pair"),
    68  //				PgpKey: pulumi.String("keybase:keybaseusername"),
    69  //			})
    70  //			if err != nil {
    71  //				return err
    72  //			}
    73  //			return nil
    74  //		})
    75  //	}
    76  //
    77  // ```
    78  // <!--End PulumiCodeChooser -->
    79  //
    80  // ### Existing Public Key Import
    81  //
    82  // <!--Start PulumiCodeChooser -->
    83  // ```go
    84  // package main
    85  //
    86  // import (
    87  //
    88  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/lightsail"
    89  //	"github.com/pulumi/pulumi-std/sdk/go/std"
    90  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    91  //
    92  // )
    93  //
    94  //	func main() {
    95  //		pulumi.Run(func(ctx *pulumi.Context) error {
    96  //			invokeFile, err := std.File(ctx, &std.FileArgs{
    97  //				Input: "~/.ssh/id_rsa.pub",
    98  //			}, nil)
    99  //			if err != nil {
   100  //				return err
   101  //			}
   102  //			_, err = lightsail.NewKeyPair(ctx, "lg_key_pair", &lightsail.KeyPairArgs{
   103  //				Name:      pulumi.String("importing"),
   104  //				PublicKey: invokeFile.Result,
   105  //			})
   106  //			if err != nil {
   107  //				return err
   108  //			}
   109  //			return nil
   110  //		})
   111  //	}
   112  //
   113  // ```
   114  // <!--End PulumiCodeChooser -->
   115  //
   116  // ## Import
   117  //
   118  // You cannot import Lightsail Key Pairs because the private and public key are only available on initial creation.
   119  type KeyPair struct {
   120  	pulumi.CustomResourceState
   121  
   122  	// The ARN of the Lightsail key pair.
   123  	Arn pulumi.StringOutput `pulumi:"arn"`
   124  	// The MD5 public key fingerprint for the encrypted private key.
   125  	EncryptedFingerprint pulumi.StringOutput `pulumi:"encryptedFingerprint"`
   126  	// the private key material, base 64 encoded and encrypted with the given `pgpKey`. This is only populated when creating a new key and `pgpKey` is supplied.
   127  	EncryptedPrivateKey pulumi.StringOutput `pulumi:"encryptedPrivateKey"`
   128  	// The MD5 public key fingerprint as specified in section 4 of RFC 4716.
   129  	Fingerprint pulumi.StringOutput `pulumi:"fingerprint"`
   130  	// The name of the Lightsail Key Pair. If omitted, a unique name will be generated by this provider
   131  	Name       pulumi.StringOutput `pulumi:"name"`
   132  	NamePrefix pulumi.StringOutput `pulumi:"namePrefix"`
   133  	// An optional PGP key to encrypt the resulting private key material. Only used when creating a new key pair
   134  	PgpKey pulumi.StringPtrOutput `pulumi:"pgpKey"`
   135  	// the private key, base64 encoded. This is only populated when creating a new key, and when no `pgpKey` is provided.
   136  	PrivateKey pulumi.StringOutput `pulumi:"privateKey"`
   137  	// The public key material. This public key will be imported into Lightsail
   138  	PublicKey pulumi.StringOutput `pulumi:"publicKey"`
   139  	// A map of tags to assign to the collection. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   140  	//
   141  	// > **NOTE:** a PGP key is not required, however it is strongly encouraged. Without a PGP key, the private key material will be stored in state unencrypted.`pgpKey` is ignored if `publicKey` is supplied.
   142  	Tags pulumi.StringMapOutput `pulumi:"tags"`
   143  	// Deprecated: Please use `tags` instead.
   144  	TagsAll pulumi.StringMapOutput `pulumi:"tagsAll"`
   145  }
   146  
   147  // NewKeyPair registers a new resource with the given unique name, arguments, and options.
   148  func NewKeyPair(ctx *pulumi.Context,
   149  	name string, args *KeyPairArgs, opts ...pulumi.ResourceOption) (*KeyPair, error) {
   150  	if args == nil {
   151  		args = &KeyPairArgs{}
   152  	}
   153  
   154  	opts = internal.PkgResourceDefaultOpts(opts)
   155  	var resource KeyPair
   156  	err := ctx.RegisterResource("aws:lightsail/keyPair:KeyPair", name, args, &resource, opts...)
   157  	if err != nil {
   158  		return nil, err
   159  	}
   160  	return &resource, nil
   161  }
   162  
   163  // GetKeyPair gets an existing KeyPair resource's state with the given name, ID, and optional
   164  // state properties that are used to uniquely qualify the lookup (nil if not required).
   165  func GetKeyPair(ctx *pulumi.Context,
   166  	name string, id pulumi.IDInput, state *KeyPairState, opts ...pulumi.ResourceOption) (*KeyPair, error) {
   167  	var resource KeyPair
   168  	err := ctx.ReadResource("aws:lightsail/keyPair:KeyPair", name, id, state, &resource, opts...)
   169  	if err != nil {
   170  		return nil, err
   171  	}
   172  	return &resource, nil
   173  }
   174  
   175  // Input properties used for looking up and filtering KeyPair resources.
   176  type keyPairState struct {
   177  	// The ARN of the Lightsail key pair.
   178  	Arn *string `pulumi:"arn"`
   179  	// The MD5 public key fingerprint for the encrypted private key.
   180  	EncryptedFingerprint *string `pulumi:"encryptedFingerprint"`
   181  	// the private key material, base 64 encoded and encrypted with the given `pgpKey`. This is only populated when creating a new key and `pgpKey` is supplied.
   182  	EncryptedPrivateKey *string `pulumi:"encryptedPrivateKey"`
   183  	// The MD5 public key fingerprint as specified in section 4 of RFC 4716.
   184  	Fingerprint *string `pulumi:"fingerprint"`
   185  	// The name of the Lightsail Key Pair. If omitted, a unique name will be generated by this provider
   186  	Name       *string `pulumi:"name"`
   187  	NamePrefix *string `pulumi:"namePrefix"`
   188  	// An optional PGP key to encrypt the resulting private key material. Only used when creating a new key pair
   189  	PgpKey *string `pulumi:"pgpKey"`
   190  	// the private key, base64 encoded. This is only populated when creating a new key, and when no `pgpKey` is provided.
   191  	PrivateKey *string `pulumi:"privateKey"`
   192  	// The public key material. This public key will be imported into Lightsail
   193  	PublicKey *string `pulumi:"publicKey"`
   194  	// A map of tags to assign to the collection. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   195  	//
   196  	// > **NOTE:** a PGP key is not required, however it is strongly encouraged. Without a PGP key, the private key material will be stored in state unencrypted.`pgpKey` is ignored if `publicKey` is supplied.
   197  	Tags map[string]string `pulumi:"tags"`
   198  	// Deprecated: Please use `tags` instead.
   199  	TagsAll map[string]string `pulumi:"tagsAll"`
   200  }
   201  
   202  type KeyPairState struct {
   203  	// The ARN of the Lightsail key pair.
   204  	Arn pulumi.StringPtrInput
   205  	// The MD5 public key fingerprint for the encrypted private key.
   206  	EncryptedFingerprint pulumi.StringPtrInput
   207  	// the private key material, base 64 encoded and encrypted with the given `pgpKey`. This is only populated when creating a new key and `pgpKey` is supplied.
   208  	EncryptedPrivateKey pulumi.StringPtrInput
   209  	// The MD5 public key fingerprint as specified in section 4 of RFC 4716.
   210  	Fingerprint pulumi.StringPtrInput
   211  	// The name of the Lightsail Key Pair. If omitted, a unique name will be generated by this provider
   212  	Name       pulumi.StringPtrInput
   213  	NamePrefix pulumi.StringPtrInput
   214  	// An optional PGP key to encrypt the resulting private key material. Only used when creating a new key pair
   215  	PgpKey pulumi.StringPtrInput
   216  	// the private key, base64 encoded. This is only populated when creating a new key, and when no `pgpKey` is provided.
   217  	PrivateKey pulumi.StringPtrInput
   218  	// The public key material. This public key will be imported into Lightsail
   219  	PublicKey pulumi.StringPtrInput
   220  	// A map of tags to assign to the collection. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   221  	//
   222  	// > **NOTE:** a PGP key is not required, however it is strongly encouraged. Without a PGP key, the private key material will be stored in state unencrypted.`pgpKey` is ignored if `publicKey` is supplied.
   223  	Tags pulumi.StringMapInput
   224  	// Deprecated: Please use `tags` instead.
   225  	TagsAll pulumi.StringMapInput
   226  }
   227  
   228  func (KeyPairState) ElementType() reflect.Type {
   229  	return reflect.TypeOf((*keyPairState)(nil)).Elem()
   230  }
   231  
   232  type keyPairArgs struct {
   233  	// The name of the Lightsail Key Pair. If omitted, a unique name will be generated by this provider
   234  	Name       *string `pulumi:"name"`
   235  	NamePrefix *string `pulumi:"namePrefix"`
   236  	// An optional PGP key to encrypt the resulting private key material. Only used when creating a new key pair
   237  	PgpKey *string `pulumi:"pgpKey"`
   238  	// The public key material. This public key will be imported into Lightsail
   239  	PublicKey *string `pulumi:"publicKey"`
   240  	// A map of tags to assign to the collection. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   241  	//
   242  	// > **NOTE:** a PGP key is not required, however it is strongly encouraged. Without a PGP key, the private key material will be stored in state unencrypted.`pgpKey` is ignored if `publicKey` is supplied.
   243  	Tags map[string]string `pulumi:"tags"`
   244  }
   245  
   246  // The set of arguments for constructing a KeyPair resource.
   247  type KeyPairArgs struct {
   248  	// The name of the Lightsail Key Pair. If omitted, a unique name will be generated by this provider
   249  	Name       pulumi.StringPtrInput
   250  	NamePrefix pulumi.StringPtrInput
   251  	// An optional PGP key to encrypt the resulting private key material. Only used when creating a new key pair
   252  	PgpKey pulumi.StringPtrInput
   253  	// The public key material. This public key will be imported into Lightsail
   254  	PublicKey pulumi.StringPtrInput
   255  	// A map of tags to assign to the collection. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   256  	//
   257  	// > **NOTE:** a PGP key is not required, however it is strongly encouraged. Without a PGP key, the private key material will be stored in state unencrypted.`pgpKey` is ignored if `publicKey` is supplied.
   258  	Tags pulumi.StringMapInput
   259  }
   260  
   261  func (KeyPairArgs) ElementType() reflect.Type {
   262  	return reflect.TypeOf((*keyPairArgs)(nil)).Elem()
   263  }
   264  
   265  type KeyPairInput interface {
   266  	pulumi.Input
   267  
   268  	ToKeyPairOutput() KeyPairOutput
   269  	ToKeyPairOutputWithContext(ctx context.Context) KeyPairOutput
   270  }
   271  
   272  func (*KeyPair) ElementType() reflect.Type {
   273  	return reflect.TypeOf((**KeyPair)(nil)).Elem()
   274  }
   275  
   276  func (i *KeyPair) ToKeyPairOutput() KeyPairOutput {
   277  	return i.ToKeyPairOutputWithContext(context.Background())
   278  }
   279  
   280  func (i *KeyPair) ToKeyPairOutputWithContext(ctx context.Context) KeyPairOutput {
   281  	return pulumi.ToOutputWithContext(ctx, i).(KeyPairOutput)
   282  }
   283  
   284  // KeyPairArrayInput is an input type that accepts KeyPairArray and KeyPairArrayOutput values.
   285  // You can construct a concrete instance of `KeyPairArrayInput` via:
   286  //
   287  //	KeyPairArray{ KeyPairArgs{...} }
   288  type KeyPairArrayInput interface {
   289  	pulumi.Input
   290  
   291  	ToKeyPairArrayOutput() KeyPairArrayOutput
   292  	ToKeyPairArrayOutputWithContext(context.Context) KeyPairArrayOutput
   293  }
   294  
   295  type KeyPairArray []KeyPairInput
   296  
   297  func (KeyPairArray) ElementType() reflect.Type {
   298  	return reflect.TypeOf((*[]*KeyPair)(nil)).Elem()
   299  }
   300  
   301  func (i KeyPairArray) ToKeyPairArrayOutput() KeyPairArrayOutput {
   302  	return i.ToKeyPairArrayOutputWithContext(context.Background())
   303  }
   304  
   305  func (i KeyPairArray) ToKeyPairArrayOutputWithContext(ctx context.Context) KeyPairArrayOutput {
   306  	return pulumi.ToOutputWithContext(ctx, i).(KeyPairArrayOutput)
   307  }
   308  
   309  // KeyPairMapInput is an input type that accepts KeyPairMap and KeyPairMapOutput values.
   310  // You can construct a concrete instance of `KeyPairMapInput` via:
   311  //
   312  //	KeyPairMap{ "key": KeyPairArgs{...} }
   313  type KeyPairMapInput interface {
   314  	pulumi.Input
   315  
   316  	ToKeyPairMapOutput() KeyPairMapOutput
   317  	ToKeyPairMapOutputWithContext(context.Context) KeyPairMapOutput
   318  }
   319  
   320  type KeyPairMap map[string]KeyPairInput
   321  
   322  func (KeyPairMap) ElementType() reflect.Type {
   323  	return reflect.TypeOf((*map[string]*KeyPair)(nil)).Elem()
   324  }
   325  
   326  func (i KeyPairMap) ToKeyPairMapOutput() KeyPairMapOutput {
   327  	return i.ToKeyPairMapOutputWithContext(context.Background())
   328  }
   329  
   330  func (i KeyPairMap) ToKeyPairMapOutputWithContext(ctx context.Context) KeyPairMapOutput {
   331  	return pulumi.ToOutputWithContext(ctx, i).(KeyPairMapOutput)
   332  }
   333  
   334  type KeyPairOutput struct{ *pulumi.OutputState }
   335  
   336  func (KeyPairOutput) ElementType() reflect.Type {
   337  	return reflect.TypeOf((**KeyPair)(nil)).Elem()
   338  }
   339  
   340  func (o KeyPairOutput) ToKeyPairOutput() KeyPairOutput {
   341  	return o
   342  }
   343  
   344  func (o KeyPairOutput) ToKeyPairOutputWithContext(ctx context.Context) KeyPairOutput {
   345  	return o
   346  }
   347  
   348  // The ARN of the Lightsail key pair.
   349  func (o KeyPairOutput) Arn() pulumi.StringOutput {
   350  	return o.ApplyT(func(v *KeyPair) pulumi.StringOutput { return v.Arn }).(pulumi.StringOutput)
   351  }
   352  
   353  // The MD5 public key fingerprint for the encrypted private key.
   354  func (o KeyPairOutput) EncryptedFingerprint() pulumi.StringOutput {
   355  	return o.ApplyT(func(v *KeyPair) pulumi.StringOutput { return v.EncryptedFingerprint }).(pulumi.StringOutput)
   356  }
   357  
   358  // the private key material, base 64 encoded and encrypted with the given `pgpKey`. This is only populated when creating a new key and `pgpKey` is supplied.
   359  func (o KeyPairOutput) EncryptedPrivateKey() pulumi.StringOutput {
   360  	return o.ApplyT(func(v *KeyPair) pulumi.StringOutput { return v.EncryptedPrivateKey }).(pulumi.StringOutput)
   361  }
   362  
   363  // The MD5 public key fingerprint as specified in section 4 of RFC 4716.
   364  func (o KeyPairOutput) Fingerprint() pulumi.StringOutput {
   365  	return o.ApplyT(func(v *KeyPair) pulumi.StringOutput { return v.Fingerprint }).(pulumi.StringOutput)
   366  }
   367  
   368  // The name of the Lightsail Key Pair. If omitted, a unique name will be generated by this provider
   369  func (o KeyPairOutput) Name() pulumi.StringOutput {
   370  	return o.ApplyT(func(v *KeyPair) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
   371  }
   372  
   373  func (o KeyPairOutput) NamePrefix() pulumi.StringOutput {
   374  	return o.ApplyT(func(v *KeyPair) pulumi.StringOutput { return v.NamePrefix }).(pulumi.StringOutput)
   375  }
   376  
   377  // An optional PGP key to encrypt the resulting private key material. Only used when creating a new key pair
   378  func (o KeyPairOutput) PgpKey() pulumi.StringPtrOutput {
   379  	return o.ApplyT(func(v *KeyPair) pulumi.StringPtrOutput { return v.PgpKey }).(pulumi.StringPtrOutput)
   380  }
   381  
   382  // the private key, base64 encoded. This is only populated when creating a new key, and when no `pgpKey` is provided.
   383  func (o KeyPairOutput) PrivateKey() pulumi.StringOutput {
   384  	return o.ApplyT(func(v *KeyPair) pulumi.StringOutput { return v.PrivateKey }).(pulumi.StringOutput)
   385  }
   386  
   387  // The public key material. This public key will be imported into Lightsail
   388  func (o KeyPairOutput) PublicKey() pulumi.StringOutput {
   389  	return o.ApplyT(func(v *KeyPair) pulumi.StringOutput { return v.PublicKey }).(pulumi.StringOutput)
   390  }
   391  
   392  // A map of tags to assign to the collection. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   393  //
   394  // > **NOTE:** a PGP key is not required, however it is strongly encouraged. Without a PGP key, the private key material will be stored in state unencrypted.`pgpKey` is ignored if `publicKey` is supplied.
   395  func (o KeyPairOutput) Tags() pulumi.StringMapOutput {
   396  	return o.ApplyT(func(v *KeyPair) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)
   397  }
   398  
   399  // Deprecated: Please use `tags` instead.
   400  func (o KeyPairOutput) TagsAll() pulumi.StringMapOutput {
   401  	return o.ApplyT(func(v *KeyPair) pulumi.StringMapOutput { return v.TagsAll }).(pulumi.StringMapOutput)
   402  }
   403  
   404  type KeyPairArrayOutput struct{ *pulumi.OutputState }
   405  
   406  func (KeyPairArrayOutput) ElementType() reflect.Type {
   407  	return reflect.TypeOf((*[]*KeyPair)(nil)).Elem()
   408  }
   409  
   410  func (o KeyPairArrayOutput) ToKeyPairArrayOutput() KeyPairArrayOutput {
   411  	return o
   412  }
   413  
   414  func (o KeyPairArrayOutput) ToKeyPairArrayOutputWithContext(ctx context.Context) KeyPairArrayOutput {
   415  	return o
   416  }
   417  
   418  func (o KeyPairArrayOutput) Index(i pulumi.IntInput) KeyPairOutput {
   419  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *KeyPair {
   420  		return vs[0].([]*KeyPair)[vs[1].(int)]
   421  	}).(KeyPairOutput)
   422  }
   423  
   424  type KeyPairMapOutput struct{ *pulumi.OutputState }
   425  
   426  func (KeyPairMapOutput) ElementType() reflect.Type {
   427  	return reflect.TypeOf((*map[string]*KeyPair)(nil)).Elem()
   428  }
   429  
   430  func (o KeyPairMapOutput) ToKeyPairMapOutput() KeyPairMapOutput {
   431  	return o
   432  }
   433  
   434  func (o KeyPairMapOutput) ToKeyPairMapOutputWithContext(ctx context.Context) KeyPairMapOutput {
   435  	return o
   436  }
   437  
   438  func (o KeyPairMapOutput) MapIndex(k pulumi.StringInput) KeyPairOutput {
   439  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *KeyPair {
   440  		return vs[0].(map[string]*KeyPair)[vs[1].(string)]
   441  	}).(KeyPairOutput)
   442  }
   443  
   444  func init() {
   445  	pulumi.RegisterInputType(reflect.TypeOf((*KeyPairInput)(nil)).Elem(), &KeyPair{})
   446  	pulumi.RegisterInputType(reflect.TypeOf((*KeyPairArrayInput)(nil)).Elem(), KeyPairArray{})
   447  	pulumi.RegisterInputType(reflect.TypeOf((*KeyPairMapInput)(nil)).Elem(), KeyPairMap{})
   448  	pulumi.RegisterOutputType(KeyPairOutput{})
   449  	pulumi.RegisterOutputType(KeyPairArrayOutput{})
   450  	pulumi.RegisterOutputType(KeyPairMapOutput{})
   451  }