Skip to content

AWS.ResourceExplorer reference

Source: src/AWS/ResourceExplorer/ExplorerIndex.ts

An AWS Resource Explorer index — the region singleton that turns on resource indexing so resources in the region can be searched.

Only one index can exist per region, so this is a capture-and-restore singleton: adopting an index that Alchemy did not create requires --adopt (ownership is tracked through the index’s tags), and destroy turns Resource Explorer off for the region (deleting every view in it).

The first index created in an account also creates the AWSServiceRoleForResourceExplorer service-linked role.

Local index

const index = yield* AWS.ResourceExplorer.Index("Index", {});

Aggregator index for cross-region search

const index = yield* AWS.ResourceExplorer.Index("Index", {
type: "AGGREGATOR",
});

Search always goes through a view — see AWS.ResourceExplorer.View and the AWS.ResourceExplorer.Search binding.

Source: src/AWS/ResourceExplorer/ListResources.ts

Runtime binding for resource-explorer-2:ListResources.

Enumerates the resources visible through the bound View using a structured filter (instead of Search’s free-form query string) — the building block of inventory automation: page through every resource the view exposes and act on each one. The view’s ARN is injected from the binding. Provide the implementation with Effect.provide(AWS.ResourceExplorer.ListResourcesHttp).

// init — bind the operation to the view
const listResources = yield* AWS.ResourceExplorer.ListResources(view);
// runtime
const page = yield* listResources({
Filters: { FilterString: "service:s3" },
MaxResults: 100,
});
for (const resource of page.Resources ?? []) {
yield* Effect.log(`${resource.ResourceType}: ${resource.Arn}`);
}

Source: src/AWS/ResourceExplorer/ListSupportedResourceTypes.ts

Runtime binding for resource-explorer-2:ListSupportedResourceTypes.

Enumerates the resource types Resource Explorer can index and search — the discovery half of query-building: validate a service:/resourcetype: filter before searching, or drive a resource-type picker. Account-level operation, so the binding takes no resource argument. Provide the implementation with Effect.provide(AWS.ResourceExplorer.ListSupportedResourceTypesHttp).

ListSupportedResourceTypes: Listing Resources

Section titled “ListSupportedResourceTypes: Listing Resources”
// init — account-level binding, no resource argument
const listSupportedResourceTypes =
yield* AWS.ResourceExplorer.ListSupportedResourceTypes();
// runtime
const { ResourceTypes } = yield* listSupportedResourceTypes();
const s3Types = (ResourceTypes ?? []).filter((t) => t.Service === "s3");

Source: src/AWS/ResourceExplorer/Search.ts

Runtime binding for resource-explorer-2:Search.

Bind this operation to a View inside a function runtime to get a callable that automatically injects the view’s ARN. Results are the intersection of the QueryString and the view’s filter. Provide the implementation with Effect.provide(AWS.ResourceExplorer.SearchHttp).

const search = yield* AWS.ResourceExplorer.Search(view);
const results = yield* search({
QueryString: "service:s3",
MaxResults: 50,
});
// results.Resources, results.Count?.TotalResources

Source: src/AWS/ResourceExplorer/View.ts

An AWS Resource Explorer view — a saved search lens with an optional filter and a set of included properties that Search queries run through.

Views require an active AWS.ResourceExplorer.Index in the region. When an index and a view deploy together, the view provider retries through the window where the index is still provisioning.

Unfiltered view over the whole account

const index = yield* AWS.ResourceExplorer.Index("Index", {});
const view = yield* AWS.ResourceExplorer.View("AllResources", {});

Filtered view with tags included in results

const view = yield* AWS.ResourceExplorer.View("S3Only", {
filterString: "service:s3",
includedProperties: ["tags"],
});
// init
const search = yield* AWS.ResourceExplorer.Search(view);
return {
fetch: Effect.gen(function* () {
// runtime
const results = yield* search({ QueryString: "service:s3" });
return HttpServerResponse.json({ count: results.Count });
}),
};