| 1 | |||
| 2 | package Paws::KMS::PutKeyPolicy; | ||
| 3 | use Moose; | ||
| 4 | has BypassPolicyLockoutSafetyCheck => (is => 'ro', isa => 'Bool'); | ||
| 5 | has KeyId => (is => 'ro', isa => 'Str', required => 1); | ||
| 6 | has Policy => (is => 'ro', isa => 'Str', required => 1); | ||
| 7 | has PolicyName => (is => 'ro', isa => 'Str', required => 1); | ||
| 8 | |||
| 9 | use MooseX::ClassAttribute; | ||
| 10 | |||
| 11 | class_has _api_call => (isa => 'Str', is => 'ro', default => 'PutKeyPolicy'); | ||
| 12 | class_has _returns => (isa => 'Str', is => 'ro', default => 'Paws::API::Response'); | ||
| 13 | class_has _result_key => (isa => 'Str', is => 'ro'); | ||
| 14 | 1; | ||
| 15 | |||
| 16 | ### main pod documentation begin ### | ||
| 17 | |||
| 18 | =head1 NAME | ||
| 19 | |||
| 20 | Paws::KMS::PutKeyPolicy - Arguments for method PutKeyPolicy on L<Paws::KMS> | ||
| 21 | |||
| 22 | =head1 DESCRIPTION | ||
| 23 | |||
| 24 | This class represents the parameters used for calling the method PutKeyPolicy on the | ||
| 25 | L<AWS Key Management Service|Paws::KMS> service. Use the attributes of this class | ||
| 26 | as arguments to method PutKeyPolicy. | ||
| 27 | |||
| 28 | You shouldn't make instances of this class. Each attribute should be used as a named argument in the call to PutKeyPolicy. | ||
| 29 | |||
| 30 | =head1 SYNOPSIS | ||
| 31 | |||
| 32 | my $kms = Paws->service('KMS'); | ||
| 33 | # To attach a key policy to a customer master key (CMK) | ||
| 34 | # The following example attaches a key policy to the specified CMK. | ||
| 35 | $kms->PutKeyPolicy( | ||
| 36 | 'KeyId' => '1234abcd-12ab-34cd-56ef-1234567890ab', | ||
| 37 | 'Policy' => '{ | ||
| 38 | "Version": "2012-10-17", | ||
| 39 | "Id": "custom-policy-2016-12-07", | ||
| 40 | "Statement": [ | ||
| 41 | { | ||
| 42 | "Sid": "Enable IAM User Permissions", | ||
| 43 | "Effect": "Allow", | ||
| 44 | "Principal": { | ||
| 45 | "AWS": "arn:aws:iam::111122223333:root" | ||
| 46 | }, | ||
| 47 | "Action": "kms:*", | ||
| 48 | "Resource": "*" | ||
| 49 | }, | ||
| 50 | { | ||
| 51 | "Sid": "Allow access for Key Administrators", | ||
| 52 | "Effect": "Allow", | ||
| 53 | "Principal": { | ||
| 54 | "AWS": [ | ||
| 55 | "arn:aws:iam::111122223333:user/ExampleAdminUser", | ||
| 56 | "arn:aws:iam::111122223333:role/ExampleAdminRole" | ||
| 57 | ] | ||
| 58 | }, | ||
| 59 | "Action": [ | ||
| 60 | "kms:Create*", | ||
| 61 | "kms:Describe*", | ||
| 62 | "kms:Enable*", | ||
| 63 | "kms:List*", | ||
| 64 | "kms:Put*", | ||
| 65 | "kms:Update*", | ||
| 66 | "kms:Revoke*", | ||
| 67 | "kms:Disable*", | ||
| 68 | "kms:Get*", | ||
| 69 | "kms:Delete*", | ||
| 70 | "kms:ScheduleKeyDeletion", | ||
| 71 | "kms:CancelKeyDeletion" | ||
| 72 | ], | ||
| 73 | "Resource": "*" | ||
| 74 | }, | ||
| 75 | { | ||
| 76 | "Sid": "Allow use of the key", | ||
| 77 | "Effect": "Allow", | ||
| 78 | "Principal": { | ||
| 79 | "AWS": "arn:aws:iam::111122223333:role/ExamplePowerUserRole" | ||
| 80 | }, | ||
| 81 | "Action": [ | ||
| 82 | "kms:Encrypt", | ||
| 83 | "kms:Decrypt", | ||
| 84 | "kms:ReEncrypt*", | ||
| 85 | "kms:GenerateDataKey*", | ||
| 86 | "kms:DescribeKey" | ||
| 87 | ], | ||
| 88 | "Resource": "*" | ||
| 89 | }, | ||
| 90 | { | ||
| 91 | "Sid": "Allow attachment of persistent resources", | ||
| 92 | "Effect": "Allow", | ||
| 93 | "Principal": { | ||
| 94 | "AWS": "arn:aws:iam::111122223333:role/ExamplePowerUserRole" | ||
| 95 | }, | ||
| 96 | "Action": [ | ||
| 97 | "kms:CreateGrant", | ||
| 98 | "kms:ListGrants", | ||
| 99 | "kms:RevokeGrant" | ||
| 100 | ], | ||
| 101 | "Resource": "*", | ||
| 102 | "Condition": { | ||
| 103 | "Bool": { | ||
| 104 | "kms:GrantIsForAWSResource": "true" | ||
| 105 | } | ||
| 106 | } | ||
| 107 | } | ||
| 108 | ] | ||
| 109 | } | ||
| 110 | ', | ||
| 111 | 'PolicyName' => 'default' | ||
| 112 | ); | ||
| 113 | |||
| 114 | |||
| 115 | Values for attributes that are native types (Int, String, Float, etc) can passed as-is (scalar values). Values for complex Types (objects) can be passed as a HashRef. The keys and values of the hashref will be used to instance the underlying object. | ||
| 116 | For the AWS API documentation, see L<https://docs.aws.amazon.com/goto/WebAPI/kms/PutKeyPolicy> | ||
| 117 | |||
| 118 | =head1 ATTRIBUTES | ||
| 119 | |||
| 120 | |||
| 121 | =head2 BypassPolicyLockoutSafetyCheck => Bool | ||
| 122 | |||
| 123 | A flag to indicate whether to bypass the key policy lockout safety | ||
| 124 | check. | ||
| 125 | |||
| 126 | Setting this value to true increases the risk that the CMK becomes | ||
| 127 | unmanageable. Do not set this value to true indiscriminately. | ||
| 128 | |||
| 129 | For more information, refer to the scenario in the Default Key Policy | ||
| 130 | (https://docs.aws.amazon.com/kms/latest/developerguide/key-policies.html#key-policy-default-allow-root-enable-iam) | ||
| 131 | section in the I<AWS Key Management Service Developer Guide>. | ||
| 132 | |||
| 133 | Use this parameter only when you intend to prevent the principal that | ||
| 134 | is making the request from making a subsequent C<PutKeyPolicy> request | ||
| 135 | on the CMK. | ||
| 136 | |||
| 137 | The default value is false. | ||
| 138 | |||
| 139 | |||
| 140 | |||
| 141 | =head2 B<REQUIRED> KeyId => Str | ||
| 142 | |||
| 143 | Sets the key policy on the specified customer master key (CMK). | ||
| 144 | |||
| 145 | Specify the key ID or key ARN of the CMK. | ||
| 146 | |||
| 147 | For example: | ||
| 148 | |||
| 149 | =over | ||
| 150 | |||
| 151 | =item * | ||
| 152 | |||
| 153 | Key ID: C<1234abcd-12ab-34cd-56ef-1234567890ab> | ||
| 154 | |||
| 155 | =item * | ||
| 156 | |||
| 157 | Key ARN: | ||
| 158 | C<arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab> | ||
| 159 | |||
| 160 | =back | ||
| 161 | |||
| 162 | To get the key ID and key ARN for a CMK, use ListKeys or DescribeKey. | ||
| 163 | |||
| 164 | |||
| 165 | |||
| 166 | =head2 B<REQUIRED> Policy => Str | ||
| 167 | |||
| 168 | The key policy to attach to the CMK. | ||
| 169 | |||
| 170 | The key policy must meet the following criteria: | ||
| 171 | |||
| 172 | =over | ||
| 173 | |||
| 174 | =item * | ||
| 175 | |||
| 176 | If you don't set C<BypassPolicyLockoutSafetyCheck> to true, the key | ||
| 177 | policy must allow the principal that is making the C<PutKeyPolicy> | ||
| 178 | request to make a subsequent C<PutKeyPolicy> request on the CMK. This | ||
| 179 | reduces the risk that the CMK becomes unmanageable. For more | ||
| 180 | information, refer to the scenario in the Default Key Policy | ||
| 181 | (https://docs.aws.amazon.com/kms/latest/developerguide/key-policies.html#key-policy-default-allow-root-enable-iam) | ||
| 182 | section of the I<AWS Key Management Service Developer Guide>. | ||
| 183 | |||
| 184 | =item * | ||
| 185 | |||
| 186 | Each statement in the key policy must contain one or more principals. | ||
| 187 | The principals in the key policy must exist and be visible to AWS KMS. | ||
| 188 | When you create a new AWS principal (for example, an IAM user or role), | ||
| 189 | you might need to enforce a delay before including the new principal in | ||
| 190 | a key policy because the new principal might not be immediately visible | ||
| 191 | to AWS KMS. For more information, see Changes that I make are not | ||
| 192 | always immediately visible | ||
| 193 | (https://docs.aws.amazon.com/IAM/latest/UserGuide/troubleshoot_general.html#troubleshoot_general_eventual-consistency) | ||
| 194 | in the I<AWS Identity and Access Management User Guide>. | ||
| 195 | |||
| 196 | =back | ||
| 197 | |||
| 198 | The key policy cannot exceed 32 kilobytes (32768 bytes). For more | ||
| 199 | information, see Resource Quotas | ||
| 200 | (https://docs.aws.amazon.com/kms/latest/developerguide/resource-limits.html) | ||
| 201 | in the I<AWS Key Management Service Developer Guide>. | ||
| 202 | |||
| 203 | |||
| 204 | |||
| 205 | =head2 B<REQUIRED> PolicyName => Str | ||
| 206 | |||
| 207 | The name of the key policy. The only valid value is C<default>. | ||
| 208 | |||
| 209 | |||
| 210 | |||
| 211 | |||
| 212 | =head1 SEE ALSO | ||
| 213 | |||
| 214 | This class forms part of L<Paws>, documenting arguments for method PutKeyPolicy in L<Paws::KMS> | ||
| 215 | |||
| 216 | =head1 BUGS and CONTRIBUTIONS | ||
| 217 | |||
| 218 | The source code is located here: L<https://github.com/pplu/aws-sdk-perl> | ||
| 219 | |||
| 220 | Please report bugs to: L<https://github.com/pplu/aws-sdk-perl/issues> | ||
| 221 | |||
| 222 | =cut | ||
| 223 |