Skip to main content
The DataResource implements the standard resource lifecycle, but does not directly take any other actions. You can use the DataResource resource without requiring or configuring a provider. The DataResource resource is useful for storing values which need to follow a manage resource lifecycle, and for triggering provisioners when there is no other logical managed resource in which to place them. It requires Terraform 1.4 or later. It is also possible to generate these bindings by adding “terraform.io/builtin/terraform” to the “terraformProviders” key in your cdktf.json file and running “cdktn get”. https://developer.hashicorp.com/terraform/language/resources/terraform-data

Initializers

import { DataResource } from 'cdktn'

new DataResource(scope: Construct, id: string, config?: DataConfig)
NameTypeDescription
scopeconstructs.ConstructThe scope in which to define this construct.
idstringThe scoped construct ID.
configDataConfigNo description.

scopeRequired

  • Type: constructs.Construct
The scope in which to define this construct.

idRequired

  • Type: string
The scoped construct ID. Must be unique amongst siblings in the same scope

configOptional


Methods

NameDescription
toStringReturns a string representation of this construct.
addOverrideNo description.
overrideLogicalIdOverrides the auto-generated logical ID with a specific ID.
resetOverrideLogicalIdResets a previously passed logical Id to use the auto-generated logical id again.
toHclTerraformNo description.
toMetadataNo description.
toTerraformAdds this resource to the terraform JSON output.
addMoveTargetAdds a user defined moveTarget string to this resource to be later used in .moveTo(moveTarget) to resolve the location of the move.
getAnyMapAttributeNo description.
getBooleanAttributeNo description.
getBooleanMapAttributeNo description.
getListAttributeNo description.
getNumberAttributeNo description.
getNumberListAttributeNo description.
getNumberMapAttributeNo description.
getStringAttributeNo description.
getStringMapAttributeNo description.
hasResourceMoveNo description.
importFromNo description.
interpolationForAttributeNo description.
moveFromIdMove the resource corresponding to “id” to this resource.
moveToMoves this resource to the target resource given by moveTarget.
moveToIdMoves this resource to the resource corresponding to “id”.
resetInputNo description.
resetTriggersReplaceNo description.

toString

public toString(): string
Returns a string representation of this construct.

addOverride

public addOverride(path: string, value: any): void

pathRequired

  • Type: string

valueRequired

  • Type: any

overrideLogicalId

public overrideLogicalId(newLogicalId: string): void
Overrides the auto-generated logical ID with a specific ID.

newLogicalIdRequired

  • Type: string
The new logical ID to use for this stack element.

resetOverrideLogicalId

public resetOverrideLogicalId(): void
Resets a previously passed logical Id to use the auto-generated logical id again.

toHclTerraform

public toHclTerraform(): any

toMetadata

public toMetadata(): any

toTerraform

public toTerraform(): any
Adds this resource to the terraform JSON output.

addMoveTarget

public addMoveTarget(moveTarget: string): void
Adds a user defined moveTarget string to this resource to be later used in .moveTo(moveTarget) to resolve the location of the move.

moveTargetRequired

  • Type: string
The string move target that will correspond to this resource.

getAnyMapAttribute

public getAnyMapAttribute(terraformAttribute: string): {[ key: string ]: any}

terraformAttributeRequired

  • Type: string

getBooleanAttribute

public getBooleanAttribute(terraformAttribute: string): IResolvable

terraformAttributeRequired

  • Type: string

getBooleanMapAttribute

public getBooleanMapAttribute(terraformAttribute: string): {[ key: string ]: boolean}

terraformAttributeRequired

  • Type: string

getListAttribute

public getListAttribute(terraformAttribute: string): string[]

terraformAttributeRequired

  • Type: string

getNumberAttribute

public getNumberAttribute(terraformAttribute: string): number

terraformAttributeRequired

  • Type: string

getNumberListAttribute

public getNumberListAttribute(terraformAttribute: string): number[]

terraformAttributeRequired

  • Type: string

getNumberMapAttribute

public getNumberMapAttribute(terraformAttribute: string): {[ key: string ]: number}

terraformAttributeRequired

  • Type: string

getStringAttribute

public getStringAttribute(terraformAttribute: string): string

terraformAttributeRequired

  • Type: string

getStringMapAttribute

public getStringMapAttribute(terraformAttribute: string): {[ key: string ]: string}

terraformAttributeRequired

  • Type: string

hasResourceMove

public hasResourceMove(): TerraformResourceMoveByTarget | TerraformResourceMoveById

importFrom

public importFrom(id: string, provider?: TerraformProvider): void

idRequired

  • Type: string

providerOptional


interpolationForAttribute

public interpolationForAttribute(terraformAttribute: string): IResolvable

terraformAttributeRequired

  • Type: string

moveFromId

public moveFromId(id: string): void
Move the resource corresponding to “id” to this resource. Note that the resource being moved from must be marked as moved using it’s instance function.

idRequired

  • Type: string
Full id of resource being moved from, e.g. “aws_s3_bucket.example”.

moveTo

public moveTo(moveTarget: string, index?: string | number): void
Moves this resource to the target resource given by moveTarget.

moveTargetRequired

  • Type: string
The previously set user defined string set by .addMoveTarget() corresponding to the resource to move to.

indexOptional

  • Type: string | number
Optional The index corresponding to the key the resource is to appear in the foreach of a resource to move to.

moveToId

public moveToId(id: string): void
Moves this resource to the resource corresponding to “id”.

idRequired

  • Type: string
Full id of resource to move to, e.g. “aws_s3_bucket.example”.

resetInput

public resetInput(): void

resetTriggersReplace

public resetTriggersReplace(): void

Static Functions

NameDescription
isConstructChecks if x is a construct.
isTerraformElementNo description.
isTerraformResourceNo description.
generateConfigForImportGenerates CDKTN code for importing a Data resource upon running “cdktn plan < stack-name >”.

isConstruct

import { DataResource } from 'cdktn'

DataResource.isConstruct(x: any)
Checks if x is a construct. Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked. Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired

  • Type: any
Any object.

isTerraformElement

import { DataResource } from 'cdktn'

DataResource.isTerraformElement(x: any)

xRequired

  • Type: any

isTerraformResource

import { DataResource } from 'cdktn'

DataResource.isTerraformResource(x: any)

xRequired

  • Type: any

generateConfigForImport

import { DataResource } from 'cdktn'

DataResource.generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: TerraformProvider)
Generates CDKTN code for importing a Data resource upon running “cdktn plan < stack-name >”.

scopeRequired

  • Type: constructs.Construct
The scope in which to define this construct.

importToIdRequired

  • Type: string
The construct id used in the generated config for the Data to import.

importFromIdRequired

  • Type: string
The id of the existing Data that should be imported. Refer to the import section in the documentation of this resource for the id to use

providerOptional

? Optional instance of the provider where the Data to import is found.

Properties

NameTypeDescription
nodeconstructs.NodeThe tree node.
cdktfStackTerraformStackNo description.
fqnstringNo description.
friendlyUniqueIdstringNo description.
terraformMetaArguments{[ key: string ]: any}No description.
terraformResourceTypestringNo description.
terraformGeneratorMetadataTerraformProviderGeneratorMetadataNo description.
connectionSSHProvisionerConnection | WinrmProvisionerConnectionNo description.
countnumber | TerraformCountNo description.
dependsOnstring[]No description.
forEachITerraformIteratorNo description.
lifecycleTerraformResourceLifecycleNo description.
providerTerraformProviderNo description.
provisionersFileProvisioner | LocalExecProvisioner | RemoteExecProvisioner[]No description.
idstringNo description.
outputAnyMapNo description.
inputInput{[ key: string ]: any}No description.
triggersReplaceInput{[ key: string ]: any}No description.
input{[ key: string ]: any}(Optional) A value which will be stored in the instance state, and reflected in the output attribute after apply.
triggersReplace{[ key: string ]: any}(Optional) A value which is stored in the instance state, and will force replacement when the value changes.

nodeRequired

public readonly node: Node;
  • Type: constructs.Node
The tree node.

cdktfStackRequired

public readonly cdktfStack: TerraformStack;

fqnRequired

public readonly fqn: string;
  • Type: string

friendlyUniqueIdRequired

public readonly friendlyUniqueId: string;
  • Type: string

terraformMetaArgumentsRequired

public readonly terraformMetaArguments: {[ key: string ]: any};
  • Type: {[ key: string ]: any}

terraformResourceTypeRequired

public readonly terraformResourceType: string;
  • Type: string

terraformGeneratorMetadataOptional

public readonly terraformGeneratorMetadata: TerraformProviderGeneratorMetadata;

connectionOptional

public readonly connection: SSHProvisionerConnection | WinrmProvisionerConnection;

countOptional

public readonly count: number | TerraformCount;

dependsOnOptional

public readonly dependsOn: string[];
  • Type: string[]

forEachOptional

public readonly forEach: ITerraformIterator;

lifecycleOptional

public readonly lifecycle: TerraformResourceLifecycle;

providerOptional

public readonly provider: TerraformProvider;

provisionersOptional

public readonly provisioners: (FileProvisioner | LocalExecProvisioner | RemoteExecProvisioner)[];

idRequired

public readonly id: string;
  • Type: string

outputRequired

public readonly output: AnyMap;

inputInputOptional

public readonly inputInput: {[ key: string ]: any};
  • Type: {[ key: string ]: any}

triggersReplaceInputOptional

public readonly triggersReplaceInput: {[ key: string ]: any};
  • Type: {[ key: string ]: any}

inputRequired

public readonly input: {[ key: string ]: any};
  • Type: {[ key: string ]: any}
(Optional) A value which will be stored in the instance state, and reflected in the output attribute after apply. https://developer.hashicorp.com/terraform/language/resources/terraform-data#input

triggersReplaceRequired

public readonly triggersReplace: {[ key: string ]: any};
  • Type: {[ key: string ]: any}
(Optional) A value which is stored in the instance state, and will force replacement when the value changes. https://developer.hashicorp.com/terraform/language/resources/terraform-data#triggers\_replace

Constants

NameTypeDescription
tfResourceTypestringNo description.

tfResourceTypeRequired

public readonly tfResourceType: string;
  • Type: string