github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/kms/getPublicKey.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  	"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 the public key about the specified KMS Key with flexible key id input. This can be useful to reference key alias without having to hard code the ARN as input.
    15  //
    16  // ## Example Usage
    17  //
    18  // <!--Start PulumiCodeChooser -->
    19  // ```go
    20  // package main
    21  //
    22  // import (
    23  //
    24  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/kms"
    25  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    26  //
    27  // )
    28  //
    29  //	func main() {
    30  //		pulumi.Run(func(ctx *pulumi.Context) error {
    31  //			_, err := kms.GetPublicKey(ctx, &kms.GetPublicKeyArgs{
    32  //				KeyId: "alias/my-key",
    33  //			}, nil)
    34  //			if err != nil {
    35  //				return err
    36  //			}
    37  //			_, err = kms.GetPublicKey(ctx, &kms.GetPublicKeyArgs{
    38  //				KeyId: "1234abcd-12ab-34cd-56ef-1234567890ab",
    39  //			}, nil)
    40  //			if err != nil {
    41  //				return err
    42  //			}
    43  //			_, err = kms.GetPublicKey(ctx, &kms.GetPublicKeyArgs{
    44  //				KeyId: "arn:aws:kms:us-east-1:111122223333:alias/my-key",
    45  //			}, nil)
    46  //			if err != nil {
    47  //				return err
    48  //			}
    49  //			_, err = kms.GetPublicKey(ctx, &kms.GetPublicKeyArgs{
    50  //				KeyId: "arn:aws:kms:us-east-1:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab",
    51  //			}, nil)
    52  //			if err != nil {
    53  //				return err
    54  //			}
    55  //			return nil
    56  //		})
    57  //	}
    58  //
    59  // ```
    60  // <!--End PulumiCodeChooser -->
    61  func GetPublicKey(ctx *pulumi.Context, args *GetPublicKeyArgs, opts ...pulumi.InvokeOption) (*GetPublicKeyResult, error) {
    62  	opts = internal.PkgInvokeDefaultOpts(opts)
    63  	var rv GetPublicKeyResult
    64  	err := ctx.Invoke("aws:kms/getPublicKey:getPublicKey", args, &rv, opts...)
    65  	if err != nil {
    66  		return nil, err
    67  	}
    68  	return &rv, nil
    69  }
    70  
    71  // A collection of arguments for invoking getPublicKey.
    72  type GetPublicKeyArgs struct {
    73  	// List of grant tokens
    74  	GrantTokens []string `pulumi:"grantTokens"`
    75  	// Key identifier which can be one of the following format:
    76  	// * Key ID. E.g - `1234abcd-12ab-34cd-56ef-1234567890ab`
    77  	// * Key ARN. E.g. - `arn:aws:kms:us-east-1:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab`
    78  	// * Alias name. E.g. - `alias/my-key`
    79  	// * Alias ARN - E.g. - `arn:aws:kms:us-east-1:111122223333:alias/my-key`
    80  	KeyId string `pulumi:"keyId"`
    81  }
    82  
    83  // A collection of values returned by getPublicKey.
    84  type GetPublicKeyResult struct {
    85  	// Key ARN of the asymmetric CMK from which the public key was downloaded.
    86  	Arn string `pulumi:"arn"`
    87  	// Type of the public key that was downloaded.
    88  	CustomerMasterKeySpec string `pulumi:"customerMasterKeySpec"`
    89  	// Encryption algorithms that AWS KMS supports for this key. Only set when the `keyUsage` of the public key is `ENCRYPT_DECRYPT`.
    90  	EncryptionAlgorithms []string `pulumi:"encryptionAlgorithms"`
    91  	GrantTokens          []string `pulumi:"grantTokens"`
    92  	// The provider-assigned unique ID for this managed resource.
    93  	Id    string `pulumi:"id"`
    94  	KeyId string `pulumi:"keyId"`
    95  	// Permitted use of the public key. Valid values are `ENCRYPT_DECRYPT` or `SIGN_VERIFY`
    96  	KeyUsage string `pulumi:"keyUsage"`
    97  	// Exported public key. The value is a DER-encoded X.509 public key, also known as SubjectPublicKeyInfo (SPKI), as defined in [RFC 5280](https://tools.ietf.org/html/rfc5280). The value is Base64-encoded.
    98  	PublicKey string `pulumi:"publicKey"`
    99  	// Exported public key. The value is Privacy Enhanced Mail (PEM) encoded.
   100  	PublicKeyPem string `pulumi:"publicKeyPem"`
   101  	// Signing algorithms that AWS KMS supports for this key. Only set when the `keyUsage` of the public key is `SIGN_VERIFY`.
   102  	SigningAlgorithms []string `pulumi:"signingAlgorithms"`
   103  }
   104  
   105  func GetPublicKeyOutput(ctx *pulumi.Context, args GetPublicKeyOutputArgs, opts ...pulumi.InvokeOption) GetPublicKeyResultOutput {
   106  	return pulumi.ToOutputWithContext(context.Background(), args).
   107  		ApplyT(func(v interface{}) (GetPublicKeyResult, error) {
   108  			args := v.(GetPublicKeyArgs)
   109  			r, err := GetPublicKey(ctx, &args, opts...)
   110  			var s GetPublicKeyResult
   111  			if r != nil {
   112  				s = *r
   113  			}
   114  			return s, err
   115  		}).(GetPublicKeyResultOutput)
   116  }
   117  
   118  // A collection of arguments for invoking getPublicKey.
   119  type GetPublicKeyOutputArgs struct {
   120  	// List of grant tokens
   121  	GrantTokens pulumi.StringArrayInput `pulumi:"grantTokens"`
   122  	// Key identifier which can be one of the following format:
   123  	// * Key ID. E.g - `1234abcd-12ab-34cd-56ef-1234567890ab`
   124  	// * Key ARN. E.g. - `arn:aws:kms:us-east-1:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab`
   125  	// * Alias name. E.g. - `alias/my-key`
   126  	// * Alias ARN - E.g. - `arn:aws:kms:us-east-1:111122223333:alias/my-key`
   127  	KeyId pulumi.StringInput `pulumi:"keyId"`
   128  }
   129  
   130  func (GetPublicKeyOutputArgs) ElementType() reflect.Type {
   131  	return reflect.TypeOf((*GetPublicKeyArgs)(nil)).Elem()
   132  }
   133  
   134  // A collection of values returned by getPublicKey.
   135  type GetPublicKeyResultOutput struct{ *pulumi.OutputState }
   136  
   137  func (GetPublicKeyResultOutput) ElementType() reflect.Type {
   138  	return reflect.TypeOf((*GetPublicKeyResult)(nil)).Elem()
   139  }
   140  
   141  func (o GetPublicKeyResultOutput) ToGetPublicKeyResultOutput() GetPublicKeyResultOutput {
   142  	return o
   143  }
   144  
   145  func (o GetPublicKeyResultOutput) ToGetPublicKeyResultOutputWithContext(ctx context.Context) GetPublicKeyResultOutput {
   146  	return o
   147  }
   148  
   149  // Key ARN of the asymmetric CMK from which the public key was downloaded.
   150  func (o GetPublicKeyResultOutput) Arn() pulumi.StringOutput {
   151  	return o.ApplyT(func(v GetPublicKeyResult) string { return v.Arn }).(pulumi.StringOutput)
   152  }
   153  
   154  // Type of the public key that was downloaded.
   155  func (o GetPublicKeyResultOutput) CustomerMasterKeySpec() pulumi.StringOutput {
   156  	return o.ApplyT(func(v GetPublicKeyResult) string { return v.CustomerMasterKeySpec }).(pulumi.StringOutput)
   157  }
   158  
   159  // Encryption algorithms that AWS KMS supports for this key. Only set when the `keyUsage` of the public key is `ENCRYPT_DECRYPT`.
   160  func (o GetPublicKeyResultOutput) EncryptionAlgorithms() pulumi.StringArrayOutput {
   161  	return o.ApplyT(func(v GetPublicKeyResult) []string { return v.EncryptionAlgorithms }).(pulumi.StringArrayOutput)
   162  }
   163  
   164  func (o GetPublicKeyResultOutput) GrantTokens() pulumi.StringArrayOutput {
   165  	return o.ApplyT(func(v GetPublicKeyResult) []string { return v.GrantTokens }).(pulumi.StringArrayOutput)
   166  }
   167  
   168  // The provider-assigned unique ID for this managed resource.
   169  func (o GetPublicKeyResultOutput) Id() pulumi.StringOutput {
   170  	return o.ApplyT(func(v GetPublicKeyResult) string { return v.Id }).(pulumi.StringOutput)
   171  }
   172  
   173  func (o GetPublicKeyResultOutput) KeyId() pulumi.StringOutput {
   174  	return o.ApplyT(func(v GetPublicKeyResult) string { return v.KeyId }).(pulumi.StringOutput)
   175  }
   176  
   177  // Permitted use of the public key. Valid values are `ENCRYPT_DECRYPT` or `SIGN_VERIFY`
   178  func (o GetPublicKeyResultOutput) KeyUsage() pulumi.StringOutput {
   179  	return o.ApplyT(func(v GetPublicKeyResult) string { return v.KeyUsage }).(pulumi.StringOutput)
   180  }
   181  
   182  // Exported public key. The value is a DER-encoded X.509 public key, also known as SubjectPublicKeyInfo (SPKI), as defined in [RFC 5280](https://tools.ietf.org/html/rfc5280). The value is Base64-encoded.
   183  func (o GetPublicKeyResultOutput) PublicKey() pulumi.StringOutput {
   184  	return o.ApplyT(func(v GetPublicKeyResult) string { return v.PublicKey }).(pulumi.StringOutput)
   185  }
   186  
   187  // Exported public key. The value is Privacy Enhanced Mail (PEM) encoded.
   188  func (o GetPublicKeyResultOutput) PublicKeyPem() pulumi.StringOutput {
   189  	return o.ApplyT(func(v GetPublicKeyResult) string { return v.PublicKeyPem }).(pulumi.StringOutput)
   190  }
   191  
   192  // Signing algorithms that AWS KMS supports for this key. Only set when the `keyUsage` of the public key is `SIGN_VERIFY`.
   193  func (o GetPublicKeyResultOutput) SigningAlgorithms() pulumi.StringArrayOutput {
   194  	return o.ApplyT(func(v GetPublicKeyResult) []string { return v.SigningAlgorithms }).(pulumi.StringArrayOutput)
   195  }
   196  
   197  func init() {
   198  	pulumi.RegisterOutputType(GetPublicKeyResultOutput{})
   199  }