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

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.

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

1 Like

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 🇺🇦

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…

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

1 Like