Struct aws_sdk_kms::client::fluent_builders::PutKeyPolicy
source · [−]pub struct PutKeyPolicy { /* private fields */ }Expand description
Fluent builder constructing a request to PutKeyPolicy.
Attaches a key policy to the specified KMS key.
For more information about key policies, see Key Policies in the Key Management Service Developer Guide. For help writing and formatting a JSON policy document, see the IAM JSON Policy Reference in the Identity and Access Management User Guide . For examples of adding a key policy in multiple programming languages, see Setting a key policy in the Key Management Service Developer Guide.
Cross-account use: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account.
Required permissions: kms:PutKeyPolicy (key policy)
Related operations: GetKeyPolicy
Implementations
sourceimpl PutKeyPolicy
impl PutKeyPolicy
sourcepub async fn send(
self
) -> Result<PutKeyPolicyOutput, SdkError<PutKeyPolicyError>>
pub async fn send(
self
) -> Result<PutKeyPolicyOutput, SdkError<PutKeyPolicyError>>
Sends the request and returns the response.
If an error occurs, an SdkError will be returned with additional details that
can be matched against.
By default, any retryable failures will be retried twice. Retry behavior is configurable with the RetryConfig, which can be set when configuring the client.
sourcepub fn key_id(self, input: impl Into<String>) -> Self
pub fn key_id(self, input: impl Into<String>) -> Self
Sets the key policy on the specified KMS key.
Specify the key ID or key ARN of the KMS key.
For example:
-
Key ID:
1234abcd-12ab-34cd-56ef-1234567890ab -
Key ARN:
arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab
To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey.
sourcepub fn set_key_id(self, input: Option<String>) -> Self
pub fn set_key_id(self, input: Option<String>) -> Self
Sets the key policy on the specified KMS key.
Specify the key ID or key ARN of the KMS key.
For example:
-
Key ID:
1234abcd-12ab-34cd-56ef-1234567890ab -
Key ARN:
arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab
To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey.
sourcepub fn policy_name(self, input: impl Into<String>) -> Self
pub fn policy_name(self, input: impl Into<String>) -> Self
The name of the key policy. The only valid value is default.
sourcepub fn set_policy_name(self, input: Option<String>) -> Self
pub fn set_policy_name(self, input: Option<String>) -> Self
The name of the key policy. The only valid value is default.
sourcepub fn policy(self, input: impl Into<String>) -> Self
pub fn policy(self, input: impl Into<String>) -> Self
The key policy to attach to the KMS key.
The key policy must meet the following criteria:
-
If you don't set
BypassPolicyLockoutSafetyCheckto true, the key policy must allow the principal that is making thePutKeyPolicyrequest to make a subsequentPutKeyPolicyrequest on the KMS key. This reduces the risk that the KMS key becomes unmanageable. For more information, refer to the scenario in the Default Key Policy section of the Key Management Service Developer Guide. -
Each statement in the key policy must contain one or more principals. The principals in the key policy must exist and be visible to KMS. When you create a new Amazon Web Services principal (for example, an IAM user or role), you might need to enforce a delay before including the new principal in a key policy because the new principal might not be immediately visible to KMS. For more information, see Changes that I make are not always immediately visible in the Amazon Web Services Identity and Access Management User Guide.
A key policy document must conform to the following rules.
-
Up to 32 kilobytes (32768 bytes)
-
Must be UTF-8 encoded
-
The only Unicode characters that are permitted in a key policy document are the horizontal tab (U+0009), linefeed (U+000A), carriage return (U+000D), and characters in the range U+0020 to U+00FF.
-
The
Sidelement in a key policy statement can include spaces. (Spaces are prohibited in theSidelement of an IAM policy document.)
sourcepub fn set_policy(self, input: Option<String>) -> Self
pub fn set_policy(self, input: Option<String>) -> Self
The key policy to attach to the KMS key.
The key policy must meet the following criteria:
-
If you don't set
BypassPolicyLockoutSafetyCheckto true, the key policy must allow the principal that is making thePutKeyPolicyrequest to make a subsequentPutKeyPolicyrequest on the KMS key. This reduces the risk that the KMS key becomes unmanageable. For more information, refer to the scenario in the Default Key Policy section of the Key Management Service Developer Guide. -
Each statement in the key policy must contain one or more principals. The principals in the key policy must exist and be visible to KMS. When you create a new Amazon Web Services principal (for example, an IAM user or role), you might need to enforce a delay before including the new principal in a key policy because the new principal might not be immediately visible to KMS. For more information, see Changes that I make are not always immediately visible in the Amazon Web Services Identity and Access Management User Guide.
A key policy document must conform to the following rules.
-
Up to 32 kilobytes (32768 bytes)
-
Must be UTF-8 encoded
-
The only Unicode characters that are permitted in a key policy document are the horizontal tab (U+0009), linefeed (U+000A), carriage return (U+000D), and characters in the range U+0020 to U+00FF.
-
The
Sidelement in a key policy statement can include spaces. (Spaces are prohibited in theSidelement of an IAM policy document.)
sourcepub fn bypass_policy_lockout_safety_check(self, input: bool) -> Self
pub fn bypass_policy_lockout_safety_check(self, input: bool) -> Self
A flag to indicate whether to bypass the key policy lockout safety check.
Setting this value to true increases the risk that the KMS key becomes unmanageable. Do not set this value to true indiscriminately.
For more information, refer to the scenario in the Default Key Policy section in the Key Management Service Developer Guide.
Use this parameter only when you intend to prevent the principal that is making the request from making a subsequent PutKeyPolicy request on the KMS key.
The default value is false.
sourcepub fn set_bypass_policy_lockout_safety_check(self, input: Option<bool>) -> Self
pub fn set_bypass_policy_lockout_safety_check(self, input: Option<bool>) -> Self
A flag to indicate whether to bypass the key policy lockout safety check.
Setting this value to true increases the risk that the KMS key becomes unmanageable. Do not set this value to true indiscriminately.
For more information, refer to the scenario in the Default Key Policy section in the Key Management Service Developer Guide.
Use this parameter only when you intend to prevent the principal that is making the request from making a subsequent PutKeyPolicy request on the KMS key.
The default value is false.
Trait Implementations
sourceimpl Clone for PutKeyPolicy
impl Clone for PutKeyPolicy
sourcefn clone(&self) -> PutKeyPolicy
fn clone(&self) -> PutKeyPolicy
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
Auto Trait Implementations
impl !RefUnwindSafe for PutKeyPolicy
impl Send for PutKeyPolicy
impl Sync for PutKeyPolicy
impl Unpin for PutKeyPolicy
impl !UnwindSafe for PutKeyPolicy
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more