Facing issue while importing existing aws_iam_role_policy attached with role

i am trying to import the existing iam inline policy attached to the role but getting below error

While attempting to import an existing object to
aws_iam_role_policy.aws_load_balancer_controller, the provider detected that
no object exists with the given id. Only pre-existing objects can be imported;
check that the id is correct and that it is associated with the provider's
configured region or endpoint, or use "terraform apply" to create a new remote
object for this resource.

Releasing state lock. This may take a few moments...
ERRO[0047] 1 error occurred:
	* exit status 1

Note : i am using provider 4.61.0 and terraform version 0.14.5

It would be great if some one could help on this.

The error message is fairly clear? You told it to import something, but the thing you told it to import does not exist according to the AWS API.

You should show your terraform import command, so that people here can confirm it looks correct.

You should check that you’re actually connecting to AWS using the correct account.

Separately, unrelated to the direct issue asked about, you really should upgrade to Terraform 1.x - 0.14 is new enough that it should be relatively easy to do so, whilst being old enough to predate the 1.x compatibility promise, so there is very little reason to remain on it, and lots of reason to upgrade.

@maxb thanks for the input…here is the complete import command…the additional information here is that we are using terragrunt

 terragrunt import aws_iam_role_policy.aws_load_balancer_controller cp-sw-ore-nonprod-aws-load-balancer-controller:cp-sw-ore-nonprod-alb-management
WARN[0039] No double-slash (//) found in source URL /koralkloud/tg-module-eks.git. Relative paths in downloaded Terraform code may not work. 
aws_iam_role_policy.aws_load_balancer_controller: Importing from ID "cp-sw-ore-nonprod-aws-load-balancer-controller:cp-sw-ore-nonprod-alb-management"...
aws_iam_role_policy.aws_load_balancer_controller: Import prepared!
  Prepared aws_iam_role_policy for import
aws_iam_role_policy.aws_load_balancer_controller: Refreshing state... [id=cp-sw-ore-nonprod-aws-load-balancer-controller:cp-sw-ore-nonprod-alb-management]

Error: Cannot import non-existent remote object

While attempting to import an existing object to
aws_iam_role_policy.aws_load_balancer_controller, the provider detected that
no object exists with the given id. Only pre-existing objects can be imported;
check that the id is correct and that it is associated with the provider's
configured region or endpoint, or use "terraform apply" to create a new remote
object for this resource.

Releasing state lock. This may take a few moments...
ERRO[0047] 1 error occurred:
	* exit status 1
          

i also found some open issue associated to the one i am facing in github import aws_iam_role_police doesn't work · Issue #10145 · hashicorp/terraform-provider-aws · GitHub. I am not sure its somthing terraform to deal with

Ah, that does make it look like a bug in terraform-provider-aws, then.

@rshevchenko-getcider does your role also have a path after /role in the ARN? Just to rule out other possibilities.

@macmiranda here is the ARN of the existing Role…

arn:aws:iam::3333333222111:role/koralkloud-sw-ore-nonprod-aws-load-balancer-controller

For one thing, the name of the role in the import command is wrong

sorry i wrongly pasted the role name
cp-sw-ore-nonprod-aws-load-balancer-controller this is the right role name

Can you share the ARN of the role policy too?

This really just looks to me like a wrong import ID reference.

But you can also set TF_LOG_PROVIDER_AWS env variable to DEBUG and post the output of the import command here (be careful with sensitive values). Because the output is very long you should paste a link to the file (hosted somewhere else like Github Gists)