ServerCertificate class
Provides an IAM Server Certificate resource to upload Server Certificates. Certs uploaded to IAM can easily work with other AWS services such as:
- AWS Elastic Beanstalk
- Elastic Load Balancing
- CloudFront
- AWS OpsWorks
For information about server certificates in IAM, see Managing Server Certificates in AWS Documentation.
Example Usage
Using certs on file:
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
import * as std from "@pulumi/std";
const testCert = new aws.iam.ServerCertificate("test_cert", {
name: "some_test_cert",
certificateBody: std.file({
input: "self-ca-cert.pem",
}).then(invoke => invoke.result),
privateKey: std.file({
input: "test-key.pem",
}).then(invoke => invoke.result),
});
import pulumi
import pulumi_aws as aws
import pulumi_std as std
test_cert = aws.iam.ServerCertificate("test_cert",
name="some_test_cert",
certificate_body=std.file(input="self-ca-cert.pem").result,
private_key=std.file(input="test-key.pem").result)
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
using Std = Pulumi.Std;
return await Deployment.RunAsync(() =>
{
var testCert = new Aws.Iam.ServerCertificate("test_cert", new()
{
Name = "some_test_cert",
CertificateBody = Std.File.Invoke(new()
{
Input = "self-ca-cert.pem",
}).Apply(invoke => invoke.Result),
PrivateKey = Std.File.Invoke(new()
{
Input = "test-key.pem",
}).Apply(invoke => invoke.Result),
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/iam"
"github.com/pulumi/pulumi-std/sdk/go/std"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
invokeFile, err := std.File(ctx, &std.FileArgs{
Input: "self-ca-cert.pem",
}, nil)
if err != nil {
return err
}
invokeFile1, err := std.File(ctx, &std.FileArgs{
Input: "test-key.pem",
}, nil)
if err != nil {
return err
}
_, err = iam.NewServerCertificate(ctx, "test_cert", &iam.ServerCertificateArgs{
Name: pulumi.String("some_test_cert"),
CertificateBody: pulumi.String(invokeFile.Result),
PrivateKey: pulumi.String(invokeFile1.Result),
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
aws = {
source = "pulumi/aws"
}
std = {
source = "pulumi/std"
}
}
}
resource "aws_iam_servercertificate" "test_cert" {
name = "some_test_cert"
certificate_body = file("self-ca-cert.pem")
private_key = file("test-key.pem")
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.iam.ServerCertificate;
import com.pulumi.aws.iam.ServerCertificateArgs;
import com.pulumi.std.StdFunctions;
import com.pulumi.std.inputs.FileArgs;
import java.util.ArrayList;
import java.util.Arrays;
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) {
var testCert = new ServerCertificate("testCert", ServerCertificateArgs.builder()
.name("some_test_cert")
.certificateBody(StdFunctions.file(FileArgs.builder()
.input("self-ca-cert.pem")
.build()).result())
.privateKey(StdFunctions.file(FileArgs.builder()
.input("test-key.pem")
.build()).result())
.build());
}
}
resources:
testCert:
type: aws:iam:ServerCertificate
name: test_cert
properties:
name: some_test_cert
certificateBody:
fn::invoke:
function: std:file
arguments:
input: self-ca-cert.pem
return: result
privateKey:
fn::invoke:
function: std:file
arguments:
input: test-key.pem
return: result
Example with cert in-line:
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const testCertAlt = new aws.iam.ServerCertificate("test_cert_alt", {
name: "alt_test_cert",
certificateBody: `-----BEGIN CERTIFICATE-----
[......] # cert contents
-----END CERTIFICATE-----
`,
privateKey: `-----BEGIN RSA PRIVATE KEY-----
[......] # cert contents
-----END RSA PRIVATE KEY-----
`,
});
import pulumi
import pulumi_aws as aws
test_cert_alt = aws.iam.ServerCertificate("test_cert_alt",
name="alt_test_cert",
certificate_body="""-----BEGIN CERTIFICATE-----
[......] # cert contents
-----END CERTIFICATE-----
""",
private_key="""-----BEGIN RSA PRIVATE KEY-----
[......] # cert contents
-----END RSA PRIVATE KEY-----
""")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var testCertAlt = new Aws.Iam.ServerCertificate("test_cert_alt", new()
{
Name = "alt_test_cert",
CertificateBody = @"-----BEGIN CERTIFICATE-----
[......] # cert contents
-----END CERTIFICATE-----
",
PrivateKey = @"-----BEGIN RSA PRIVATE KEY-----
[......] # cert contents
-----END RSA PRIVATE KEY-----
",
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/iam"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := iam.NewServerCertificate(ctx, "test_cert_alt", &iam.ServerCertificateArgs{
Name: pulumi.String("alt_test_cert"),
CertificateBody: pulumi.String("-----BEGIN CERTIFICATE-----\n[......] # cert contents\n-----END CERTIFICATE-----\n"),
PrivateKey: pulumi.String("-----BEGIN RSA PRIVATE KEY-----\n[......] # cert contents\n-----END RSA PRIVATE KEY-----\n"),
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
aws = {
source = "pulumi/aws"
}
}
}
resource "aws_iam_servercertificate" "test_cert_alt" {
name = "alt_test_cert"
certificate_body = "-----BEGIN CERTIFICATE-----\n[......] # cert contents\n-----END CERTIFICATE-----\n"
private_key = "-----BEGIN RSA PRIVATE KEY-----\n[......] # cert contents\n-----END RSA PRIVATE KEY-----\n"
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.iam.ServerCertificate;
import com.pulumi.aws.iam.ServerCertificateArgs;
import java.util.ArrayList;
import java.util.Arrays;
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) {
var testCertAlt = new ServerCertificate("testCertAlt", ServerCertificateArgs.builder()
.name("alt_test_cert")
.certificateBody("""
-----BEGIN CERTIFICATE-----
[......] # cert contents
-----END CERTIFICATE-----
""")
.privateKey("""
-----BEGIN RSA PRIVATE KEY-----
[......] # cert contents
-----END RSA PRIVATE KEY-----
""")
.build());
}
}
resources:
testCertAlt:
type: aws:iam:ServerCertificate
name: test_cert_alt
properties:
name: alt_test_cert
certificateBody: |
-----BEGIN CERTIFICATE-----
[......] # cert contents
-----END CERTIFICATE-----
privateKey: |
-----BEGIN RSA PRIVATE KEY-----
[......] # cert contents
-----END RSA PRIVATE KEY-----
Use in combination with an AWS ELB resource:
Some properties of an IAM Server Certificates cannot be updated while they are
in use. In order for the provider to effectively manage a Certificate in this situation, it is
recommended you utilize the namePrefix attribute and enable the
createBeforeDestroy lifecycle block. This will allow Pulumi
to create a new, updated aws.iam.ServerCertificate resource and replace it in
dependant resources before attempting to destroy the old version.
Import
Using pulumi import, import IAM Server Certificates using the name. For example:
$ pulumi import aws:iam/serverCertificate:ServerCertificate certificate example.com-certificate-until-2018
Constructors
- ServerCertificate(String name, {ServerCertificateArgs? args, CustomResourceOptions? options})
-
Creates a new ServerCertificate.
nameThe Pulumi resource name.argsArguments used to configure this ServerCertificate. The set of arguments for ServerCertificate.optionsResource options controlling this resource's behavior. - ServerCertificate.reference(String urn)
- Creates a typed reference to an existing ServerCertificate resource.
Properties
-
arn
↔ Output<
String> -
ARN specifying the server certificate.
latefinal
-
certificateBody
↔ Output<
String> -
The contents of the public key certificate in
PEM-encoded format.
latefinal
-
certificateChain
↔ Output<
String?> -
The contents of the certificate chain.
This is typically a concatenation of the PEM-encoded public key certificates
of the chain.
latefinal
-
childResources
→ Set<
Resource> -
finalinherited
-
completionSources
↔ Map<
String, IOutputCompletionSource> -
latefinalinherited
-
expiration
↔ Output<
String> -
Date and time in RFC3339 format on which the certificate is set to expire.
latefinal
- hashCode → int
-
The hash code for this object.
no setterinherited
-
id
↔ Output<
String> -
getter/setter pairinherited
- isCustom → bool
-
Returns whether this resource is provider-managed.
no setterinherited
- isProtected → bool
-
Returns whether this resource is protected from deletion.
no setterinherited
- isRemote → bool
-
Whether this resource is registered as remote.
no setterinherited
- isResourceReference → bool
-
Whether this instance represents a resource value returned over RPC.
finalinherited
-
name
↔ Output<
String> -
The name of the Server Certificate. Do not include the path in this value. If omitted, the provider will assign a random, unique name.
latefinal
-
namePrefix
↔ Output<
String> -
Creates a unique name beginning with the specified
prefix. Conflicts with
name.latefinal -
path
↔ Output<
String?> -
The IAM path for the server certificate. If it is not
included, it defaults to a slash (/). If this certificate is for use with
AWS CloudFront, the path must be in format
/cloudfront/your_path_here. See IAM Identifiers for more details on IAM Paths.latefinal -
privateKey
↔ Output<
String> -
The contents of the private key in PEM-encoded format.
latefinal
-
resourceTransforms
→ List<
ResourceTransform> -
Inherited/explicit async transforms.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
Map of resource tags for the server certificate. If configured with a provider
defaultTagsconfiguration block present, tags with matching keys will overwrite those defined at the provider-level.latefinal -
A map of tags assigned to the resource, including those inherited from the provider
defaultTagsconfiguration block.latefinal -
transformations
→ List<
ResourceTransformation> -
Inherited/explicit legacy transformations.
no setterinherited
-
uploadDate
↔ Output<
String> -
Date and time in RFC3339 format when the server certificate was uploaded.
latefinal
-
urn
↔ Output<
String> -
latefinalinherited
Methods
-
failId(
Object error) → void -
Completes this resource ID with an error when registration fails.
inherited
-
failOutputs(
Object error) → void -
Completes all output properties with
error.inherited -
failUrn(
Object error) → void -
Completes this resource URN with an error when registration fails.
inherited
-
getProvider(
String moduleMember) → ProviderResource? -
Returns provider for
moduleMember's package, if configured.inherited -
getResourceName(
) → String -
Returns this resource's logical name.
inherited
-
getResourceType(
) → String -
Returns this resource's Pulumi type token.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerOutput<
T> (String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output< T> -
Registers a dynamic output property for this resource.
inherited
-
resolveId(
String? value, {required bool isKnown}) → void -
Resolves the provider-assigned ID for this resource.
inherited
-
resolveOutputs(
Struct outputs) → void -
Resolves all output properties from a monitor response payload.
inherited
-
resolveUrn(
String value) → void -
Resolves this resource's URN once assigned by the engine.
inherited
-
serializeProperties(
Map< String, dynamic> properties) → Future<Struct> -
Serializes resource properties for RPC transmission.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
get(
String name, Input< String> id, {ServerCertificateState? state, CustomResourceOptions? options}) → ServerCertificate -
Gets an existing ServerCertificate resource's state with the given
nameandid.