Use PowerShell to request a public certificate from AWS Certificate Manager

By Saad Khamis

August 1, 2024

13951 views

In this blog, I will demonstrate how to use PowerShell to request a public certificate from AWS Certificate Manager, utilizing DNS validation for verification. Additionally, I will show how to request multiple certificates within the same profile and region, as well as how to request certificates from a list saved in a CSV file.

Yo may be interested in reading List all AWS Certificate Manager certificates.

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

Introduction

In List all AWS Certificate Manager certificates, I demonstrated how to list all existing ACM certificates. You can use either ACM console or AWS CLI to request a public ACM certificate.

I needed to create multiple public certificates with DNS validation in multiple profiles and regions. To achieve this, I utilized PowerShell and “AWS Tools for PowerShell – AWS Certificate Manager”.

Note:

  1. After you create a certificate with email validation, you cannot switch to validating it with DNS. To use DNS validation, delete the certificate and then create a new one that uses DNS validation.
  2. Amazon Certificate Manager (ACM) certificate validation requests are valid for 72 hours after they are made. If the certificate is not validated within this period, the request becomes invalid, and a new certificate must be requested.

Prerequisites

To run the scripts 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-ACMCertificateDetail Returns detailed metadata about the specified ACM certificate.
  2. New-ACMCertificate Requests an ACM certificate for use with other Amazon Web Services services.

How to request a single public certificate

First, I will demonstrate how to create a single public certificate:

  1. Initialize Required Variables: Set up the necessary variables.
  2. Request Certificate: Use the New-ACMCertificate cmdlet to request a new certificate based on the input variables.
  3. Wait for Certificate Creation: Allow time for ACM to create the certificate.
  4. Monitor CNAME Information: Ensure that the CNAME information becomes available by using a “Do {} While” loop.

How to request multiple public certificates in the same profile and region

Second, I will demonstrate how to create multiple public certificates using domain names stored in a variable. I will follow the steps outlined in the previous section, but within a ForEach loop.

How to request multiple public certificates in multiple profiles and regions

Finally, I will use a CSV file to create multiple public certificates across various profiles and regions. The file should include, at a minimum, the profile name, region name, and domain name.

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 demonstrate how to request a public certificate from AWS Certificate Manager using PowerShell, utilizing DNS validation for verification. Additionally, I showed how to request multiple certificates within the same profile and region, as well as how to request certificates from a list saved in a CSV file.

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

List all AWS Certificate Manager certificates

By Saad Khamis 14079 views July 31, 2024

Get all AWS EBS snapshots across all profiles and regions

By Saad Khamis 18437 views June 26, 2024

Get all AWS EC2 instances across all profiles and regions

By Saad Khamis 33190 views November 27, 2023