Skip to main content

aws_sdk_kms/client/
get_key_policy.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2impl super::Client {
3    /// Constructs a fluent builder for the [`GetKeyPolicy`](crate::operation::get_key_policy::builders::GetKeyPolicyFluentBuilder) operation.
4    ///
5    /// - The fluent builder is configurable:
6    ///   - [`key_id(impl Into<String>)`](crate::operation::get_key_policy::builders::GetKeyPolicyFluentBuilder::key_id) / [`set_key_id(Option<String>)`](crate::operation::get_key_policy::builders::GetKeyPolicyFluentBuilder::set_key_id):<br>required: **true**<br><p>Identifies the KMS key whose key policy you want to get.</p> <p>Specify the key ID or key ARN of the KMS key.</p> <p>For example:</p> <ul>  <li>   <p>Key ID: <code>1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>  <li>   <p>Key ARN: <code>arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li> </ul> <p>To get the key ID and key ARN for a KMS key, use <code>ListKeys</code> or <code>DescribeKey</code>.</p><br>
7    ///   - [`policy_name(impl Into<String>)`](crate::operation::get_key_policy::builders::GetKeyPolicyFluentBuilder::policy_name) / [`set_policy_name(Option<String>)`](crate::operation::get_key_policy::builders::GetKeyPolicyFluentBuilder::set_policy_name):<br>required: **false**<br><p>Specifies the name of the key policy. If no policy name is specified, the default value is <code>default</code>. Valid values are <code>default</code> and <code>AWS_RAM</code>. Use <code>AWS_RAM</code> to get the key policy that RAM manages for a KMS key that you share through RAM. If the KMS key doesn't have an <code>AWS_RAM</code> key policy, the request fails with a <code>NotFoundException</code>. To get the names of key policies, use <code>ListKeyPolicies</code>.</p><br>
8    /// - On success, responds with [`GetKeyPolicyOutput`](crate::operation::get_key_policy::GetKeyPolicyOutput) with field(s):
9    ///   - [`policy(Option<String>)`](crate::operation::get_key_policy::GetKeyPolicyOutput::policy): <p>A key policy document in JSON format.</p>
10    ///   - [`policy_name(Option<String>)`](crate::operation::get_key_policy::GetKeyPolicyOutput::policy_name): <p>The name of the key policy. Valid values are:</p> <dl>  <dt>   default  </dt>  <dd>   <p>The key policy that you manage.</p>  </dd>  <dt>   AWS_RAM  </dt>  <dd>   <p>The key policy that RAM manages for KMS keys that you share through RAM.</p>  </dd> </dl>
11    /// - On failure, responds with [`SdkError<GetKeyPolicyError>`](crate::operation::get_key_policy::GetKeyPolicyError)
12    pub fn get_key_policy(&self) -> crate::operation::get_key_policy::builders::GetKeyPolicyFluentBuilder {
13        crate::operation::get_key_policy::builders::GetKeyPolicyFluentBuilder::new(self.handle.clone())
14    }
15}