Client — AWS SDK for Ruby V3 (original) (raw)

Class: Aws::ACMPCA::Client

Overview

An API client for ACMPCA. To construct a client, you need to configure a :region and :credentials.

client = Aws::ACMPCA::Client.new(
  region: region_name,
  credentials: credentials,
  # ...
)

For details on configuring region and credentials see the developer guide.

See #initialize for a full list of supported configuration options.

Instance Attribute Summary

Attributes inherited from Seahorse::Client::Base

#config, #handlers

API Operationscollapse

Instance Method Summarycollapse

Methods included from ClientStubs

#api_requests, #stub_data, #stub_responses

Methods inherited from Seahorse::Client::Base

add_plugin, api, clear_plugins, define, new, #operation_names, plugins, remove_plugin, set_api, set_plugins

Methods included from Seahorse::Client::HandlerBuilder

#handle, #handle_request, #handle_response

Constructor Details

#initialize(options) ⇒ Client

Returns a new instance of Client.

473 474 475 # File 'gems/aws-sdk-acmpca/lib/aws-sdk-acmpca/client.rb', line 473 def initialize(*args) super end

Instance Method Details

Creates a root or subordinate private certificate authority (CA). You must specify the CA configuration, an optional configuration for Online Certificate Status Protocol (OCSP) and/or a certificate revocation list (CRL), the CA type, and an optional idempotency token to avoid accidental creation of multiple CAs. The CA configuration specifies the name of the algorithm and key size to be used to create the CA private key, the type of signing algorithm that the CA uses, and X.500 subject information. The OCSP configuration can optionally specify a custom URL for the OCSP responder. The CRL configuration specifies the CRL expiration period in days (the validity period of the CRL), the Amazon S3 bucket that will contain the CRL, and a CNAME alias for the S3 bucket that is included in certificates issued by the CA. If successful, this action returns the Amazon Resource Name (ARN) of the CA.

Both Amazon Web Services Private CA and the IAM principal must have permission to write to the S3 bucket that you specify. If the IAM principal making the call does not have permission to write to the bucket, then an exception is thrown. For more information, see Access policies for CRLs in Amazon S3.

Amazon Web Services Private CA assets that are stored in Amazon S3 can be protected with encryption. For more information, see Encrypting Your CRLs.

732 733 734 735 # File 'gems/aws-sdk-acmpca/lib/aws-sdk-acmpca/client.rb', line 732 def create_certificate_authority(params = {}, options = {}) req = build_request(:create_certificate_authority, params) req.send_request(options) end

#create_certificate_authority_audit_report(params = {}) ⇒ Types::CreateCertificateAuthorityAuditReportResponse

Creates an audit report that lists every time that your CA private key is used to issue a certificate. The IssueCertificate andRevokeCertificate actions use the private key.

To save the audit report to your designated Amazon S3 bucket, you must create a bucket policy that grants Amazon Web Services Private CA permission to access and write to it. For an example policy, seePrepare an Amazon S3 bucket for audit reports.

Amazon Web Services Private CA assets that are stored in Amazon S3 can be protected with encryption. For more information, see Encrypting Your Audit Reports.

You can generate a maximum of one report every 30 minutes.

797 798 799 800 # File 'gems/aws-sdk-acmpca/lib/aws-sdk-acmpca/client.rb', line 797 def create_certificate_authority_audit_report(params = {}, options = {}) req = build_request(:create_certificate_authority_audit_report, params) req.send_request(options) end

#create_permission(params = {}) ⇒ Struct

Grants one or more permissions on a private CA to the Certificate Manager (ACM) service principal (acm.amazonaws.com). These permissions allow ACM to issue and renew ACM certificates that reside in the same Amazon Web Services account as the CA.

You can list current permissions with the ListPermissions action and revoke them with the DeletePermission action.

About Permissions

873 874 875 876 # File 'gems/aws-sdk-acmpca/lib/aws-sdk-acmpca/client.rb', line 873 def create_permission(params = {}, options = {}) req = build_request(:create_permission, params) req.send_request(options) end

#delete_certificate_authority(params = {}) ⇒ Struct

Deletes a private certificate authority (CA). You must provide the Amazon Resource Name (ARN) of the private CA that you want to delete. You can find the ARN by calling the ListCertificateAuthoritiesaction.

Deleting a CA will invalidate other CAs and certificates below it in your CA hierarchy.

Before you can delete a CA that you have created and activated, you must disable it. To do this, call the UpdateCertificateAuthorityaction and set the CertificateAuthorityStatus parameter toDISABLED.

Additionally, you can delete a CA if you are waiting for it to be created (that is, the status of the CA is CREATING). You can also delete it if the CA has been created but you haven't yet imported the signed certificate into Amazon Web Services Private CA (that is, the status of the CA is PENDING_CERTIFICATE).

When you successfully call DeleteCertificateAuthority, the CA's status changes to DELETED. However, the CA won't be permanently deleted until the restoration period has passed. By default, if you do not set the PermanentDeletionTimeInDays parameter, the CA remains restorable for 30 days. You can set the parameter from 7 to 30 days. The DescribeCertificateAuthority action returns the time remaining in the restoration window of a private CA in the DELETEDstate. To restore an eligible CA, call theRestoreCertificateAuthority action.

945 946 947 948 # File 'gems/aws-sdk-acmpca/lib/aws-sdk-acmpca/client.rb', line 945 def delete_certificate_authority(params = {}, options = {}) req = build_request(:delete_certificate_authority, params) req.send_request(options) end

#delete_permission(params = {}) ⇒ Struct

Revokes permissions on a private CA granted to the Certificate Manager (ACM) service principal (acm.amazonaws.com).

These permissions allow ACM to issue and renew ACM certificates that reside in the same Amazon Web Services account as the CA. If you revoke these permissions, ACM will no longer renew the affected certificates automatically.

Permissions can be granted with the CreatePermission action and listed with the ListPermissions action.

About Permissions

1019 1020 1021 1022 # File 'gems/aws-sdk-acmpca/lib/aws-sdk-acmpca/client.rb', line 1019 def delete_permission(params = {}, options = {}) req = build_request(:delete_permission, params) req.send_request(options) end

#delete_policy(params = {}) ⇒ Struct

Deletes the resource-based policy attached to a private CA. Deletion will remove any access that the policy has granted. If there is no policy attached to the private CA, this action will return successful.

If you delete a policy that was applied through Amazon Web Services Resource Access Manager (RAM), the CA will be removed from all shares in which it was included.

The Certificate Manager Service Linked Role that the policy supports is not affected when you delete the policy.

The current policy can be shown with GetPolicy and updated withPutPolicy.

About Policies

1090 1091 1092 1093 # File 'gems/aws-sdk-acmpca/lib/aws-sdk-acmpca/client.rb', line 1090 def delete_policy(params = {}, options = {}) req = build_request(:delete_policy, params) req.send_request(options) end

#describe_certificate_authority(params = {}) ⇒ Types::DescribeCertificateAuthorityResponse

Lists information about your private certificate authority (CA) or one that has been shared with you. You specify the private CA on input by its ARN (Amazon Resource Name). The output contains the status of your CA. This can be any of the following:

1231 1232 1233 1234 # File 'gems/aws-sdk-acmpca/lib/aws-sdk-acmpca/client.rb', line 1231 def describe_certificate_authority(params = {}, options = {}) req = build_request(:describe_certificate_authority, params) req.send_request(options) end

#describe_certificate_authority_audit_report(params = {}) ⇒ Types::DescribeCertificateAuthorityAuditReportResponse

Lists information about a specific audit report created by calling theCreateCertificateAuthorityAuditReport action. Audit information is created every time the certificate authority (CA) private key is used. The private key is used when you call the IssueCertificateaction or the RevokeCertificate action.

The following waiters are defined for this operation (see #wait_until for detailed usage):

1293 1294 1295 1296 # File 'gems/aws-sdk-acmpca/lib/aws-sdk-acmpca/client.rb', line 1293 def describe_certificate_authority_audit_report(params = {}, options = {}) req = build_request(:describe_certificate_authority_audit_report, params) req.send_request(options) end

#get_certificate(params = {}) ⇒ Types::GetCertificateResponse

Retrieves a certificate from your private CA or one that has been shared with you. The ARN of the certificate is returned when you call the IssueCertificate action. You must specify both the ARN of your private CA and the ARN of the issued certificate when calling theGetCertificate action. You can retrieve the certificate if it is in the ISSUED state. You can call theCreateCertificateAuthorityAuditReport action to create a report that contains information about all of the certificates issued and revoked by your private CA.

The following waiters are defined for this operation (see #wait_until for detailed usage):

1357 1358 1359 1360 # File 'gems/aws-sdk-acmpca/lib/aws-sdk-acmpca/client.rb', line 1357 def get_certificate(params = {}, options = {}) req = build_request(:get_certificate, params) req.send_request(options) end

#get_certificate_authority_certificate(params = {}) ⇒ Types::GetCertificateAuthorityCertificateResponse

Retrieves the certificate and certificate chain for your private certificate authority (CA) or one that has been shared with you. Both the certificate and the chain are base64 PEM-encoded. The chain does not include the CA certificate. Each certificate in the chain signs the one before it.

1395 1396 1397 1398 # File 'gems/aws-sdk-acmpca/lib/aws-sdk-acmpca/client.rb', line 1395 def get_certificate_authority_certificate(params = {}, options = {}) req = build_request(:get_certificate_authority_certificate, params) req.send_request(options) end

#get_certificate_authority_csr(params = {}) ⇒ Types::GetCertificateAuthorityCsrResponse

Retrieves the certificate signing request (CSR) for your private certificate authority (CA). The CSR is created when you call theCreateCertificateAuthority action. Sign the CSR with your Amazon Web Services Private CA-hosted or on-premises root or subordinate CA. Then import the signed certificate back into Amazon Web Services Private CA by calling the ImportCertificateAuthorityCertificateaction. The CSR is returned as a base64 PEM-encoded string.

The following waiters are defined for this operation (see #wait_until for detailed usage):

1447 1448 1449 1450 # File 'gems/aws-sdk-acmpca/lib/aws-sdk-acmpca/client.rb', line 1447 def get_certificate_authority_csr(params = {}, options = {}) req = build_request(:get_certificate_authority_csr, params) req.send_request(options) end

#get_policy(params = {}) ⇒ Types::GetPolicyResponse

Retrieves the resource-based policy attached to a private CA. If either the private CA resource or the policy cannot be found, this action returns a ResourceNotFoundException.

The policy can be attached or updated with PutPolicy and removed with DeletePolicy.

About Policies

1511 1512 1513 1514 # File 'gems/aws-sdk-acmpca/lib/aws-sdk-acmpca/client.rb', line 1511 def get_policy(params = {}, options = {}) req = build_request(:get_policy, params) req.send_request(options) end

#import_certificate_authority_certificate(params = {}) ⇒ Struct

Imports a signed private CA certificate into Amazon Web Services Private CA. This action is used when you are using a chain of trust whose root is located outside Amazon Web Services Private CA. Before you can call this action, the following preparations must in place:

  1. In Amazon Web Services Private CA, call theCreateCertificateAuthority action to create the private CA that you plan to back with the imported certificate.
  2. Call the GetCertificateAuthorityCsr action to generate a certificate signing request (CSR).
  3. Sign the CSR using a root or intermediate CA hosted by either an on-premises PKI hierarchy or by a commercial CA.
  4. Create a certificate chain and copy the signed certificate and the certificate chain to your working directory.

Amazon Web Services Private CA supports three scenarios for installing a CA certificate:

The following additional requirements apply when you import a CA certificate.

Enforcement of Critical Constraints

Amazon Web Services Private CA allows the following extensions to be marked critical in the imported CA certificate or chain.

Amazon Web Services Private CA rejects the following extensions when they are marked critical in an imported CA certificate or chain.

Amazon Web Services Private Certificate Authority will also reject any other extension marked as critical not contained on the preceding list of allowed extensions.

1658 1659 1660 1661 # File 'gems/aws-sdk-acmpca/lib/aws-sdk-acmpca/client.rb', line 1658 def import_certificate_authority_certificate(params = {}, options = {}) req = build_request(:import_certificate_authority_certificate, params) req.send_request(options) end

#issue_certificate(params = {}) ⇒ Types::IssueCertificateResponse

Uses your private certificate authority (CA), or one that has been shared with you, to issue a client certificate. This action returns the Amazon Resource Name (ARN) of the certificate. You can retrieve the certificate by calling the GetCertificate action and specifying the ARN.

You cannot use the ACM ListCertificateAuthorities action to retrieve the ARNs of the certificates that you issue by using Amazon Web Services Private CA.

1946 1947 1948 1949 # File 'gems/aws-sdk-acmpca/lib/aws-sdk-acmpca/client.rb', line 1946 def issue_certificate(params = {}, options = {}) req = build_request(:issue_certificate, params) req.send_request(options) end

#list_certificate_authorities(params = {}) ⇒ Types::ListCertificateAuthoritiesResponse

2082 2083 2084 2085 # File 'gems/aws-sdk-acmpca/lib/aws-sdk-acmpca/client.rb', line 2082 def list_certificate_authorities(params = {}, options = {}) req = build_request(:list_certificate_authorities, params) req.send_request(options) end

#list_permissions(params = {}) ⇒ Types::ListPermissionsResponse

List all permissions on a private CA, if any, granted to the Certificate Manager (ACM) service principal (acm.amazonaws.com).

These permissions allow ACM to issue and renew ACM certificates that reside in the same Amazon Web Services account as the CA.

Permissions can be granted with the CreatePermission action and revoked with the DeletePermission action.

About Permissions

The returned response is a pageable response and is Enumerable. For details on usage see PageableResponse.

2174 2175 2176 2177 # File 'gems/aws-sdk-acmpca/lib/aws-sdk-acmpca/client.rb', line 2174 def list_permissions(params = {}, options = {}) req = build_request(:list_permissions, params) req.send_request(options) end

#list_tags(params = {}) ⇒ Types::ListTagsResponse

Lists the tags, if any, that are associated with your private CA or one that has been shared with you. Tags are labels that you can use to identify and organize your CAs. Each tag consists of a key and an optional value. Call the TagCertificateAuthority action to add one or more tags to your CA. Call the UntagCertificateAuthorityaction to remove tags.

The returned response is a pageable response and is Enumerable. For details on usage see PageableResponse.

2240 2241 2242 2243 # File 'gems/aws-sdk-acmpca/lib/aws-sdk-acmpca/client.rb', line 2240 def list_tags(params = {}, options = {}) req = build_request(:list_tags, params) req.send_request(options) end

#put_policy(params = {}) ⇒ Struct

Attaches a resource-based policy to a private CA.

A policy can also be applied by sharing a private CA through Amazon Web Services Resource Access Manager (RAM). For more information, seeAttach a Policy for Cross-Account Access.

The policy can be displayed with GetPolicy and removed withDeletePolicy.

About Policies

2319 2320 2321 2322 # File 'gems/aws-sdk-acmpca/lib/aws-sdk-acmpca/client.rb', line 2319 def put_policy(params = {}, options = {}) req = build_request(:put_policy, params) req.send_request(options) end

#restore_certificate_authority(params = {}) ⇒ Struct

Restores a certificate authority (CA) that is in the DELETED state. You can restore a CA during the period that you defined in thePermanentDeletionTimeInDays parameter of theDeleteCertificateAuthority action. Currently, you can specify 7 to 30 days. If you did not specify a PermanentDeletionTimeInDaysvalue, by default you can restore the CA at any time in a 30 day period. You can check the time remaining in the restoration period of a private CA in the DELETED state by calling theDescribeCertificateAuthority or ListCertificateAuthoritiesactions. The status of a restored CA is set to its pre-deletion status when the RestoreCertificateAuthority action returns. To change its status to ACTIVE, call the UpdateCertificateAuthority action. If the private CA was in the PENDING_CERTIFICATE state at deletion, you must use the ImportCertificateAuthorityCertificate action to import a certificate authority into the private CA before it can be activated. You cannot restore a CA after the restoration period has ended.

2373 2374 2375 2376 # File 'gems/aws-sdk-acmpca/lib/aws-sdk-acmpca/client.rb', line 2373 def restore_certificate_authority(params = {}, options = {}) req = build_request(:restore_certificate_authority, params) req.send_request(options) end

#revoke_certificate(params = {}) ⇒ Struct

Revokes a certificate that was issued inside Amazon Web Services Private CA. If you enable a certificate revocation list (CRL) when you create or update your private CA, information about the revoked certificates will be included in the CRL. Amazon Web Services Private CA writes the CRL to an S3 bucket that you specify. A CRL is typically updated approximately 30 minutes after a certificate is revoked. If for any reason the CRL update fails, Amazon Web Services Private CA attempts makes further attempts every 15 minutes. With Amazon CloudWatch, you can create alarms for the metrics CRLGenerated andMisconfiguredCRLBucket. For more information, see Supported CloudWatch Metrics.

Both Amazon Web Services Private CA and the IAM principal must have permission to write to the S3 bucket that you specify. If the IAM principal making the call does not have permission to write to the bucket, then an exception is thrown. For more information, see Access policies for CRLs in Amazon S3.

Amazon Web Services Private CA also writes revocation information to the audit report. For more information, seeCreateCertificateAuthorityAuditReport.

You cannot revoke a root CA self-signed certificate.

2456 2457 2458 2459 # File 'gems/aws-sdk-acmpca/lib/aws-sdk-acmpca/client.rb', line 2456 def revoke_certificate(params = {}, options = {}) req = build_request(:revoke_certificate, params) req.send_request(options) end

#tag_certificate_authority(params = {}) ⇒ Struct

Adds one or more tags to your private CA. Tags are labels that you can use to identify and organize your Amazon Web Services resources. Each tag consists of a key and an optional value. You specify the private CA on input by its Amazon Resource Name (ARN). You specify the tag by using a key-value pair. You can apply a tag to just one private CA if you want to identify a specific characteristic of that CA, or you can apply the same tag to multiple private CAs if you want to filter for a common relationship among those CAs. To remove one or more tags, use the UntagCertificateAuthority action. Call the ListTagsaction to see what tags are associated with your CA.

To attach tags to a private CA during the creation procedure, a CA administrator must first associate an inline IAM policy with theCreateCertificateAuthority action and explicitly allow tagging. For more information, see Attaching tags to a CA at the time of creation.

2518 2519 2520 2521 # File 'gems/aws-sdk-acmpca/lib/aws-sdk-acmpca/client.rb', line 2518 def tag_certificate_authority(params = {}, options = {}) req = build_request(:tag_certificate_authority, params) req.send_request(options) end

#untag_certificate_authority(params = {}) ⇒ Struct

Remove one or more tags from your private CA. A tag consists of a key-value pair. If you do not specify the value portion of the tag when calling this action, the tag will be removed regardless of value. If you specify a value, the tag is removed only if it is associated with the specified value. To add tags to a private CA, use theTagCertificateAuthority. Call the ListTags action to see what tags are associated with your CA.

2568 2569 2570 2571 # File 'gems/aws-sdk-acmpca/lib/aws-sdk-acmpca/client.rb', line 2568 def untag_certificate_authority(params = {}, options = {}) req = build_request(:untag_certificate_authority, params) req.send_request(options) end

#update_certificate_authority(params = {}) ⇒ Struct

Updates the status or configuration of a private certificate authority (CA). Your private CA must be in the ACTIVE or DISABLED state before you can update it. You can disable a private CA that is in theACTIVE state or make a CA that is in the DISABLED state active again.

Both Amazon Web Services Private CA and the IAM principal must have permission to write to the S3 bucket that you specify. If the IAM principal making the call does not have permission to write to the bucket, then an exception is thrown. For more information, see Access policies for CRLs in Amazon S3.

2676 2677 2678 2679 # File 'gems/aws-sdk-acmpca/lib/aws-sdk-acmpca/client.rb', line 2676 def update_certificate_authority(params = {}, options = {}) req = build_request(:update_certificate_authority, params) req.send_request(options) end

#wait_until(waiter_name, params = {}, options = {}) {|w.waiter| ... } ⇒ Boolean

Polls an API operation until a resource enters a desired state.

Basic Usage

A waiter will call an API operation until:

In between attempts, the waiter will sleep.

# polls in a loop, sleeping between attempts
client.wait_until(waiter_name, params)

Configuration

You can configure the maximum number of polling attempts, and the delay (in seconds) between each polling attempt. You can pass configuration as the final arguments hash.

# poll for ~25 seconds
client.wait_until(waiter_name, params, {
  max_attempts: 5,
  delay: 5,
})

Callbacks

You can be notified before each polling attempt and before each delay. If you throw :success or :failure from these callbacks, it will terminate the waiter.

started_at = Time.now
client.wait_until(waiter_name, params, {

  # disable max attempts
  max_attempts: nil,

  # poll for 1 hour, instead of a number of attempts
  before_wait: -> (attempts, response) do
    throw :failure if Time.now - started_at > 3600
  end
})

Handling Errors

When a waiter is unsuccessful, it will raise an error. All of the failure errors extend fromWaiters::Errors::WaiterFailed.

begin
  client.wait_until(...)
rescue Aws::Waiters::Errors::WaiterFailed
  # resource did not enter the desired state in time
end

Valid Waiters

The following table lists the valid waiter names, the operations they call, and the default :delay and :max_attempts values.

waiter_name params :delay :max_attempts
audit_report_created #describe_certificate_authority_audit_report 3 60
certificate_authority_csr_created #get_certificate_authority_csr 3 60
certificate_issued #get_certificate 1 60
2793 2794 2795 2796 2797 # File 'gems/aws-sdk-acmpca/lib/aws-sdk-acmpca/client.rb', line 2793 def wait_until(waiter_name, params = {}, options = {}) w = waiter(waiter_name, options) yield(w.waiter) if block_given? w.wait(params) end