Skip to content

ApiKey

Source: src/AWS/Location/ApiKey.ts

An Amazon Location Service API key. API keys authorize unsigned requests (e.g. map tiles rendered directly in a browser) to a restricted set of Location actions and resources. The key name is immutable; restrictions, description, and expiry can be updated in place.

The key attribute is the secret key value (v1.public.…) clients pass as the key query parameter; it is wrapped in Redacted.

Availability: Amazon Location classic (V1) is closed to newer AWS accounts — geo:CreateKey is rejected service-side with an AccessDeniedException regardless of IAM policy. Accounts onboarded to Location before the V2 split can create keys normally.

Map-Rendering Key for Browsers

import * as Location from "alchemy/AWS/Location";
const map = yield* Location.Map("SiteMap", {
configuration: { style: "VectorEsriStreets" },
});
const key = yield* Location.ApiKey("SiteMapKey", {
restrictions: {
allowActions: ["geo:GetMap*"],
allowResources: [map.mapArn],
},
});
// Redacted.value(key.key) → "v1.public.…" — append as ?key=… to tile URLs

Key with Referer Restrictions and Expiry

const key = yield* Location.ApiKey("WebKey", {
restrictions: {
allowActions: ["geo:GetMap*"],
allowResources: ["arn:aws:geo:*:*:map/*"],
allowReferers: ["https://example.com/*"],
},
expireTime: "2027-01-01T00:00:00Z",
});