I am trying to attach an existing role created in AWS, but I am not able to add it in Terraform Code. I tried to add the role in instance profile but it didn't work either for me.

Is there any direct way to add it in the resource in Terraform Code ?

iam_instance_profile = "my-role"

Note: my-role is having the full access of ec2.

  • 2
    What error message do you get? – Philipp Claßen May 2 '18 at 0:41
  • That should work, but like @PhilippClaßen said, without knowing what happened it's near impossible to help you out with this. – Tim Malone Jun 17 '18 at 2:49

you can add role like below

role = "${aws_iam_role.ec2_role_name.name}"

Please check - https://www.terraform.io/docs/providers/aws/r/iam_instance_profile.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.