ResourceDeclaration class
Shared base for resource declaration implementations.
- Extends
Remarks
Both represent one Bicep resource declaration in the component tree and
share the same declaration-level state layout: identity fields
(type, apiVersion, existing), the if(...) guard (condition),
the optional cross-scope reference (scope), and the raw prop bag that
becomes the resource body.
This class owns the common declaration state layout, raw-handle escape hatch, and identity accessors. Subclasses supply their construction and access behavior.
Constructors
| Resource |
Base constructor for every Bicep resource declaration. |
Properties
| api |
|
| condition | |
| depends |
|
| deployment |
The effective deployment context inherited from ancestors, resolved by walking up the parent chain (this node's own local contribution is intentionally excluded — a node's contribution flows to its descendants, not to itself). Each field is resolved per its own rule:
Returns an object whose fields may all be |
| existing | |
| self | Public identity for this node. |
| type | |
| [RESOURCE_DECLARATION_BRAND] | Brand marker for cross-realm |
Inherited Methods
| is |
|
| transform((component: Provisioning |
Applies a callback to every descendant component/resource that matches the
given constructor, including |
| transform<TComponent>(Provisioning |
|
| visit((component: Provisioning |
Depth-first visit of this node and all descendants.
Return |
Constructor Details
ResourceDeclaration<TType>(ProvisioningComponent, ResourceProps<TType> & Record<string, unknown>, ResourceOptions, ResourceNamingRules)
Base constructor for every Bicep resource declaration.
new ResourceDeclaration(context: ProvisioningComponent, props: ResourceProps<TType> & Record<string, unknown>, options?: ResourceOptions, namingRules?: ResourceNamingRules)
Parameters
- context
- ProvisioningComponent
- props
-
ResourceProps<TType> & Record<string, unknown>
- options
- ResourceOptions
- namingRules
- ResourceNamingRules
per-resource-type constraints for the naming
policy. Resource reads this reflectively off the concrete subclass
constructor; internal declaration implementations receive it from
the concrete resource constructor they represent.
Remarks
Responsibilities:
- Register in the component tree (
super(context)). - Enforce a deployment context ancestor.
- Unwrap
contextif it's an indexed proxy from.at(i)/parent.at(loop.index), and stashparentIndexonstateso the serializer can emitparent: parentSym[index]on the child. - Inherit
conditionfrom the immediate parent resource declaration when the caller doesn't supply one (Bicep requires children of a conditional resource to share the same guard). - Populate
state— existing arm records only identity fields; deployable arm runs the naming policy and appliesDeploymentContextdefaults forlocation/tagsper the shape descriptor.
Subclasses supply the last mile, including their public handle behavior.
Property Details
apiVersion
string apiVersion
Property Value
string
condition
ExpressionOrValue<boolean> | undefined condition
Property Value
ExpressionOrValue<boolean> | undefined
dependsOn
(readonly ResourceDeclaration<string>[]) | undefined dependsOn
Property Value
(readonly ResourceDeclaration<string>[]) | undefined
deploymentContext
The effective deployment context inherited from ancestors, resolved by walking up the parent chain (this node's own local contribution is intentionally excluded — a node's contribution flows to its descendants, not to itself). Each field is resolved per its own rule:
location: nearest ancestor with a value wins.namingPolicy: nearest ancestor with a value wins.tags: flat-merged across all ancestors; innermost wins on key conflict.
Returns an object whose fields may all be undefined if no ancestor
contributed anything.
DeploymentContext deploymentContext
Property Value
existing
boolean | undefined existing
Property Value
boolean | undefined
self
Public identity for this node.
this self
Property Value
this
type
TType type
Property Value
TType
[RESOURCE_DECLARATION_BRAND]
Brand marker for cross-realm isResourceDeclaration() checks. Uses
Symbol.for so it survives multiple copies of @azure/provisioning-core.
Inherited by every resource declaration implementation.
[RESOURCE_DECLARATION_BRAND]: true
Property Value
true
Inherited Property Details
children
parent
parent: ProvisioningComponent | undefined
Property Value
ProvisioningComponent | undefined
Inherited From ProvisioningComponent.parent
Inherited Method Details
isChildOf(ProvisioningComponent)
function isChildOf(component: ProvisioningComponent): boolean
Parameters
- component
- ProvisioningComponent
Returns
boolean
Inherited From ProvisioningComponent.isChildOf
transform((component: ProvisioningComponent) => void)
Applies a callback to every descendant component/resource that matches the
given constructor, including this when it matches.
function transform(callback: (component: ProvisioningComponent) => void): this
Parameters
- callback
-
(component: ProvisioningComponent) => void
Returns
this
Inherited From ProvisioningComponent.transform
transform<TComponent>(ProvisioningComponentConstructor<TComponent>, (component: TComponent) => void)
function transform<TComponent>(ctor: ProvisioningComponentConstructor<TComponent>, callback: (component: TComponent) => void): this
Parameters
- ctor
-
ProvisioningComponentConstructor<TComponent>
- callback
-
(component: TComponent) => void
Returns
this
Inherited From ProvisioningComponent.transform
visit((component: ProvisioningComponent) => boolean | void)
Depth-first visit of this node and all descendants.
Return false from the callback to skip visiting that node's children.
function visit(callback: (component: ProvisioningComponent) => boolean | void)
Parameters
- callback
-
(component: ProvisioningComponent) => boolean | void
Inherited From ProvisioningComponent.visit