AWS Quicksight has a built in default role aws-quicksight-service-role-v0
which does not have any policy attached to it. Knowing its ARN, I want to attach policies to the role via terraform. How can I achieve this?
In other words, how can I import a manually/automatically created resource outside terraform, into terraform?
Question posted in Amazon Web Sevices
The official Amazon Web Services documentation can be found here.
The official Amazon Web Services documentation can be found here.
3
Answers
In my particular case, the below reference helped to pick the role by name and attach needed policies to it. As explained it works per policy, meaning you need to pick one policy at a time and attach it to as many roles or users you want. https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment
To work with resources already existing use data-sources:
https://www.terraform.io/language/data-sources
If you just want to add a new policy to an existing IAM role and you know its ARN, you don’t have to import it. You can just use aws_iam_role_policy to define and add the policy that you want to pre-existing role.