amazon-web-servicespermissionscommand-line-interfaceaws-resource-explorer

UnauthorizedError when using resource-explorer-2 search operation


I created a resource explorer index in us-east-2 with this command:

aws resource-explorer-2 create-index --region us-east-2

I verified it was ready:

aws resource-explorer-2 get-index --region us-east-2

{
    "Arn": "arn:aws:resource-explorer-2:us-east-2:123456123456:index/c8a3afa7-aca7-4d74-a5d9-7bef74385371",
    "CreatedAt": "2025-02-08T18:53:50.523000+00:00",
    "LastUpdatedAt": "2025-02-08T18:53:50.523000+00:00",
    "ReplicatingTo": [],
    "State": "ACTIVE",
    "Tags": {},
    "Type": "LOCAL"
}

When I try to search against the index, I get an UnauthorizedException

aws resource-explorer-2 search --query-string "*" --region us-east-2

An error occurred (UnauthorizedException) when calling the Search operation: Unauthorized

My user already had an AdministratorAccess policy attached to it, which should allow searching. Just in case I also added AWSResourceExplorerFullAccess to the user, which did not fix it.

Why am I getting UnauthorizedExceptions searching for resources in an index I created?


Solution

  • That error is generated because the default --view-arn is not set in us-east-2 (check the description of --value-arn in https://awscli.amazonaws.com/v2/documentation/api/latest/reference/resource-explorer-2/search.html).

    You need to create a default view in us-east-2 (https://docs.aws.amazon.com/resource-explorer/latest/userguide/configure-views-set-default.html).