AWS SDK for Ruby
Developer Guide

Working with IAM Server Certificates

To enable HTTPS connections to your website or application on AWS, you need an SSL/TLS server certificate. To use a certificate that you obtained from an external provider with your website or application on AWS, you must upload the certificate to IAM or import it into AWS Certificate Manager. For more information about server certificates, see Working with Server Certificates.

In this example, you use the AWS SDK for Ruby with IAM to:

  1. Update a server certificate, using Aws::IAM::Client#update_server_certificate.

  2. Delete the server certificate, using Aws::IAM::Client#delete_server_certificate.

  3. List information about any remaining server certificates, using Aws::IAM::Client#list_server_certificates.

Prerequisites

Before running the example code, you need to install and configure the AWS SDK for Ruby, as described in:

Note

The server certificate must already exist, or the script will throw an Aws::IAM::Errors::NoSuchEntity error.

Example

require 'aws-sdk-iam' # v2: require 'aws-sdk' iam = Aws::IAM::Client.new(region: 'us-east-1') server_certificate_name = "my-server-certificate" changed_server_certificate_name = "my-changed-server-certificate" # Update a server certificate. iam.update_server_certificate({ server_certificate_name: server_certificate_name, new_server_certificate_name: changed_server_certificate_name }) # Delete the server certificate. iam.delete_server_certificate({ server_certificate_name: changed_server_certificate_name }) # List information about any remaining server certificates. list_server_certificates_response = iam.list_server_certificates if list_server_certificates_response.server_certificate_metadata_list.count == 0 puts "No server certificates." else list_server_certificates_response.server_certificate_metadata_list.each do |certificate_metadata| puts "-" * certificate_metadata.server_certificate_name.length puts "Name: #{certificate_metadata.server_certificate_name}" get_server_certificate_response = iam.get_server_certificate({ server_certificate_name: "certificate_metadata.server_certificate_name" }) puts "ID: #{get_server_certificate_response.server_certificate.server_certificate_metadata.server_certificate_id}" end end

On this page: