I am using restricted roles for deploying resources via Cloudformation and have come across an error that threw me for a loop for some time.
I have a minimal role that I am using to create the resource. It only has the following allowed actions (On all resources)
rds:CreateDBSubnetGroup
ec2:DescribeVpcs
ec2:DescribeSubnets
ec2:DescribeAvailabilityZones
With the above actions, I am able to successfully create a DB Subnet Group with the following aws cli command:
aws rds create-db-subnet-group \
--db-subnet-group-name testing \
--db-subnet-group-description testing \
--subnet-ids "subnet-abc" "subnet-def"
However, if I leave out any one of those ec2 actions, then I get a rather misleading error when running the same command.
An error occurred (InvalidParameterValue) when calling the CreateDBSubnetGroup operation: Missing necessary credentials. Please check http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.IAM.ServiceLinkedRoles.html
This threw me down a long rabbit-hole of looking at service linked roles, which made no difference (Adding the action iam:CreateServiceLinkedRole did not stop the error). I eventually found the ec2 actions to add via trial and error and looking at CloudTrail. The error about using RDS with IAM Service Linked roles was completely misleading.
My question really is... Is my assessment of this scenario accurate, or am I missing something fundamental here?
It would not be so bad if it were not for the fact that I then ran in to the same error when creating the DB instance. Naturally I no longer trusted this error, so did not look at service linked roles. Spent a day searching down that rabbit hole that led nowhere - only to find that in this instance it WAS the service linked roles (Easy fix).