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
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
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)