35
loading...
This website collects cookies to deliver better user experience
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"kms:Decrypt",
"kms:Encrypt",
"kms:GenerateDataKey*",
"kms:ReEncrypt*",
"kms:DescribeKey"
],
"Resource": "arn:aws:kms:[aws-region]:[account-id]:key/1234abcd-12ab-34cd-56ef-1234567890ab"
}
]
}
resource "aws_kms_key" "replication_s3_kms_key" {
description = "s3 encryption key"
}
resource "aws_kms_alias" "replication_s3_kms_alias" {
name = "alias/replication-s3-key"
target_key_id = aws_kms_key.replication_s3_kms_key.key_id
}
data "aws_iam_policy_document" "kms_policy" {
statement {
sid = "Enable IAM User Permissions"
effect = "Allow"
principals {
type = "AWS"
identifiers = [
"arn:aws:iam::${data.aws_caller_identity.current.account_id}:root"
]
}
actions = [
"kms:*"
]
resources = [
"*"
]
}
statement {
sid = "Allow use of the key"
effect = "Allow"
principals {
type = "AWS"
identifiers = [
"arn:aws:iam::<Replication role ARN>”
]
}
actions = [
"kms:Encrypt",
"kms:Decrypt",
"kms:ReEncrypt*",
"kms:GenerateDataKey*",
"kms:DescribeKey"
]
resources = [
"arn:aws:s3:::destination-test-replication"
]
}
}
resource "aws_kms_key" "replication_s3_kms_key" {
description = "s3 encryption key"
policy = data.aws_iam_policy_document.kms_policy.json
}
resource "aws_kms_alias" "replication_s3_kms_alias" {
name = "alias/replication-s3-key"
target_key_id = aws_kms_key.replication_s3_kms_key.key_id
}
Error: MalformedPolicyDocumentException: The new key policy will not allow you to update the key policy in the future.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"kms:Decrypt",
"kms:Encrypt",
"kms:GenerateDataKey*",
"kms:ReEncrypt*",
"kms:DescribeKey"
],
"Resource": "arn:aws:kms:us-east-2:<Source Account ID>:key/523b2035-e947-4c71-8690-db6b43589c34"
}
]
}