-2

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?

DragonKnight
  • 1,740
  • 2
  • 22
  • 35
  • 2
    Well, you can do that by using `terraform import` command. You are looking for this in particular: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role#import. – Marko E Aug 24 '22 at 06:52

3 Answers3

1

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.

Marcin
  • 215,873
  • 14
  • 235
  • 294
0

To work with resources already existing use data-sources: https://www.terraform.io/language/data-sources

Erik Asplund
  • 673
  • 4
  • 14
0

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

DragonKnight
  • 1,740
  • 2
  • 22
  • 35