I"m trying to avoid hard coding AWS 'KMS key' in a python application running on AWS EC2 instance. The AWS EC2 instance is assigned with an IAM role where access to the particular KMS key is defined. The instance doesnt have access to list all the KMS keys in the account but have access to only one. Is there any way to get the KMS key name, to which it have access from the application(using boto3?) The KMS Key IAM role definition look like this:
"Action": [
"kms:Decrypt",
"kms:DescribeKey",
"kms:Encrypt",
"kms:GenerateDataKey",
"kms:GenerateDataKeyWithoutPlaintext",
"kms:GetKeyPolicy",
"kms:GetKeyRotationStatus",
"kms:GetParametersForImport",
"kms:ListAliases",
"kms:ListGrants",
"kms:ListKeyPolicies",
"kms:ListKeys",
"kms:ListResourceTags",
"kms:ListRetirableGrants"
],
"Resource": [
"arn:aws:kms:xx-xxxx-x:xxxxxxxx:key/yyyy-yyy-yyyy-yyyy-yyyy"
]