buildKeyedRecord
buildKeyedRecord<
Keys extends readonly string[],
>(
keys: Keys,
): number extends Keys['length'] ? Partial<KeyedRecord<Keys[number]>> : KeyedRecord<Keys[number]>Converts stable string keys into a keyed component-input record.
Remarks
Use this helper when a component models repeated resources as a keyed record for stable Pulumi identity but no per-key configuration is required. Input order is preserved in the returned object's property order, although component identity must depend on the keys rather than order. Duplicate keys are rejected rather than silently collapsed. Literal tuples preserve their exact required keys in the return type; widened arrays return a partial record because their runtime contents cannot prove that every possible key is present.
Type Parameters
Keysextendsreadonly string[]
Parameters
keys(Keys) — Stable keys for the component collection.
Returns
number extends Keys["length"] ? Partial<KeyedRecord<Keys[number]>> :KeyedRecord<Keys[number]>— A new object containing every input key with an empty configuration object.
Example
CODE
import { AwsAccountDefaults } from '@jobcloud/aws-account-defaults';
import { buildKeyedRecord } from '@jobcloud/pulumi-helpers';
const defaults = new AwsAccountDefaults({
identity: 'account-defaults',
serverlessDeploymentRole: {
regions: buildKeyedRecord(['eu-west-1', 'eu-central-1']),
policyDocument: { path: 'policies/serverless-deployment.json' },
},
});