AWS v6.77.1 published on Friday, Apr 18, 2025 by Pulumi
aws.iam.getServerCertificate
Explore with Pulumi AI
Use this data source to lookup information about IAM Server Certificates.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const my_domain = aws.iam.getServerCertificate({
    namePrefix: "my-domain.org",
    latest: true,
});
const elb = new aws.elb.LoadBalancer("elb", {
    name: "my-domain-elb",
    listeners: [{
        instancePort: 8000,
        instanceProtocol: "https",
        lbPort: 443,
        lbProtocol: "https",
        sslCertificateId: my_domain.then(my_domain => my_domain.arn),
    }],
});
import pulumi
import pulumi_aws as aws
my_domain = aws.iam.get_server_certificate(name_prefix="my-domain.org",
    latest=True)
elb = aws.elb.LoadBalancer("elb",
    name="my-domain-elb",
    listeners=[{
        "instance_port": 8000,
        "instance_protocol": "https",
        "lb_port": 443,
        "lb_protocol": "https",
        "ssl_certificate_id": my_domain.arn,
    }])
package main
import (
	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/elb"
	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iam"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		my_domain, err := iam.LookupServerCertificate(ctx, &iam.LookupServerCertificateArgs{
			NamePrefix: pulumi.StringRef("my-domain.org"),
			Latest:     pulumi.BoolRef(true),
		}, nil)
		if err != nil {
			return err
		}
		_, err = elb.NewLoadBalancer(ctx, "elb", &elb.LoadBalancerArgs{
			Name: pulumi.String("my-domain-elb"),
			Listeners: elb.LoadBalancerListenerArray{
				&elb.LoadBalancerListenerArgs{
					InstancePort:     pulumi.Int(8000),
					InstanceProtocol: pulumi.String("https"),
					LbPort:           pulumi.Int(443),
					LbProtocol:       pulumi.String("https"),
					SslCertificateId: pulumi.String(my_domain.Arn),
				},
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() => 
{
    var my_domain = Aws.Iam.GetServerCertificate.Invoke(new()
    {
        NamePrefix = "my-domain.org",
        Latest = true,
    });
    var elb = new Aws.Elb.LoadBalancer("elb", new()
    {
        Name = "my-domain-elb",
        Listeners = new[]
        {
            new Aws.Elb.Inputs.LoadBalancerListenerArgs
            {
                InstancePort = 8000,
                InstanceProtocol = "https",
                LbPort = 443,
                LbProtocol = "https",
                SslCertificateId = my_domain.Apply(my_domain => my_domain.Apply(getServerCertificateResult => getServerCertificateResult.Arn)),
            },
        },
    });
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.iam.IamFunctions;
import com.pulumi.aws.iam.inputs.GetServerCertificateArgs;
import com.pulumi.aws.elb.LoadBalancer;
import com.pulumi.aws.elb.LoadBalancerArgs;
import com.pulumi.aws.elb.inputs.LoadBalancerListenerArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }
    public static void stack(Context ctx) {
        final var my-domain = IamFunctions.getServerCertificate(GetServerCertificateArgs.builder()
            .namePrefix("my-domain.org")
            .latest(true)
            .build());
        var elb = new LoadBalancer("elb", LoadBalancerArgs.builder()
            .name("my-domain-elb")
            .listeners(LoadBalancerListenerArgs.builder()
                .instancePort(8000)
                .instanceProtocol("https")
                .lbPort(443)
                .lbProtocol("https")
                .sslCertificateId(my_domain.arn())
                .build())
            .build());
    }
}
resources:
  elb:
    type: aws:elb:LoadBalancer
    properties:
      name: my-domain-elb
      listeners:
        - instancePort: 8000
          instanceProtocol: https
          lbPort: 443
          lbProtocol: https
          sslCertificateId: ${["my-domain"].arn}
variables:
  my-domain:
    fn::invoke:
      function: aws:iam:getServerCertificate
      arguments:
        namePrefix: my-domain.org
        latest: true
Using getServerCertificate
Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.
function getServerCertificate(args: GetServerCertificateArgs, opts?: InvokeOptions): Promise<GetServerCertificateResult>
function getServerCertificateOutput(args: GetServerCertificateOutputArgs, opts?: InvokeOptions): Output<GetServerCertificateResult>def get_server_certificate(latest: Optional[bool] = None,
                           name: Optional[str] = None,
                           name_prefix: Optional[str] = None,
                           path_prefix: Optional[str] = None,
                           opts: Optional[InvokeOptions] = None) -> GetServerCertificateResult
def get_server_certificate_output(latest: Optional[pulumi.Input[bool]] = None,
                           name: Optional[pulumi.Input[str]] = None,
                           name_prefix: Optional[pulumi.Input[str]] = None,
                           path_prefix: Optional[pulumi.Input[str]] = None,
                           opts: Optional[InvokeOptions] = None) -> Output[GetServerCertificateResult]func LookupServerCertificate(ctx *Context, args *LookupServerCertificateArgs, opts ...InvokeOption) (*LookupServerCertificateResult, error)
func LookupServerCertificateOutput(ctx *Context, args *LookupServerCertificateOutputArgs, opts ...InvokeOption) LookupServerCertificateResultOutput> Note: This function is named LookupServerCertificate in the Go SDK.
public static class GetServerCertificate 
{
    public static Task<GetServerCertificateResult> InvokeAsync(GetServerCertificateArgs args, InvokeOptions? opts = null)
    public static Output<GetServerCertificateResult> Invoke(GetServerCertificateInvokeArgs args, InvokeOptions? opts = null)
}public static CompletableFuture<GetServerCertificateResult> getServerCertificate(GetServerCertificateArgs args, InvokeOptions options)
public static Output<GetServerCertificateResult> getServerCertificate(GetServerCertificateArgs args, InvokeOptions options)
fn::invoke:
  function: aws:iam/getServerCertificate:getServerCertificate
  arguments:
    # arguments dictionaryThe following arguments are supported:
- Latest bool
 - sort results by expiration date. returns the certificate with expiration date in furthest in the future.
 - Name string
 - exact name of the cert to lookup
 - Name
Prefix string - prefix of cert to filter by
 - Path
Prefix string - prefix of path to filter by
 
- Latest bool
 - sort results by expiration date. returns the certificate with expiration date in furthest in the future.
 - Name string
 - exact name of the cert to lookup
 - Name
Prefix string - prefix of cert to filter by
 - Path
Prefix string - prefix of path to filter by
 
- latest Boolean
 - sort results by expiration date. returns the certificate with expiration date in furthest in the future.
 - name String
 - exact name of the cert to lookup
 - name
Prefix String - prefix of cert to filter by
 - path
Prefix String - prefix of path to filter by
 
- latest boolean
 - sort results by expiration date. returns the certificate with expiration date in furthest in the future.
 - name string
 - exact name of the cert to lookup
 - name
Prefix string - prefix of cert to filter by
 - path
Prefix string - prefix of path to filter by
 
- latest bool
 - sort results by expiration date. returns the certificate with expiration date in furthest in the future.
 - name str
 - exact name of the cert to lookup
 - name_
prefix str - prefix of cert to filter by
 - path_
prefix str - prefix of path to filter by
 
- latest Boolean
 - sort results by expiration date. returns the certificate with expiration date in furthest in the future.
 - name String
 - exact name of the cert to lookup
 - name
Prefix String - prefix of cert to filter by
 - path
Prefix String - prefix of path to filter by
 
getServerCertificate Result
The following output properties are available:
- Arn string
 - is set to the ARN of the IAM Server Certificate
 - Certificate
Body string - is the public key certificate (PEM-encoded). This is useful when configuring back-end instance authentication policy for load balancer
 - Certificate
Chain string - is the public key certificate chain (PEM-encoded) if exists, empty otherwise
 - Expiration
Date string - is set to the expiration date of the IAM Server Certificate
 - Id string
 - The provider-assigned unique ID for this managed resource.
 - Name string
 - Path string
 - is set to the path of the IAM Server Certificate
 - Upload
Date string - is the date when the server certificate was uploaded
 - Latest bool
 - Name
Prefix string - Path
Prefix string 
- Arn string
 - is set to the ARN of the IAM Server Certificate
 - Certificate
Body string - is the public key certificate (PEM-encoded). This is useful when configuring back-end instance authentication policy for load balancer
 - Certificate
Chain string - is the public key certificate chain (PEM-encoded) if exists, empty otherwise
 - Expiration
Date string - is set to the expiration date of the IAM Server Certificate
 - Id string
 - The provider-assigned unique ID for this managed resource.
 - Name string
 - Path string
 - is set to the path of the IAM Server Certificate
 - Upload
Date string - is the date when the server certificate was uploaded
 - Latest bool
 - Name
Prefix string - Path
Prefix string 
- arn String
 - is set to the ARN of the IAM Server Certificate
 - certificate
Body String - is the public key certificate (PEM-encoded). This is useful when configuring back-end instance authentication policy for load balancer
 - certificate
Chain String - is the public key certificate chain (PEM-encoded) if exists, empty otherwise
 - expiration
Date String - is set to the expiration date of the IAM Server Certificate
 - id String
 - The provider-assigned unique ID for this managed resource.
 - name String
 - path String
 - is set to the path of the IAM Server Certificate
 - upload
Date String - is the date when the server certificate was uploaded
 - latest Boolean
 - name
Prefix String - path
Prefix String 
- arn string
 - is set to the ARN of the IAM Server Certificate
 - certificate
Body string - is the public key certificate (PEM-encoded). This is useful when configuring back-end instance authentication policy for load balancer
 - certificate
Chain string - is the public key certificate chain (PEM-encoded) if exists, empty otherwise
 - expiration
Date string - is set to the expiration date of the IAM Server Certificate
 - id string
 - The provider-assigned unique ID for this managed resource.
 - name string
 - path string
 - is set to the path of the IAM Server Certificate
 - upload
Date string - is the date when the server certificate was uploaded
 - latest boolean
 - name
Prefix string - path
Prefix string 
- arn str
 - is set to the ARN of the IAM Server Certificate
 - certificate_
body str - is the public key certificate (PEM-encoded). This is useful when configuring back-end instance authentication policy for load balancer
 - certificate_
chain str - is the public key certificate chain (PEM-encoded) if exists, empty otherwise
 - expiration_
date str - is set to the expiration date of the IAM Server Certificate
 - id str
 - The provider-assigned unique ID for this managed resource.
 - name str
 - path str
 - is set to the path of the IAM Server Certificate
 - upload_
date str - is the date when the server certificate was uploaded
 - latest bool
 - name_
prefix str - path_
prefix str 
- arn String
 - is set to the ARN of the IAM Server Certificate
 - certificate
Body String - is the public key certificate (PEM-encoded). This is useful when configuring back-end instance authentication policy for load balancer
 - certificate
Chain String - is the public key certificate chain (PEM-encoded) if exists, empty otherwise
 - expiration
Date String - is set to the expiration date of the IAM Server Certificate
 - id String
 - The provider-assigned unique ID for this managed resource.
 - name String
 - path String
 - is set to the path of the IAM Server Certificate
 - upload
Date String - is the date when the server certificate was uploaded
 - latest Boolean
 - name
Prefix String - path
Prefix String 
Package Details
- Repository
 - AWS Classic pulumi/pulumi-aws
 - License
 - Apache-2.0
 - Notes
 - This Pulumi package is based on the 
awsTerraform Provider.