List all AWS Certificate Manager certificates

By Saad Khamis

July 31, 2024

14090 views

In this blog, I will share a PowerShell script to list all AWS Certificate Manager (ACM) certificates across all profiles and regions. This script will include details such as the certificate domain, type, expiration date, and associated resources (InUseBy). You can choose to display the results, export them to a file, or both.

Explore my other articles about AWS services and Microsoft Azure services.

Introduction

Use AWS Certificate Manager (ACM) to provision, manage, and deploy public and private SSL/TLS certificates for AWS services and your internal connected resources.

I needed a comprehensive list of all AWS Certificate Manager (ACM) certificates managed by ACM, including details such as the certificate domain, type, expiration date, associated resource (InUseBy), and other properties. I will use this list to determine which certificates to delete, keep, or renew. To achieve this, I utilized PowerShell and “AWS Tools for PowerShell – AWS Certificate Manager”.

Prerequisites

To execute the script provided in this blog, you need to:

  1. Install and configure AWS Tools for PowerShell.
  2. Log in to all necessary AWS accounts and profiles.
  3. Configure your IAM permissions to allow required access to AWS Certificate Manager (ACM) certificates.

PowerShell Cmdlets

Here are the PowerShell cmdlets we will use.

  1. Get-ACCTRegionList Lists all the Regions for a given account and their respective opt-in statuses.
  2. Get-ACMCertificateDetail Returns detailed metadata about the specified ACM certificate.
  3. Get-ACMCertificateList Retrieves a list of certificate ARNs and domain names.
  4. Get-AWSCredential Returns an AWSCredentials object initialized from either credentials currently set as default in the shell or saved and associated with the supplied name from the local credential store.

Retrieve metadata about a specified ACM certificate

First, we will begin by using the Get-ACMCertificateDetail cmdlet to retrieve metadata about a specific ACM certificate.

Compile requested EBS snapshot information

Second, let’s compile the required information. Note that the “-join” operator concatenates a set of strings into a single string.

Compile requested ACM certificates information within a single profile and region

Third, let’s compile the required information for a single profile and region.

Compile requested ACM certificates information within a single profile

Third, let’s compile the required information for a single profile and all enabled regions within the profile

Compile requested ACM certificates information across all profiles and regions

Finally, let’s compile the required information across all profiles and regions.

Conclusion

Congratulations on reaching the end of this blog! You’ve successfully navigated through some potentially challenging and lengthy code. Well done!

In this blog, I used PowerShell and AWS Tools for PowerShell to create a script that retrieves all AWS ACM certificates across all profiles and regions. This information will help determine which certificates to delete, keep, or renew.

Did you find this blog easy to follow and helpful? I would love to hear your feedback and suggestions, so please share them in the comments below.

Disclaimer

Purpose of the code contained in blog is solely for learning and demo purposes. Author will not be held responsible for any failure or damages caused due to any other usage.

Comments

There's no comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts

Get all AWS EBS snapshots across all profiles and regions

By Saad Khamis 18448 views June 26, 2024

Get all AWS EC2 instances across all profiles and regions

By Saad Khamis 33195 views November 27, 2023