Terraform plan is failing with Error: EC2RoleRequestError: no EC2 instance role found

Terraform v0.12.28
aws provider version is 3.37
credential_source=Ec2InstanceMetadata with asume role.

terraform plan is failing with below error after upgrading the aws provider version from 2.x to 3.37.

on db-terraform/stacks/rds-aurora/main.tf line 9, in provider “aws”:
9: provider “aws” {

Error: error configuring Terraform AWS Provider: no valid credential sources for Terraform AWS Provider found.

Please see https://registry.terraform.io/providers/hashicorp/aws
for more information about providing credentials.

Error: EC2RoleRequestError: no EC2 instance role found
caused by: MissingEndpoint: ‘Endpoint’ configuration is required for this service