View a markdown version of this page

Set up and manage certificate inventory - AWS Certificate Manager

Set up and manage certificate inventory

Each organization has one inventory configuration. You create and change it with PutInventoryConfiguration and read it with GetInventoryConfiguration.

Prerequisites

Before you call PutInventoryConfiguration, check the following:

  • You've chosen an ACM plan, Essentials or Pro. You set it in your first PutInventoryConfiguration call. For more information, see ACM plans.

  • The calling account is your organization's management account or its delegated administrator for the service principal inventory.acm.amazonaws.com. Calls from any other account, or from an account that isn't in an organization, fail with AccessDeniedException, and the error message names the condition that isn't met. Only the management account can make the first call, because that call starts your plan.

  • The organization has all features turned on. For more information, see Enabling all features for an organization in the AWS Organizations User Guide.

  • Trusted access for certificate inventory is turned on in AWS Organizations for the service principal inventory.acm.amazonaws.com.

PutInventoryConfiguration doesn't check all features or trusted access. If either isn't in place, the call still succeeds, and setup stops with ProvisioningStatus set to FAILED and a reason that names the problem. Fix it, and then send the configuration again. Your plan, and its charge, start with your first call even if setup then fails, so check these prerequisites first. For more information, see Check configuration and provisioning status.

If trusted access is turned off later, certificate actions stop, and ProvisioningStatus is FAILED with reason code TRUSTED_ACCESS_DISABLED until it's turned back on. GetInventoryConfiguration, PutInventoryConfiguration, and the inventory search and list operations keep working, but member operations fail with AccessDeniedException. To stop collection and end your plan, turn off certificate inventory, as described in Turn off certificate inventory.

ACM doesn't notify you when ProvisioningStatus changes, and certificate inventory doesn't send events to Amazon EventBridge. To find out, check ProvisioningStatus and ProvisioningStatusReason in the GetInventoryConfiguration response. For more information, see Check configuration and provisioning status.

Service principals and service-linked roles

ACM uses two service principals and two service-linked roles for work across the accounts in your organization.

Service principal Service-linked role Used for

inventory.acm.amazonaws.com

AWSServiceRoleForCertificateManagerInventory

Read access to certificates in your organization's accounts. Trusted access and registering as delegated administrator use this principal.

management.acm.amazonaws.com

AWSServiceRoleForCertificateManagerOrganizationManagement

Write actions in your organization's accounts, used only when you turn on certificate actions. It has no separate entry in AWS Organizations, so you don't enable trusted access for it. For more information, see Manage certificates across your organization.

In member accounts, AWS Organizations creates the AWSServiceRoleForCertificateManagerInventory role when you enable trusted access. In the management account, the ACM console creates it during setup. If you use the API or the AWS Command Line Interface (AWS CLI), create it through IAM yourself. For more information about these roles, see Service-linked role for certificate inventory and Service-linked role for certificate actions.

Required IAM permissions

Each certificate inventory operation has its own IAM action in the acm namespace. None of these actions supports resource-level permissions, so set Resource to "*".

Action Access level

acm:GetInventoryConfiguration

Read

acm:PutInventoryConfiguration

Write

acm:SearchInventory

Read

acm:ListInventoryRelatedResources

Read

acm:ListInventoryUsages

Read

acm:ListInventoryFindings

Read

acm:GetInventoryInsights

Read

The following JSON policy grants read-only access to the inventory:

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "acm:GetInventoryConfiguration", "acm:SearchInventory", "acm:ListInventoryRelatedResources", "acm:ListInventoryUsages", "acm:ListInventoryFindings", "acm:GetInventoryInsights" ], "Resource": "*" } ] }

Even with these permissions, calls from an account other than the management account or the delegated administrator fail with AccessDeniedException. These actions also appear in ACM API permissions: Actions and resources reference.

Starting, changing, or canceling your plan also needs permissions for AWS User Subscriptions, because ACM calls it with your credentials. The principal in the management account that calls PutInventoryConfiguration needs user-subscriptions:CreateClaim to start a plan, user-subscriptions:UpdateClaim to change it, and user-subscriptions:DeleteClaim to cancel it, with Resource set to "*". Without them, the call fails with AccessDeniedException, and the message names the missing action.

The following JSON policy lets a principal in the management account manage the inventory configuration and the plan:

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "acm:GetInventoryConfiguration", "acm:PutInventoryConfiguration", "user-subscriptions:CreateClaim", "user-subscriptions:UpdateClaim", "user-subscriptions:DeleteClaim" ], "Resource": "*" } ] }

Turn on certificate inventory

To turn on collection, call PutInventoryConfiguration from the Region that you want as your home Region, and set Status to ENABLED. You must specify AccountScope, RegionalScope, and Status.

Your first call must also set InventoryTier to ESSENTIALS or PRO. That call starts your plan, so only the management account can make it. Without InventoryTier, the first call fails with ValidationException. Later calls can leave it out, and your plan stays the same.

The following members are optional:

  • DataRetentionDays: how long to keep records of expired certificates that were valid for more than 7 days, from 90 through 365 days. The default is 90. For more information, see Data retention.

  • LifecycleManagement: turns certificate actions on or off. You can turn them on in your first call. For more information, see Set up and manage certificate actions.

  • ExpiryNotification: sends notifications to an Amazon SNS topic before certificates expire. For more information, see Get notified before certificates expire.

Important

The first successful call sets your organization's home Region, and you can't change it later. Every later call must come from that Region. For more information, see Home Region.

The following JSON request body starts the Pro plan and collects from one organizational unit (OU) and one account, in every Region except us-west-2. It keeps certificates that are valid for more than 7 days for 180 days:

{ "RegionalScope": { "Mode": "EXCLUDE", "Regions": ["us-west-2"] }, "AccountScope": { "Mode": "INCLUDE", "OrganizationalUnitIds": ["ou-ab12-cd345678"], "AccountIds": ["111122223333"] }, "DataRetentionDays": 180, "InventoryTier": "PRO", "Status": "ENABLED" }

Replace ou-ab12-cd345678 and 111122223333 with your own OU and account IDs.

The response returns the configuration as stored, without InventoryTierConfiguration. To see your plan, call GetInventoryConfiguration. Right after you turn on collection, ProvisioningStatus is ENABLING. For more information, see Check configuration and provisioning status.

Choose which accounts to collect from

AccountScope sets the accounts and OUs that the inventory collects from. Its Mode also decides whether accounts that join your organization later are added automatically. The following table describes the Mode values.

Mode Collects from Accounts that join later

ALL_ACCOUNTS

Every account

Added

INCLUDE

The listed OUs, their child OUs, and the listed accounts

Added only when they land under an included OU. If you list only AccountIds, new accounts are never added.

EXCLUDE

Every account except the listed OUs, their child OUs, and the listed accounts

Added unless they land under an excluded OU

With INCLUDE or EXCLUDE, AccountIds and OrganizationalUnitIds together must have at least one entry. With ALL_ACCOUNTS, leave both lists out. AccountIds accepts up to 500 unique account IDs, and OrganizationalUnitIds accepts up to 100 unique OU IDs. The organization root ID isn't accepted as an OU, and EXCLUDE can leave out the management account.

Choose which Regions to collect from

RegionalScope sets the Regions that the inventory collects from. Set Mode to one of the following values:

ALL_REGIONS

Collects from every Region, including Regions that launch later. Leave Regions out.

INCLUDE

Collects only from the Regions listed in Regions.

EXCLUDE

Collects from every Region except those listed in Regions.

Regions accepts up to 100 unique Region codes, such as us-west-2. With INCLUDE, list only Regions where certificate inventory is available. A Region where it isn't available makes setup fail.

If you narrow RegionalScope, the inventory stops collecting from the Regions that you removed and deletes the records that it collected from them.

Check configuration and provisioning status

Call GetInventoryConfiguration to read the configuration, the organization's home Region, and the progress of any provisioning in flight. If the organization has no configuration yet, the call fails with ResourceNotFoundException.

The configuration has two status fields. Status is whether collection is on, and ProvisioningStatus is how far the service has gotten in applying your last change. After you turn off certificate inventory, Status stays ENABLED until your plan ends, and InventoryTierConfiguration.ScheduledChange shows the end date, as described in Turn off certificate inventory. The following table shows the possible ProvisioningStatus values for each Status.

Status Possible ProvisioningStatus values

ENABLED

ENABLING, ENABLED, FAILED

DISABLED

DISABLING, DISABLED, FAILED

When ProvisioningStatus is FAILED, ProvisioningStatusReason says why. Its Code is one of the following, and its Message describes the cause and what to do about it:

  • TRUSTED_ACCESS_DISABLED: trusted access for certificate inventory is turned off in AWS Organizations.

  • INTERNAL_FAILURE: setup failed. The message says what failed, which can be a problem that you can fix, such as trusted access not being turned on, or an opt-in Region in RegionalScope that isn't enabled in the management account or the delegated administrator account. In that case, the message names the account and each Region.

These codes are values in the configuration that GetInventoryConfiguration returns, not errors. The call itself succeeds.

To recover from FAILED, read Message first and fix what it names. Then call PutInventoryConfiguration again with Status set to ENABLED. After FAILED, that call starts setup again, even if your settings haven't changed. If setup keeps failing with INTERNAL_FAILURE, contact AWS Support.

Change the inventory configuration

PutInventoryConfiguration replaces the scope and status settings. If you omit DataRetentionDays, InventoryTier, LifecycleManagement, or ExpiryNotification, they keep their stored settings. To change the scope, read the current configuration with GetInventoryConfiguration and send it back with your change.

If you repeat a call with the same settings, it returns the stored configuration and changes nothing. The exception is after FAILED: the same call starts setup again.

The following rules apply when you change the configuration:

  • While ProvisioningStatus is ENABLING or DISABLING, a request that matches the stored configuration returns it unchanged. Any other request fails with ConflictException. Wait for the transition to finish, then try again.

  • If you change AccountScope or RegionalScope, ProvisioningStatus changes to ENABLING while the service applies the change, and back to ENABLED when it's done. Until then, other changes fail with ConflictException, as described in the previous item. A change to only DataRetentionDays or ExpiryNotification doesn't start this process.

  • Outside a transition, concurrent calls don't conflict with each other. The last call to arrive wins.

  • To change your plan, set InventoryTier to the plan that you want. Only the management account can change the plan. For when the change takes effect, see How plans work.

  • Narrowing RegionalScope stops collection from the Regions that you remove. For more information, see Choose which Regions to collect from.

Get notified before certificates expire

Certificate inventory can send notifications to an Amazon SNS topic about certificates across your organization that are about to expire. Notifications are separate from the Amazon EventBridge events that ACM sends in each account, and they're sent only while Status is ENABLED. After you turn off certificate inventory, notifications continue until your plan ends. To stop them sooner, set Enabled to false.

Before you turn on notifications, prepare the topic:

  1. In the management account, create or choose a standard (not FIFO) Amazon SNS topic in your home Region.

  2. Add the following statement to the topic's access policy, so that ACM can publish to the topic for your organization only. Replace the topic ARN and the account ID, 111122223333, with your own topic ARN and management account ID.

    { "Version": "2012-10-17", "Statement": [ { "Sid": "AllowACMExpiryNotifications", "Effect": "Allow", "Principal": { "Service": "inventory.acm.amazonaws.com" }, "Action": "sns:Publish", "Resource": "arn:aws:sns:us-east-1:111122223333:cert-expiry", "Condition": { "StringEquals": { "aws:SourceAccount": "111122223333" }, "ArnLike": { "aws:SourceArn": "arn:aws:acm:*:111122223333:*" } } } ] }

Then set ExpiryNotification in PutInventoryConfiguration:

  • Enabled: set to true to send notifications, or false to stop them.

  • Channel and TopicArn: required when Enabled is true. Set Channel to SNS.

  • LeadTimeDays: how many days before a certificate expires notifications start: 7, 30, 60, or 90. The default is 7.

  • Frequency: how often each certificate is notified: ONCE, DAILY, or WEEKLY. The default is ONCE.

Because the call replaces the scope settings, include your current scope. The following request body keeps the configuration from the earlier example and sends a notification each day for certificates that expire within 30 days:

{ "RegionalScope": { "Mode": "EXCLUDE", "Regions": ["us-west-2"] }, "AccountScope": { "Mode": "INCLUDE", "OrganizationalUnitIds": ["ou-ab12-cd345678"], "AccountIds": ["111122223333"] }, "Status": "ENABLED", "ExpiryNotification": { "Enabled": true, "Channel": "SNS", "TopicArn": "arn:aws:sns:us-east-1:111122223333:cert-expiry", "LeadTimeDays": 30, "Frequency": "DAILY" } }

Each time you save ExpiryNotification with Enabled set to true, ACM verifies the topic again. Nothing is delivered until verification succeeds. To follow it, read LastDeliveryStatus in the GetInventoryConfiguration response. Its status is PENDING_VERIFICATION, VERIFIED, VERIFICATION_FAILED, DELIVERED, or DELIVERY_FAILED. If the topic's access policy doesn't let ACM publish, the status is VERIFICATION_FAILED.

Each day that certificates are due, ACM sends one message for your organization. The message lists up to 100 certificates that are due to expire, with each certificate's account, Region, subject common name, serial number, issuer, expiration date, and days until expiration. If more certificates are due, the message says that the list is cut off. Don't build automation that depends on the message's exact structure, because it can change.

If you leave ExpiryNotification out of a later PutInventoryConfiguration call, it keeps its stored setting.

Turn off certificate inventory

To turn off certificate inventory and cancel your plan, call PutInventoryConfiguration with Status set to DISABLED. Only the management account can make this call. A delegated administrator that tries gets AccessDeniedException. Certificate actions turn off at once. The inventory keeps collecting, and expiry notifications continue, until your plan ends at the end of the billing period. Until then, Status stays ENABLED, and GetInventoryConfiguration shows the end date in InventoryTierConfiguration.ScheduledChange. After the plan ends, Status changes to DISABLED, and ProvisioningStatus goes through DISABLING to DISABLED while the service offboards each account in your scope. This includes deleting the AWS Config service-linked configuration recorder that it created in the account. The inventory then deletes the records that it collected.

You can't undo a cancellation. Until the plan ends, a request for the plan that's ending fails with ConflictException, but you can still choose the other plan. Turning off works even while trusted access is turned off.

Because the call replaces the scope settings, include your current scope. The following request body cancels the plan and keeps the rest of the configuration from the earlier example:

{ "RegionalScope": { "Mode": "EXCLUDE", "Regions": ["us-west-2"] }, "AccountScope": { "Mode": "INCLUDE", "OrganizationalUnitIds": ["ou-ab12-cd345678"], "AccountIds": ["111122223333"] }, "DataRetentionDays": 180, "Status": "DISABLED" }

For the complete configuration, see Turn on certificate inventory.