Skip to content
GitHubXDiscordRSS

ServerCertificate

Learn how to create, update, and manage AWS IAM ServerCertificates using Alchemy Cloud Control.

The ServerCertificate resource lets you manage AWS IAM ServerCertificates for securely managing SSL/TLS certificates for your AWS resources.

Create a basic server certificate with the required properties and a common optional property.

import AWS from "alchemy/aws/control";
const serverCertificate = await AWS.IAM.ServerCertificate("myServerCertificate", {
ServerCertificateName: "my-website-cert",
CertificateBody: "-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----",
PrivateKey: "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----"
});

Configure a server certificate with an optional certificate chain and tagging.

const advancedServerCertificate = await AWS.IAM.ServerCertificate("advancedServerCertificate", {
ServerCertificateName: "my-advanced-website-cert",
CertificateBody: "-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----",
PrivateKey: "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----",
CertificateChain: "-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----",
Tags: [
{ Key: "Environment", Value: "Production" },
{ Key: "Department", Value: "IT" }
]
});

If you have an existing server certificate, you can adopt it using the adopt property.

const existingServerCertificate = await AWS.IAM.ServerCertificate("existingServerCertificate", {
ServerCertificateName: "existing-cert-name",
adopt: true // This will adopt the existing resource instead of failing
});

You can update an existing server certificate with new properties like the certificate body or tags.

const updatedServerCertificate = await AWS.IAM.ServerCertificate("updateServerCertificate", {
ServerCertificateName: "my-website-cert",
CertificateBody: "-----BEGIN NEW CERTIFICATE-----\n...\n-----END NEW CERTIFICATE-----",
Tags: [
{ Key: "Environment", Value: "Staging" }
]
});