Amplify Toolbox
    Preparing search index...
    • Resolve a secret (AWS Secrets Manager) at runtime.

      Local development. Reads process.env.KEY first, so a .env file supplies the value with no AWS call. On a deployed function it falls through to fetching the wired secret from Secrets Manager.

      Type safety. key is typed as SecretKey: by default any string, but once you run npm run typegen (which generates a .d.ts augmenting HostingSecretRegistry from your secret('...') calls) it narrows to your declared keys — autocomplete, and a typo is a compile error. When you declared a schema (secret('K', { schema })), the return type is the schema's inferred output and the value is JSON-parsed at runtime; otherwise it is string.

      Type Parameters

      • K extends string

      Parameters

      • key: K

        The logical name, exactly as passed to secret('<key>').

      Returns Promise<string>

      The value — parsed to the schema's type when a schema was declared, else the decrypted string.

      If the key is neither in process.env nor backed by an injected locator.