/** * Adopt a Terraform-managed resource into chant source from its `.tfstate` * (#1009). This is the correct adoption source for carving OUT of Terraform: * a TF resource is created through the provider API, not CloudFormation, so it * is not in any CFN stack — but its resolved attributes ARE in the state file. * * chant AWS constructors take CloudFormation PascalCase properties (e.g. * `new Bucket({ BucketName })`), while Terraform state uses the provider's * snake_case attributes (`bucket`, `tags`). The mapping is driven by the single * AWS carve-out table (`aws-resources.ts`) — the same table the advisor's tier * map derives from, so every AWS type advise ranks can be emitted. Attributes * without a mapping are preserved in a reference comment, never dropped. * * Deferred outbound inputs (#998): an attribute whose value the Terraform * source read from a survivor (`vpc_id = aws_vpc.main.id`) is not a fact of * the carved resource — it is a deploy-time input. Those props are emitted as * `params.` references instead of frozen literals, with the state's * resolved value as the declared default (see `carve-emit.ts`'s scaffold). */ import type { StateResource } from "./state.js"; /** The core subpath the emitted source reads build parameters from. */ export declare const PARAMS_IMPORT = "@intentius/chant/params"; /** * One deferred outbound input turned into a build parameter (#998). Derived * from the boundary report's outbound edges + the state's resolved attributes * in `carve-emit.ts`; consumed here (source substitution) and by the scaffold * (`chant.config.ts` `buildParams` declaration). */ export interface DeferredParam { /** Build-parameter name, source-referenceable (`params.`). */ name: string; /** The carved resource's own Terraform attribute the value enters through. */ tfAttr: string; /** The survivor the Terraform source read, e.g. `aws_vpc.main`. */ survivor: string; /** Survivor attribute(s) read, e.g. `["id"]`. */ attrs: string[]; /** The state-resolved value — the parameter's declared default. */ default?: string | number | boolean; } /** What one folded sub-resource contributed to the parent's emitted props (#1637). */ export interface FoldedContribution { /** The sub-resource's Terraform address, e.g. `aws_s3_bucket_versioning.assets`. */ address: string; /** CFN properties it added to the parent, e.g. `["VersioningConfiguration"]`. */ props: string[]; } export interface AdoptedSource { fileName: string; content: string; /** True when at least one attribute was mapped to a native prop. */ mapped: boolean; nativeType: string; /** Deferred params actually substituted into the emitted props (#998). */ parameterized: string[]; /** Folded sub-resources and the props each one joined into the parent (#1637). */ folded: FoldedContribution[]; } /** Is this Terraform type adoptable from state (has a native constructor)? */ export declare function canAdoptFromState(tfType: string): boolean; /** Terraform types that can currently be adopted from state, for user-facing hints. */ export declare function supportedStateAdoptionTypes(): string[]; /** * Render chant source for a state-adopted resource. Emits the native * constructor with mapped properties, plus a reference comment listing the * Terraform attributes that were not mapped so nothing is silently dropped. * * A mapped attribute named by a `DeferredParam` renders as a `params.` * reference (a real chant build parameter) instead of the state literal — * the value came from a survivor, so it stays overridable per build. * * `folded` carries the carve set's sub-resources (`aws_s3_bucket_versioning` * and friends), read from the same state file. Their mappable attributes join * the parent's props (#1637) — a fold that only announced itself and left the * emitted resource without the versioning or public-access block the Terraform * declared was a silent loss of configuration. A sub-resource's setting wins * over the parent's own legacy in-state block: it is the one the config * actually declares. */ export declare function adoptFromState(resource: StateResource, params?: DeferredParam[], folded?: StateResource[]): AdoptedSource | null; //# sourceMappingURL=adopt-state.d.ts.map