Configuring aws provider using instance profile

Hi Guys,

I have configured a ec2 instance with an instance profile which does have all the required permissions. While executing planning I am getting following error.

│ Error: error configuring Terraform AWS Provider: IAM Role (arn:aws:iam::xxxxxx:instance-profile/automation_role) cannot be assumed.
│
│ There are a number of possible causes of this - the most common are:
│   * The credentials used in order to assume the role are invalid
│   * The credentials do not have appropriate permission to assume the role
│   * The role ARN is not valid
│
│ Error: NoCredentialProviders: no valid providers in chain. Deprecated.
│   For verbose messaging see aws.Config.CredentialsChainVerboseErrors
│
│
│   with provider["registry.terraform.io/hashicorp/aws"],
│   on provider.tf line 10, in provider "aws":
│   10: provider "aws" {

provider.tf

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "3.74.0"
    }
  }
}

provider "aws" {
  region  = "us-east-1"
  assume_role {
    role_arn = "arn:aws:iam::xxxxxx:instance-profile/automation_role"
    
  }
}

What is the changes required ?