Các tài nguyên có thể liên kết với AWS KMS thông qua VPC private Endpoint. Một VPC enpoints giúp bạn kết nối VPC của mình tới các dịch vụ AWS khác một cách private, và các dịch vụ VPC endpoints cung cấp bởi PrivateLink sẽ không cần tới Internet gateway, NAT device, VPN connection, hay AWS Direct Connect connection.
aws kms list-keys --endpoint-url <the KMS VPC Endpoint url>
{
"Version": "2012-10-17",
"Id": "key-default-1",
"Statement": [
{
"Sid": "Enable IAM User Permissions",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::<your acount id>:root"
},
"Action": "kms:*",
"Resource": "*"
},
{
"Sid": "Allow for Use only within our VPC",
"Effect": "Deny",
"Principal": {
"AWS": "arn:aws:iam::<your acount id>:role/KMSWorkshop-InstanceInitRole"
},
"Action": [
"kms:Encrypt",
"kms:Decrypt",
"kms:ReEncrypt*",
"kms:GenerateDataKey*"
],
"Resource": "*",
"Condition": {
"StringNotEquals": {
"aws:sourceVpce": "<the id of the KMS VPC Endpoint>"
}
}
}
]
}