- Newest
- Most votes
- Most comments
You'll have to permit access to kms:Decrypt and kms:GenerateDataKey (without the wildcard) also in the policies attached to the IAM role.
KMS is one of the two exceptions to the general intra-account policy evaluation rules in that it requires access to be permitted explicitly to the role, either by referencing the role ARN explicitly in the key policy, or permitting access more generally in both the identity-based policies and the key policy.
If you're doing this with CloudFormation, you can declare an IAM policy such as the one shown below (with the proper parameters substituted) and attach it to the IAM role by referencing KmsAccessPolicy in the ManagedPolicyArns property of the AWS::IAM::Role in your template. This example assumes that your S3 bucket is using the bucket key feature, as most buckets are:
KmsAccessPolicy:
Type: 'AWS::IAM::ManagedPolicy'
Properties:
Description: 'Permissions policy for KMS access by DeploymentRole'
PolicyDocument:
Version: '2012-10-17'
Statement:
- Sid: 'AllowKmsAccess'
Effect: 'Allow'
Action: ['kms:Decrypt','kms:GenerateDataKey']
Resource: !Ref KmsKeyArn
Condition:
StringEquals:
'kms:ViaService': !Sub 's3.${AWS::Region}.amazonaws.com'
'kms:EncryptionContext:aws:s3:arn': !Sub '${S3Bucket.Arn}'
Thanks Leo K, it also turned out that i didn't also configure the pipeline Articat store Encryption Key with KMS
EncryptionKey: {"Type": KMS, "Id": !Ref KMSKeyARN }
For the same account:
- If you allowed the root in the principal section of the KMS policy. Then, you would need to grant access via the IAM policy as well. You can attach the KMS related actions to the role as IAM policy who is accessing the KMS key
OR
2.You can directly allow the IAM role who is accessing the KMS key in the principal section of the KMS policy.
Thanks Ankita , it also turned out that i didn't also configure the pipeline Articat store Encryption Key with KMS
EncryptionKey: {"Type": KMS, "Id": !Ref KMSKeyARN }
We were not setting the KMS encryption key so the default was being used. If your attempting to access cross-account, then the keys won't match. So, adding the EncryptionKey property on the CodePipeline ensures your using the same key cross-account for artifact push/pull activity:
Relevant content
- asked 3 years ago

Can you show me Pls how i can achieve this Thanks
Thanks, it also turned out that i didn't also configure the pipeline Articat store Encryption Key with KMS
EncryptionKey: {"Type": KMS, "Id": !Ref KMSKeyARN }