You are viewing documentation for version 2 of the AWS SDK for Ruby. Version 3 documentation can be found here.

Class: Aws::CloudHSMV2::Client

Inherits:
Seahorse::Client::Base show all
Defined in:
(unknown)

Overview

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

cloudhsmv2 = Aws::CloudHSMV2::Client.new(
  region: region_name,
  credentials: credentials,
  # ...
)

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

Region

You can configure a default region in the following locations:

  • ENV['AWS_REGION']
  • Aws.config[:region]

Go here for a list of supported regions.

Credentials

Default credentials are loaded automatically from the following locations:

  • ENV['AWS_ACCESS_KEY_ID'] and ENV['AWS_SECRET_ACCESS_KEY']
  • Aws.config[:credentials]
  • The shared credentials ini file at ~/.aws/credentials (more information)
  • From an instance profile when running on EC2

You can also construct a credentials object from one of the following classes:

Alternatively, you configure credentials with :access_key_id and :secret_access_key:

# load credentials from disk
creds = YAML.load(File.read('/path/to/secrets'))

Aws::CloudHSMV2::Client.new(
  access_key_id: creds['access_key_id'],
  secret_access_key: creds['secret_access_key']
)

Always load your credentials from outside your application. Avoid configuring credentials statically and never commit them to source control.

Instance Attribute Summary

Attributes inherited from Seahorse::Client::Base

#config, #handlers

Constructor collapse

API Operations collapse

Instance Method Summary collapse

Methods inherited from Seahorse::Client::Base

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

Methods included from Seahorse::Client::HandlerBuilder

#handle, #handle_request, #handle_response

Constructor Details

#initialize(options = {}) ⇒ Aws::CloudHSMV2::Client

Constructs an API client.

Options Hash (options):

  • :access_key_id (String)

    Used to set credentials statically. See Plugins::RequestSigner for more details.

  • :convert_params (Boolean) — default: true

    When true, an attempt is made to coerce request parameters into the required types. See Plugins::ParamConverter for more details.

  • :credentials (required, Credentials)

    Your AWS credentials. The following locations will be searched in order for credentials:

    • :access_key_id, :secret_access_key, and :session_token options
    • ENV['AWS_ACCESS_KEY_ID'], ENV['AWS_SECRET_ACCESS_KEY']
    • HOME/.aws/credentials shared credentials file
    • EC2 instance profile credentials See Plugins::RequestSigner for more details.
  • :endpoint (String)

    A default endpoint is constructed from the :region. See Plugins::RegionalEndpoint for more details.

  • :http_continue_timeout (Float) — default: 1

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :http_idle_timeout (Integer) — default: 5

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :http_open_timeout (Integer) — default: 15

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :http_proxy (String)

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :http_read_timeout (Integer) — default: 60

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :http_wire_trace (Boolean) — default: false

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :log_level (Symbol) — default: :info

    The log level to send messages to the logger at. See Plugins::Logging for more details.

  • :log_formatter (Logging::LogFormatter)

    The log formatter. Defaults to Seahorse::Client::Logging::Formatter.default. See Plugins::Logging for more details.

  • :logger (Logger) — default: nil

    The Logger instance to send log messages to. If this option is not set, logging will be disabled. See Plugins::Logging for more details.

  • :profile (String)

    Used when loading credentials from the shared credentials file at HOME/.aws/credentials. When not specified, 'default' is used. See Plugins::RequestSigner for more details.

  • :raise_response_errors (Boolean) — default: true

    When true, response errors are raised. See Seahorse::Client::Plugins::RaiseResponseErrors for more details.

  • :region (required, String)

    The AWS region to connect to. The region is used to construct the client endpoint. Defaults to ENV['AWS_REGION']. Also checks AMAZON_REGION and AWS_DEFAULT_REGION. See Plugins::RegionalEndpoint for more details.

  • :retry_limit (Integer) — default: 3

    The maximum number of times to retry failed requests. Only ~ 500 level server errors and certain ~ 400 level client errors are retried. Generally, these are throttling errors, data checksum errors, networking errors, timeout errors and auth errors from expired credentials. See Plugins::RetryErrors for more details.

  • :secret_access_key (String)

    Used to set credentials statically. See Plugins::RequestSigner for more details.

  • :session_token (String)

    Used to set credentials statically. See Plugins::RequestSigner for more details.

  • :simple_json (Boolean) — default: false

    Disables request parameter conversion, validation, and formatting. Also disable response data type conversions. This option is useful when you want to ensure the highest level of performance by avoiding overhead of walking request parameters and response data structures.

    When :simple_json is enabled, the request parameters hash must be formatted exactly as the DynamoDB API expects. See Plugins::Protocols::JsonRpc for more details.

  • :ssl_ca_bundle (String)

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :ssl_ca_directory (String)

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :ssl_ca_store (String)

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :ssl_verify_peer (Boolean) — default: true

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :stub_responses (Boolean) — default: false

    Causes the client to return stubbed responses. By default fake responses are generated and returned. You can specify the response data to return or errors to raise by calling Aws::ClientStubs#stub_responses. See Aws::ClientStubs for more information.

    Please note When response stubbing is enabled, no HTTP requests are made, and retries are disabled. See Plugins::StubResponses for more details.

  • :validate_params (Boolean) — default: true

    When true, request parameters are validated before sending the request. See Plugins::ParamValidator for more details.

Instance Method Details

#create_cluster(options = {}) ⇒ Types::CreateClusterResponse

Creates a new AWS CloudHSM cluster.

Examples:

Request syntax with placeholder values


resp = client.create_cluster({
  subnet_ids: ["SubnetId"], # required
  hsm_type: "HsmType", # required
  source_backup_id: "BackupId",
})

Response structure


resp.cluster.backup_policy #=> String, one of "DEFAULT"
resp.cluster.cluster_id #=> String
resp.cluster.create_timestamp #=> Time
resp.cluster.hsms #=> Array
resp.cluster.hsms[0].availability_zone #=> String
resp.cluster.hsms[0].cluster_id #=> String
resp.cluster.hsms[0].subnet_id #=> String
resp.cluster.hsms[0].eni_id #=> String
resp.cluster.hsms[0].eni_ip #=> String
resp.cluster.hsms[0].hsm_id #=> String
resp.cluster.hsms[0].state #=> String, one of "CREATE_IN_PROGRESS", "ACTIVE", "DEGRADED", "DELETE_IN_PROGRESS", "DELETED"
resp.cluster.hsms[0].state_message #=> String
resp.cluster.hsm_type #=> String
resp.cluster.pre_co_password #=> String
resp.cluster.security_group #=> String
resp.cluster.source_backup_id #=> String
resp.cluster.state #=> String, one of "CREATE_IN_PROGRESS", "UNINITIALIZED", "INITIALIZE_IN_PROGRESS", "INITIALIZED", "ACTIVE", "UPDATE_IN_PROGRESS", "DELETE_IN_PROGRESS", "DELETED", "DEGRADED"
resp.cluster.state_message #=> String
resp.cluster.subnet_mapping #=> Hash
resp.cluster.subnet_mapping["ExternalAz"] #=> String
resp.cluster.vpc_id #=> String
resp.cluster.certificates.cluster_csr #=> String
resp.cluster.certificates.hsm_certificate #=> String
resp.cluster.certificates.aws_hardware_certificate #=> String
resp.cluster.certificates.manufacturer_hardware_certificate #=> String
resp.cluster.certificates.cluster_certificate #=> String

Options Hash (options):

  • :subnet_ids (required, Array<String>)

    The identifiers (IDs) of the subnets where you are creating the cluster. You must specify at least one subnet. If you specify multiple subnets, they must meet the following criteria:

    • All subnets must be in the same virtual private cloud (VPC).

    • You can specify only one subnet per Availability Zone.

  • :hsm_type (required, String)

    The type of HSM to use in the cluster. Currently the only allowed value is hsm1.medium.

  • :source_backup_id (String)

    The identifier (ID) of the cluster backup to restore. Use this value to restore the cluster from a backup instead of creating a new cluster. To find the backup ID, use DescribeBackups.

Returns:

See Also:

#create_hsm(options = {}) ⇒ Types::CreateHsmResponse

Creates a new hardware security module (HSM) in the specified AWS CloudHSM cluster.

Examples:

Request syntax with placeholder values


resp = client.create_hsm({
  cluster_id: "ClusterId", # required
  availability_zone: "ExternalAz", # required
  ip_address: "IpAddress",
})

Response structure


resp.hsm.availability_zone #=> String
resp.hsm.cluster_id #=> String
resp.hsm.subnet_id #=> String
resp.hsm.eni_id #=> String
resp.hsm.eni_ip #=> String
resp.hsm.hsm_id #=> String
resp.hsm.state #=> String, one of "CREATE_IN_PROGRESS", "ACTIVE", "DEGRADED", "DELETE_IN_PROGRESS", "DELETED"
resp.hsm.state_message #=> String

Options Hash (options):

  • :cluster_id (required, String)

    The identifier (ID) of the HSM\'s cluster. To find the cluster ID, use DescribeClusters.

  • :availability_zone (required, String)

    The Availability Zone where you are creating the HSM. To find the cluster\'s Availability Zones, use DescribeClusters.

  • :ip_address (String)

    The HSM\'s IP address. If you specify an IP address, use an available address from the subnet that maps to the Availability Zone where you are creating the HSM. If you don\'t specify an IP address, one is chosen for you from that subnet.

Returns:

See Also:

#delete_cluster(options = {}) ⇒ Types::DeleteClusterResponse

Deletes the specified AWS CloudHSM cluster. Before you can delete a cluster, you must delete all HSMs in the cluster. To see if the cluster contains any HSMs, use DescribeClusters. To delete an HSM, use DeleteHsm.

Examples:

Request syntax with placeholder values


resp = client.delete_cluster({
  cluster_id: "ClusterId", # required
})

Response structure


resp.cluster.backup_policy #=> String, one of "DEFAULT"
resp.cluster.cluster_id #=> String
resp.cluster.create_timestamp #=> Time
resp.cluster.hsms #=> Array
resp.cluster.hsms[0].availability_zone #=> String
resp.cluster.hsms[0].cluster_id #=> String
resp.cluster.hsms[0].subnet_id #=> String
resp.cluster.hsms[0].eni_id #=> String
resp.cluster.hsms[0].eni_ip #=> String
resp.cluster.hsms[0].hsm_id #=> String
resp.cluster.hsms[0].state #=> String, one of "CREATE_IN_PROGRESS", "ACTIVE", "DEGRADED", "DELETE_IN_PROGRESS", "DELETED"
resp.cluster.hsms[0].state_message #=> String
resp.cluster.hsm_type #=> String
resp.cluster.pre_co_password #=> String
resp.cluster.security_group #=> String
resp.cluster.source_backup_id #=> String
resp.cluster.state #=> String, one of "CREATE_IN_PROGRESS", "UNINITIALIZED", "INITIALIZE_IN_PROGRESS", "INITIALIZED", "ACTIVE", "UPDATE_IN_PROGRESS", "DELETE_IN_PROGRESS", "DELETED", "DEGRADED"
resp.cluster.state_message #=> String
resp.cluster.subnet_mapping #=> Hash
resp.cluster.subnet_mapping["ExternalAz"] #=> String
resp.cluster.vpc_id #=> String
resp.cluster.certificates.cluster_csr #=> String
resp.cluster.certificates.hsm_certificate #=> String
resp.cluster.certificates.aws_hardware_certificate #=> String
resp.cluster.certificates.manufacturer_hardware_certificate #=> String
resp.cluster.certificates.cluster_certificate #=> String

Options Hash (options):

  • :cluster_id (required, String)

    The identifier (ID) of the cluster that you are deleting. To find the cluster ID, use DescribeClusters.

Returns:

See Also:

#delete_hsm(options = {}) ⇒ Types::DeleteHsmResponse

Deletes the specified HSM. To specify an HSM, you can use its identifier (ID), the IP address of the HSM's elastic network interface (ENI), or the ID of the HSM's ENI. You need to specify only one of these values. To find these values, use DescribeClusters.

Examples:

Request syntax with placeholder values


resp = client.delete_hsm({
  cluster_id: "ClusterId", # required
  hsm_id: "HsmId",
  eni_id: "EniId",
  eni_ip: "IpAddress",
})

Response structure


resp.hsm_id #=> String

Options Hash (options):

  • :cluster_id (required, String)

    The identifier (ID) of the cluster that contains the HSM that you are deleting.

  • :hsm_id (String)

    The identifier (ID) of the HSM that you are deleting.

  • :eni_id (String)

    The identifier (ID) of the elastic network interface (ENI) of the HSM that you are deleting.

  • :eni_ip (String)

    The IP address of the elastic network interface (ENI) of the HSM that you are deleting.

Returns:

See Also:

#describe_backups(options = {}) ⇒ Types::DescribeBackupsResponse

Gets information about backups of AWS CloudHSM clusters.

This is a paginated operation, which means that each response might contain only a subset of all the backups. When the response contains only a subset of backups, it includes a NextToken value. Use this value in a subsequent DescribeBackups request to get more backups. When you receive a response with no NextToken (or an empty or null value), that means there are no more backups to get.

Examples:

Request syntax with placeholder values


resp = client.describe_backups({
  next_token: "NextToken",
  max_results: 1,
  filters: {
    "Field" => ["String"],
  },
})

Response structure


resp.backups #=> Array
resp.backups[0].backup_id #=> String
resp.backups[0].backup_state #=> String, one of "CREATE_IN_PROGRESS", "READY", "DELETED"
resp.backups[0].cluster_id #=> String
resp.backups[0].create_timestamp #=> Time
resp.next_token #=> String

Options Hash (options):

  • :next_token (String)

    The NextToken value that you received in the previous response. Use this value to get more backups.

  • :max_results (Integer)

    The maximum number of backups to return in the response. When there are more backups than the number you specify, the response contains a NextToken value.

  • :filters (Hash<String,Array<String>>)

    One or more filters to limit the items returned in the response.

    Use the backupIds filter to return only the specified backups. Specify backups by their backup identifier (ID).

    Use the clusterIds filter to return only the backups for the specified clusters. Specify clusters by their cluster identifier (ID).

    Use the states filter to return only backups that match the specified state.

Returns:

See Also:

#describe_clusters(options = {}) ⇒ Types::DescribeClustersResponse

Gets information about AWS CloudHSM clusters.

This is a paginated operation, which means that each response might contain only a subset of all the clusters. When the response contains only a subset of clusters, it includes a NextToken value. Use this value in a subsequent DescribeClusters request to get more clusters. When you receive a response with no NextToken (or an empty or null value), that means there are no more clusters to get.

Examples:

Request syntax with placeholder values


resp = client.describe_clusters({
  filters: {
    "Field" => ["String"],
  },
  next_token: "NextToken",
  max_results: 1,
})

Response structure


resp.clusters #=> Array
resp.clusters[0].backup_policy #=> String, one of "DEFAULT"
resp.clusters[0].cluster_id #=> String
resp.clusters[0].create_timestamp #=> Time
resp.clusters[0].hsms #=> Array
resp.clusters[0].hsms[0].availability_zone #=> String
resp.clusters[0].hsms[0].cluster_id #=> String
resp.clusters[0].hsms[0].subnet_id #=> String
resp.clusters[0].hsms[0].eni_id #=> String
resp.clusters[0].hsms[0].eni_ip #=> String
resp.clusters[0].hsms[0].hsm_id #=> String
resp.clusters[0].hsms[0].state #=> String, one of "CREATE_IN_PROGRESS", "ACTIVE", "DEGRADED", "DELETE_IN_PROGRESS", "DELETED"
resp.clusters[0].hsms[0].state_message #=> String
resp.clusters[0].hsm_type #=> String
resp.clusters[0].pre_co_password #=> String
resp.clusters[0].security_group #=> String
resp.clusters[0].source_backup_id #=> String
resp.clusters[0].state #=> String, one of "CREATE_IN_PROGRESS", "UNINITIALIZED", "INITIALIZE_IN_PROGRESS", "INITIALIZED", "ACTIVE", "UPDATE_IN_PROGRESS", "DELETE_IN_PROGRESS", "DELETED", "DEGRADED"
resp.clusters[0].state_message #=> String
resp.clusters[0].subnet_mapping #=> Hash
resp.clusters[0].subnet_mapping["ExternalAz"] #=> String
resp.clusters[0].vpc_id #=> String
resp.clusters[0].certificates.cluster_csr #=> String
resp.clusters[0].certificates.hsm_certificate #=> String
resp.clusters[0].certificates.aws_hardware_certificate #=> String
resp.clusters[0].certificates.manufacturer_hardware_certificate #=> String
resp.clusters[0].certificates.cluster_certificate #=> String
resp.next_token #=> String

Options Hash (options):

  • :filters (Hash<String,Array<String>>)

    One or more filters to limit the items returned in the response.

    Use the clusterIds filter to return only the specified clusters. Specify clusters by their cluster identifier (ID).

    Use the vpcIds filter to return only the clusters in the specified virtual private clouds (VPCs). Specify VPCs by their VPC identifier (ID).

    Use the states filter to return only clusters that match the specified state.

  • :next_token (String)

    The NextToken value that you received in the previous response. Use this value to get more clusters.

  • :max_results (Integer)

    The maximum number of clusters to return in the response. When there are more clusters than the number you specify, the response contains a NextToken value.

Returns:

See Also:

#initialize_cluster(options = {}) ⇒ Types::InitializeClusterResponse

Claims an AWS CloudHSM cluster by submitting the cluster certificate issued by your issuing certificate authority (CA) and the CA's root certificate. Before you can claim a cluster, you must sign the cluster's certificate signing request (CSR) with your issuing CA. To get the cluster's CSR, use DescribeClusters.

Examples:

Request syntax with placeholder values


resp = client.initialize_cluster({
  cluster_id: "ClusterId", # required
  signed_cert: "Cert", # required
  trust_anchor: "Cert", # required
})

Response structure


resp.state #=> String, one of "CREATE_IN_PROGRESS", "UNINITIALIZED", "INITIALIZE_IN_PROGRESS", "INITIALIZED", "ACTIVE", "UPDATE_IN_PROGRESS", "DELETE_IN_PROGRESS", "DELETED", "DEGRADED"
resp.state_message #=> String

Options Hash (options):

  • :cluster_id (required, String)

    The identifier (ID) of the cluster that you are claiming. To find the cluster ID, use DescribeClusters.

  • :signed_cert (required, String)

    The cluster certificate issued (signed) by your issuing certificate authority (CA). The certificate must be in PEM format and can contain a maximum of 5000 characters.

  • :trust_anchor (required, String)

    The issuing certificate of the issuing certificate authority (CA) that issued (signed) the cluster certificate. This can be a root (self-signed) certificate or a certificate chain that begins with the certificate that issued the cluster certificate and ends with a root certificate. The certificate or certificate chain must be in PEM format and can contain a maximum of 5000 characters.

Returns:

See Also:

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

Gets a list of tags for the specified AWS CloudHSM cluster.

This is a paginated operation, which means that each response might contain only a subset of all the tags. When the response contains only a subset of tags, it includes a NextToken value. Use this value in a subsequent ListTags request to get more tags. When you receive a response with no NextToken (or an empty or null value), that means there are no more tags to get.

Examples:

Request syntax with placeholder values


resp = client.list_tags({
  resource_id: "ClusterId", # required
  next_token: "NextToken",
  max_results: 1,
})

Response structure


resp.tag_list #=> Array
resp.tag_list[0].key #=> String
resp.tag_list[0].value #=> String
resp.next_token #=> String

Options Hash (options):

  • :resource_id (required, String)

    The cluster identifier (ID) for the cluster whose tags you are getting. To find the cluster ID, use DescribeClusters.

  • :next_token (String)

    The NextToken value that you received in the previous response. Use this value to get more tags.

  • :max_results (Integer)

    The maximum number of tags to return in the response. When there are more tags than the number you specify, the response contains a NextToken value.

Returns:

See Also:

#tag_resource(options = {}) ⇒ Struct

Adds or overwrites one or more tags for the specified AWS CloudHSM cluster.

Examples:

Request syntax with placeholder values


resp = client.tag_resource({
  resource_id: "ClusterId", # required
  tag_list: [ # required
    {
      key: "TagKey", # required
      value: "TagValue", # required
    },
  ],
})

Options Hash (options):

  • :resource_id (required, String)

    The cluster identifier (ID) for the cluster that you are tagging. To find the cluster ID, use DescribeClusters.

  • :tag_list (required, Array<Types::Tag>)

    A list of one or more tags.

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#untag_resource(options = {}) ⇒ Struct

Removes the specified tag or tags from the specified AWS CloudHSM cluster.

Examples:

Request syntax with placeholder values


resp = client.untag_resource({
  resource_id: "ClusterId", # required
  tag_key_list: ["TagKey"], # required
})

Options Hash (options):

  • :resource_id (required, String)

    The cluster identifier (ID) for the cluster whose tags you are removing. To find the cluster ID, use DescribeClusters.

  • :tag_key_list (required, Array<String>)

    A list of one or more tag keys for the tags that you are removing. Specify only the tag keys, not the tag values.

Returns:

  • (Struct)

    Returns an empty response.

See Also:

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

Waiters polls an API operation until a resource enters a desired state.

Basic Usage

Waiters will poll until they are succesful, they fail by entering a terminal state, or until a maximum number of attempts are made.

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

Configuration

You can configure the maximum number of polling attempts, and the delay (in seconds) between each polling attempt. You configure waiters by passing a block to #wait_until:

# poll for ~25 seconds
client.wait_until(...) do |w|
  w.max_attempts = 5
  w.delay = 5
end

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(...) do |w|

  # disable max attempts
  w.max_attempts = nil

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

end

Handling Errors

When a waiter is successful, it returns true. When a waiter fails, it raises an error. All errors raised extend from Waiters::Errors::WaiterFailed.

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

Parameters:

  • waiter_name (Symbol)

    The name of the waiter. See #waiter_names for a full list of supported waiters.

  • params (Hash) (defaults to: {})

    Additional request parameters. See the #waiter_names for a list of supported waiters and what request they call. The called request determines the list of accepted parameters.

Yield Parameters:

Returns:

  • (Boolean)

    Returns true if the waiter was successful.

Raises:

  • (Errors::FailureStateError)

    Raised when the waiter terminates because the waiter has entered a state that it will not transition out of, preventing success.

  • (Errors::TooManyAttemptsError)

    Raised when the configured maximum number of attempts have been made, and the waiter is not yet successful.

  • (Errors::UnexpectedError)

    Raised when an error is encounted while polling for a resource that is not expected.

  • (Errors::NoSuchWaiterError)

    Raised when you request to wait for an unknown state.

#waiter_namesArray<Symbol>

Returns the list of supported waiters. The following table lists the supported waiters and the client method they call:

Waiter NameClient MethodDefault Delay:Default Max Attempts:

Returns:

  • (Array<Symbol>)

    the list of supported waiters.