github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/acm/getCertificate.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 acm
     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 ARN of a certificate in AWS Certificate
    15  // Manager (ACM), you can reference
    16  // it by domain without having to hard code the ARNs as input.
    17  //
    18  // ## Example Usage
    19  //
    20  // <!--Start PulumiCodeChooser -->
    21  // ```go
    22  // package main
    23  //
    24  // import (
    25  //
    26  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/acm"
    27  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    28  //
    29  // )
    30  //
    31  //	func main() {
    32  //		pulumi.Run(func(ctx *pulumi.Context) error {
    33  //			// Find a certificate that is issued
    34  //			_, err := acm.LookupCertificate(ctx, &acm.LookupCertificateArgs{
    35  //				Domain: "tf.example.com",
    36  //				Statuses: []string{
    37  //					"ISSUED",
    38  //				},
    39  //			}, nil)
    40  //			if err != nil {
    41  //				return err
    42  //			}
    43  //			// Find a certificate issued by (not imported into) ACM
    44  //			_, err = acm.LookupCertificate(ctx, &acm.LookupCertificateArgs{
    45  //				Domain: "tf.example.com",
    46  //				Types: []string{
    47  //					"AMAZON_ISSUED",
    48  //				},
    49  //				MostRecent: pulumi.BoolRef(true),
    50  //			}, nil)
    51  //			if err != nil {
    52  //				return err
    53  //			}
    54  //			// Find a RSA 4096 bit certificate
    55  //			_, err = acm.LookupCertificate(ctx, &acm.LookupCertificateArgs{
    56  //				Domain: "tf.example.com",
    57  //				KeyTypes: []string{
    58  //					"RSA_4096",
    59  //				},
    60  //			}, nil)
    61  //			if err != nil {
    62  //				return err
    63  //			}
    64  //			return nil
    65  //		})
    66  //	}
    67  //
    68  // ```
    69  // <!--End PulumiCodeChooser -->
    70  func LookupCertificate(ctx *pulumi.Context, args *LookupCertificateArgs, opts ...pulumi.InvokeOption) (*LookupCertificateResult, error) {
    71  	opts = internal.PkgInvokeDefaultOpts(opts)
    72  	var rv LookupCertificateResult
    73  	err := ctx.Invoke("aws:acm/getCertificate:getCertificate", args, &rv, opts...)
    74  	if err != nil {
    75  		return nil, err
    76  	}
    77  	return &rv, nil
    78  }
    79  
    80  // A collection of arguments for invoking getCertificate.
    81  type LookupCertificateArgs struct {
    82  	// Domain of the certificate to look up. If no certificate is found with this name, an error will be returned.
    83  	Domain string `pulumi:"domain"`
    84  	// List of key algorithms to filter certificates. By default, ACM does not return all certificate types when searching. See the [ACM API Reference](https://docs.aws.amazon.com/acm/latest/APIReference/API_CertificateDetail.html#ACM-Type-CertificateDetail-KeyAlgorithm) for supported key algorithms.
    85  	KeyTypes []string `pulumi:"keyTypes"`
    86  	// If set to true, it sorts the certificates matched by previous criteria by the NotBefore field, returning only the most recent one. If set to false, it returns an error if more than one certificate is found. Defaults to false.
    87  	MostRecent *bool `pulumi:"mostRecent"`
    88  	// List of statuses on which to filter the returned list. Valid values are `PENDING_VALIDATION`, `ISSUED`,
    89  	// `INACTIVE`, `EXPIRED`, `VALIDATION_TIMED_OUT`, `REVOKED` and `FAILED`. If no value is specified, only certificates in the `ISSUED` state
    90  	// are returned.
    91  	Statuses []string `pulumi:"statuses"`
    92  	// Mapping of tags for the resource.
    93  	Tags map[string]string `pulumi:"tags"`
    94  	// List of types on which to filter the returned list. Valid values are `AMAZON_ISSUED`, `PRIVATE`, and `IMPORTED`.
    95  	Types []string `pulumi:"types"`
    96  }
    97  
    98  // A collection of values returned by getCertificate.
    99  type LookupCertificateResult struct {
   100  	// ARN of the found certificate, suitable for referencing in other resources that support ACM certificates.
   101  	Arn string `pulumi:"arn"`
   102  	// ACM-issued certificate.
   103  	Certificate string `pulumi:"certificate"`
   104  	// Certificates forming the requested ACM-issued certificate's chain of trust. The chain consists of the certificate of the issuing CA and the intermediate certificates of any other subordinate CAs.
   105  	CertificateChain string `pulumi:"certificateChain"`
   106  	Domain           string `pulumi:"domain"`
   107  	// The provider-assigned unique ID for this managed resource.
   108  	Id         string   `pulumi:"id"`
   109  	KeyTypes   []string `pulumi:"keyTypes"`
   110  	MostRecent *bool    `pulumi:"mostRecent"`
   111  	// Status of the found certificate.
   112  	Status   string   `pulumi:"status"`
   113  	Statuses []string `pulumi:"statuses"`
   114  	// Mapping of tags for the resource.
   115  	Tags  map[string]string `pulumi:"tags"`
   116  	Types []string          `pulumi:"types"`
   117  }
   118  
   119  func LookupCertificateOutput(ctx *pulumi.Context, args LookupCertificateOutputArgs, opts ...pulumi.InvokeOption) LookupCertificateResultOutput {
   120  	return pulumi.ToOutputWithContext(context.Background(), args).
   121  		ApplyT(func(v interface{}) (LookupCertificateResult, error) {
   122  			args := v.(LookupCertificateArgs)
   123  			r, err := LookupCertificate(ctx, &args, opts...)
   124  			var s LookupCertificateResult
   125  			if r != nil {
   126  				s = *r
   127  			}
   128  			return s, err
   129  		}).(LookupCertificateResultOutput)
   130  }
   131  
   132  // A collection of arguments for invoking getCertificate.
   133  type LookupCertificateOutputArgs struct {
   134  	// Domain of the certificate to look up. If no certificate is found with this name, an error will be returned.
   135  	Domain pulumi.StringInput `pulumi:"domain"`
   136  	// List of key algorithms to filter certificates. By default, ACM does not return all certificate types when searching. See the [ACM API Reference](https://docs.aws.amazon.com/acm/latest/APIReference/API_CertificateDetail.html#ACM-Type-CertificateDetail-KeyAlgorithm) for supported key algorithms.
   137  	KeyTypes pulumi.StringArrayInput `pulumi:"keyTypes"`
   138  	// If set to true, it sorts the certificates matched by previous criteria by the NotBefore field, returning only the most recent one. If set to false, it returns an error if more than one certificate is found. Defaults to false.
   139  	MostRecent pulumi.BoolPtrInput `pulumi:"mostRecent"`
   140  	// List of statuses on which to filter the returned list. Valid values are `PENDING_VALIDATION`, `ISSUED`,
   141  	// `INACTIVE`, `EXPIRED`, `VALIDATION_TIMED_OUT`, `REVOKED` and `FAILED`. If no value is specified, only certificates in the `ISSUED` state
   142  	// are returned.
   143  	Statuses pulumi.StringArrayInput `pulumi:"statuses"`
   144  	// Mapping of tags for the resource.
   145  	Tags pulumi.StringMapInput `pulumi:"tags"`
   146  	// List of types on which to filter the returned list. Valid values are `AMAZON_ISSUED`, `PRIVATE`, and `IMPORTED`.
   147  	Types pulumi.StringArrayInput `pulumi:"types"`
   148  }
   149  
   150  func (LookupCertificateOutputArgs) ElementType() reflect.Type {
   151  	return reflect.TypeOf((*LookupCertificateArgs)(nil)).Elem()
   152  }
   153  
   154  // A collection of values returned by getCertificate.
   155  type LookupCertificateResultOutput struct{ *pulumi.OutputState }
   156  
   157  func (LookupCertificateResultOutput) ElementType() reflect.Type {
   158  	return reflect.TypeOf((*LookupCertificateResult)(nil)).Elem()
   159  }
   160  
   161  func (o LookupCertificateResultOutput) ToLookupCertificateResultOutput() LookupCertificateResultOutput {
   162  	return o
   163  }
   164  
   165  func (o LookupCertificateResultOutput) ToLookupCertificateResultOutputWithContext(ctx context.Context) LookupCertificateResultOutput {
   166  	return o
   167  }
   168  
   169  // ARN of the found certificate, suitable for referencing in other resources that support ACM certificates.
   170  func (o LookupCertificateResultOutput) Arn() pulumi.StringOutput {
   171  	return o.ApplyT(func(v LookupCertificateResult) string { return v.Arn }).(pulumi.StringOutput)
   172  }
   173  
   174  // ACM-issued certificate.
   175  func (o LookupCertificateResultOutput) Certificate() pulumi.StringOutput {
   176  	return o.ApplyT(func(v LookupCertificateResult) string { return v.Certificate }).(pulumi.StringOutput)
   177  }
   178  
   179  // Certificates forming the requested ACM-issued certificate's chain of trust. The chain consists of the certificate of the issuing CA and the intermediate certificates of any other subordinate CAs.
   180  func (o LookupCertificateResultOutput) CertificateChain() pulumi.StringOutput {
   181  	return o.ApplyT(func(v LookupCertificateResult) string { return v.CertificateChain }).(pulumi.StringOutput)
   182  }
   183  
   184  func (o LookupCertificateResultOutput) Domain() pulumi.StringOutput {
   185  	return o.ApplyT(func(v LookupCertificateResult) string { return v.Domain }).(pulumi.StringOutput)
   186  }
   187  
   188  // The provider-assigned unique ID for this managed resource.
   189  func (o LookupCertificateResultOutput) Id() pulumi.StringOutput {
   190  	return o.ApplyT(func(v LookupCertificateResult) string { return v.Id }).(pulumi.StringOutput)
   191  }
   192  
   193  func (o LookupCertificateResultOutput) KeyTypes() pulumi.StringArrayOutput {
   194  	return o.ApplyT(func(v LookupCertificateResult) []string { return v.KeyTypes }).(pulumi.StringArrayOutput)
   195  }
   196  
   197  func (o LookupCertificateResultOutput) MostRecent() pulumi.BoolPtrOutput {
   198  	return o.ApplyT(func(v LookupCertificateResult) *bool { return v.MostRecent }).(pulumi.BoolPtrOutput)
   199  }
   200  
   201  // Status of the found certificate.
   202  func (o LookupCertificateResultOutput) Status() pulumi.StringOutput {
   203  	return o.ApplyT(func(v LookupCertificateResult) string { return v.Status }).(pulumi.StringOutput)
   204  }
   205  
   206  func (o LookupCertificateResultOutput) Statuses() pulumi.StringArrayOutput {
   207  	return o.ApplyT(func(v LookupCertificateResult) []string { return v.Statuses }).(pulumi.StringArrayOutput)
   208  }
   209  
   210  // Mapping of tags for the resource.
   211  func (o LookupCertificateResultOutput) Tags() pulumi.StringMapOutput {
   212  	return o.ApplyT(func(v LookupCertificateResult) map[string]string { return v.Tags }).(pulumi.StringMapOutput)
   213  }
   214  
   215  func (o LookupCertificateResultOutput) Types() pulumi.StringArrayOutput {
   216  	return o.ApplyT(func(v LookupCertificateResult) []string { return v.Types }).(pulumi.StringArrayOutput)
   217  }
   218  
   219  func init() {
   220  	pulumi.RegisterOutputType(LookupCertificateResultOutput{})
   221  }