Terraform deleting instance profile

I am trying to provision an EMR cluster in AWS using terraform but getting error message after configuring my instance profile as below:

data "aws_iam_policy" "AmazonElasticMapReduceforEC2Role" {
  arn = "xxx/AmazonElasticMapReduceforEC2Role"
}


data "aws_iam_policy_document" "ec2-assume-role" {
  statement {
    effect = "Allow"

    principals {
      type        = "Service"
      identifiers = ["ec2.amazonaws.com"]
    }

    actions = ["sts:AssumeRole"]
  }
}


resource "aws_iam_role" "ec2-role" {
  name               = "EMR_EC2_DefaultRole"
  assume_role_policy = data.aws_iam_policy_document.ec2-assume-role.json
}


resource "aws_iam_role_policy_attachment" "attach-ec2-emr" {
  role       = aws_iam_role.ec2-role.name
  policy_arn = data.aws_iam_policy.AmazonElasticMapReduceforEC2Role.arn
}

resource "aws_iam_instance_profile" "profile" {
  name = "profileEc2"
  role = aws_iam_role.ec2-role.name
}

I keep on getting error:
‘’’
Error: deleting IAM Instance Profile (emr_profile): removing role (arn:aws:iam::xxx:role/xxx): ValidationError: The specified value for roleName is invalid. It must contain only alphanumeric characters and/or the following: +=,.@_-

│ status code: 400, request id: xxx
‘’’
even after i try deleting instance profile from the terraform.tfstate file it wouldnt let me.
Its an error that seems to be there no matter what I do.

Has anyone faced these challenges before? Any help will be welcomed

thanks

I think we’re missing a bit of the context here.
Why is Terraform attempting to remove that resource in the first place?