# \[terraform-aws-modules/terraform-aws-ec2-instance\] Attatch existent IAM role

**URL:** <https://discuss.hashicorp.com/t/terraform-aws-modules-terraform-aws-ec2-instance-attatch-existent-iam-role/49612>\
**Category:** Terraform\
**Created:** [February 1, 2023, 6:35pm UTC](https://discuss.hashicorp.com/t/terraform-aws-modules-terraform-aws-ec2-instance-attatch-existent-iam-role/49612 "2023-02-01T18:35:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![weyderfs](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/weyderfs/32/33576_2.png) [@weyderfs](https://discuss.hashicorp.com/u/weyderfs)\
**Post date:** [February 1, 2023, 6:35pm UTC](https://discuss.hashicorp.com/t/terraform-aws-modules-terraform-aws-ec2-instance-attatch-existent-iam-role/49612/1 "2023-02-01T18:35:19Z")

</div>

Guys,

Maybe I have been a “noobie”…

But I’m not found a way to attach a existent role to EC2 using the official [Terraform Module](https://github.com/terraform-aws-modules/terraform-aws-ec2-instance).

Someone know how workaround in this scenario? I just wanna deplaoy a new EC2 with attached existent IAM Role…

---

<div class="post-metadata">

**Author:** ![stuart-c](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/stuart-c/32/10789_2.png) [@stuart-c](https://discuss.hashicorp.com/u/stuart-c)\
**Post date:** [February 1, 2023, 6:57pm UTC](https://discuss.hashicorp.com/t/terraform-aws-modules-terraform-aws-ec2-instance-attatch-existent-iam-role/49612/2 "2023-02-01T18:57:54Z")

</div>

The module has an attribute to allow you to attach an instance profile: [GitHub - terraform-aws-modules/terraform-aws-ec2-instance: Terraform module which creates EC2 instance(s) on AWS 🇺🇦](https://github.com/terraform-aws-modules/terraform-aws-ec2-instance#input_iam_instance_profile)

---

<div class="post-metadata">

**Author:** ![weyderfs](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/weyderfs/32/33576_2.png) [@weyderfs](https://discuss.hashicorp.com/u/weyderfs)\
**Post date:** [February 1, 2023, 7:40pm UTC](https://discuss.hashicorp.com/t/terraform-aws-modules-terraform-aws-ec2-instance-attatch-existent-iam-role/49612/3 "2023-02-01T19:40:24Z")

</div>

```auto
Error: creating EC2 Instance: InvalidParameterValue: Value (arn:aws:iam::1234567890:instance-profile/ec2-xxxxxxx) for parameter iamInstanceProfile.name is invalid. Invalid IAM Instance Profile name

```

I’ve tried with:

- IAM ROLE ARN
- IAM ROLE PROFILE

And returns the same error above…

---

<div class="post-metadata">

**Author:** ![weyderfs](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/weyderfs/32/33576_2.png) [@weyderfs](https://discuss.hashicorp.com/u/weyderfs)\
**Post date:** [February 1, 2023, 8:17pm UTC](https://discuss.hashicorp.com/t/terraform-aws-modules-terraform-aws-ec2-instance-attatch-existent-iam-role/49612/4 "2023-02-01T20:17:11Z")

</div>

I’ve solved. The parâmeter: `iam_instance_profile` expects exactly the role **name**. Normally the resources waiting for **ARN**.
