I have in my AWS Secrets Manager a few keys that need to be accessed from a EC2 instance using the command :
aws secretsmanager get-secret-value --secret-id Test/Dev-key
I have created a IAM user that will only be used for this purpose and created a IAM group to apply the SecretManagerPolicy that I created. I want to this user to only have access to the key having Test/
in their names. So here is the policy I've made :
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": "secretsmanager:*",
"Resource": "arn:aws:secretsmanager:*:*:secret:Test/*"
}
]
}
My user cannot access to any keys or list them. If I replace the Resource field with the full arn of a secret I can list all of them.
I also tried to add a condition using tags but I still can list secrets without the tag.
It's either I can access all secrets or none.