github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/ec2/getKeyPair.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 ec2
     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  // Use this data source to get information about a specific EC2 Key Pair.
    15  //
    16  // ## Example Usage
    17  //
    18  // The following example shows how to get a EC2 Key Pair including the public key material from its name.
    19  //
    20  // <!--Start PulumiCodeChooser -->
    21  // ```go
    22  // package main
    23  //
    24  // import (
    25  //
    26  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2"
    27  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    28  //
    29  // )
    30  //
    31  //	func main() {
    32  //		pulumi.Run(func(ctx *pulumi.Context) error {
    33  //			example, err := ec2.LookupKeyPair(ctx, &ec2.LookupKeyPairArgs{
    34  //				KeyName:          pulumi.StringRef("test"),
    35  //				IncludePublicKey: pulumi.BoolRef(true),
    36  //				Filters: []ec2.GetKeyPairFilter{
    37  //					{
    38  //						Name: "tag:Component",
    39  //						Values: []string{
    40  //							"web",
    41  //						},
    42  //					},
    43  //				},
    44  //			}, nil)
    45  //			if err != nil {
    46  //				return err
    47  //			}
    48  //			ctx.Export("fingerprint", example.Fingerprint)
    49  //			ctx.Export("name", example.KeyName)
    50  //			ctx.Export("id", example.Id)
    51  //			return nil
    52  //		})
    53  //	}
    54  //
    55  // ```
    56  // <!--End PulumiCodeChooser -->
    57  func LookupKeyPair(ctx *pulumi.Context, args *LookupKeyPairArgs, opts ...pulumi.InvokeOption) (*LookupKeyPairResult, error) {
    58  	opts = internal.PkgInvokeDefaultOpts(opts)
    59  	var rv LookupKeyPairResult
    60  	err := ctx.Invoke("aws:ec2/getKeyPair:getKeyPair", args, &rv, opts...)
    61  	if err != nil {
    62  		return nil, err
    63  	}
    64  	return &rv, nil
    65  }
    66  
    67  // A collection of arguments for invoking getKeyPair.
    68  type LookupKeyPairArgs struct {
    69  	// Custom filter block as described below.
    70  	Filters []GetKeyPairFilter `pulumi:"filters"`
    71  	// Whether to include the public key material in the response.
    72  	IncludePublicKey *bool `pulumi:"includePublicKey"`
    73  	// Key Pair name.
    74  	KeyName *string `pulumi:"keyName"`
    75  	// Key Pair ID.
    76  	KeyPairId *string `pulumi:"keyPairId"`
    77  	// Any tags assigned to the Key Pair.
    78  	Tags map[string]string `pulumi:"tags"`
    79  }
    80  
    81  // A collection of values returned by getKeyPair.
    82  type LookupKeyPairResult struct {
    83  	// ARN of the Key Pair.
    84  	Arn string `pulumi:"arn"`
    85  	// Timestamp for when the key pair was created in ISO 8601 format.
    86  	CreateTime string             `pulumi:"createTime"`
    87  	Filters    []GetKeyPairFilter `pulumi:"filters"`
    88  	// SHA-1 digest of the DER encoded private key.
    89  	Fingerprint string `pulumi:"fingerprint"`
    90  	// The provider-assigned unique ID for this managed resource.
    91  	Id               string  `pulumi:"id"`
    92  	IncludePublicKey *bool   `pulumi:"includePublicKey"`
    93  	KeyName          *string `pulumi:"keyName"`
    94  	KeyPairId        *string `pulumi:"keyPairId"`
    95  	// Type of key pair.
    96  	KeyType string `pulumi:"keyType"`
    97  	// Public key material.
    98  	PublicKey string `pulumi:"publicKey"`
    99  	// Any tags assigned to the Key Pair.
   100  	Tags map[string]string `pulumi:"tags"`
   101  }
   102  
   103  func LookupKeyPairOutput(ctx *pulumi.Context, args LookupKeyPairOutputArgs, opts ...pulumi.InvokeOption) LookupKeyPairResultOutput {
   104  	return pulumi.ToOutputWithContext(context.Background(), args).
   105  		ApplyT(func(v interface{}) (LookupKeyPairResult, error) {
   106  			args := v.(LookupKeyPairArgs)
   107  			r, err := LookupKeyPair(ctx, &args, opts...)
   108  			var s LookupKeyPairResult
   109  			if r != nil {
   110  				s = *r
   111  			}
   112  			return s, err
   113  		}).(LookupKeyPairResultOutput)
   114  }
   115  
   116  // A collection of arguments for invoking getKeyPair.
   117  type LookupKeyPairOutputArgs struct {
   118  	// Custom filter block as described below.
   119  	Filters GetKeyPairFilterArrayInput `pulumi:"filters"`
   120  	// Whether to include the public key material in the response.
   121  	IncludePublicKey pulumi.BoolPtrInput `pulumi:"includePublicKey"`
   122  	// Key Pair name.
   123  	KeyName pulumi.StringPtrInput `pulumi:"keyName"`
   124  	// Key Pair ID.
   125  	KeyPairId pulumi.StringPtrInput `pulumi:"keyPairId"`
   126  	// Any tags assigned to the Key Pair.
   127  	Tags pulumi.StringMapInput `pulumi:"tags"`
   128  }
   129  
   130  func (LookupKeyPairOutputArgs) ElementType() reflect.Type {
   131  	return reflect.TypeOf((*LookupKeyPairArgs)(nil)).Elem()
   132  }
   133  
   134  // A collection of values returned by getKeyPair.
   135  type LookupKeyPairResultOutput struct{ *pulumi.OutputState }
   136  
   137  func (LookupKeyPairResultOutput) ElementType() reflect.Type {
   138  	return reflect.TypeOf((*LookupKeyPairResult)(nil)).Elem()
   139  }
   140  
   141  func (o LookupKeyPairResultOutput) ToLookupKeyPairResultOutput() LookupKeyPairResultOutput {
   142  	return o
   143  }
   144  
   145  func (o LookupKeyPairResultOutput) ToLookupKeyPairResultOutputWithContext(ctx context.Context) LookupKeyPairResultOutput {
   146  	return o
   147  }
   148  
   149  // ARN of the Key Pair.
   150  func (o LookupKeyPairResultOutput) Arn() pulumi.StringOutput {
   151  	return o.ApplyT(func(v LookupKeyPairResult) string { return v.Arn }).(pulumi.StringOutput)
   152  }
   153  
   154  // Timestamp for when the key pair was created in ISO 8601 format.
   155  func (o LookupKeyPairResultOutput) CreateTime() pulumi.StringOutput {
   156  	return o.ApplyT(func(v LookupKeyPairResult) string { return v.CreateTime }).(pulumi.StringOutput)
   157  }
   158  
   159  func (o LookupKeyPairResultOutput) Filters() GetKeyPairFilterArrayOutput {
   160  	return o.ApplyT(func(v LookupKeyPairResult) []GetKeyPairFilter { return v.Filters }).(GetKeyPairFilterArrayOutput)
   161  }
   162  
   163  // SHA-1 digest of the DER encoded private key.
   164  func (o LookupKeyPairResultOutput) Fingerprint() pulumi.StringOutput {
   165  	return o.ApplyT(func(v LookupKeyPairResult) string { return v.Fingerprint }).(pulumi.StringOutput)
   166  }
   167  
   168  // The provider-assigned unique ID for this managed resource.
   169  func (o LookupKeyPairResultOutput) Id() pulumi.StringOutput {
   170  	return o.ApplyT(func(v LookupKeyPairResult) string { return v.Id }).(pulumi.StringOutput)
   171  }
   172  
   173  func (o LookupKeyPairResultOutput) IncludePublicKey() pulumi.BoolPtrOutput {
   174  	return o.ApplyT(func(v LookupKeyPairResult) *bool { return v.IncludePublicKey }).(pulumi.BoolPtrOutput)
   175  }
   176  
   177  func (o LookupKeyPairResultOutput) KeyName() pulumi.StringPtrOutput {
   178  	return o.ApplyT(func(v LookupKeyPairResult) *string { return v.KeyName }).(pulumi.StringPtrOutput)
   179  }
   180  
   181  func (o LookupKeyPairResultOutput) KeyPairId() pulumi.StringPtrOutput {
   182  	return o.ApplyT(func(v LookupKeyPairResult) *string { return v.KeyPairId }).(pulumi.StringPtrOutput)
   183  }
   184  
   185  // Type of key pair.
   186  func (o LookupKeyPairResultOutput) KeyType() pulumi.StringOutput {
   187  	return o.ApplyT(func(v LookupKeyPairResult) string { return v.KeyType }).(pulumi.StringOutput)
   188  }
   189  
   190  // Public key material.
   191  func (o LookupKeyPairResultOutput) PublicKey() pulumi.StringOutput {
   192  	return o.ApplyT(func(v LookupKeyPairResult) string { return v.PublicKey }).(pulumi.StringOutput)
   193  }
   194  
   195  // Any tags assigned to the Key Pair.
   196  func (o LookupKeyPairResultOutput) Tags() pulumi.StringMapOutput {
   197  	return o.ApplyT(func(v LookupKeyPairResult) map[string]string { return v.Tags }).(pulumi.StringMapOutput)
   198  }
   199  
   200  func init() {
   201  	pulumi.RegisterOutputType(LookupKeyPairResultOutput{})
   202  }