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 io.cdktn.cdktn.DataResource;

DataResource.Builder.create(Construct scope, java.lang.String id)
//  .connection(SSHProvisionerConnection|WinrmProvisionerConnection)
//  .count(java.lang.Number|TerraformCount)
//  .dependsOn(java.util.List<ITerraformDependable>)
//  .forEach(ITerraformIterator)
//  .lifecycle(TerraformResourceLifecycle)
//  .provider(TerraformProvider)
//  .provisioners(java.util.List<FileProvisioner|LocalExecProvisioner|RemoteExecProvisioner>)
//  .input(java.util.Map<java.lang.String, java.lang.Object>)
//  .triggersReplace(java.util.Map<java.lang.String, java.lang.Object>)
    .build();
NameTypeDescription
scopesoftware.constructs.ConstructThe scope in which to define this construct.
idjava.lang.StringThe scoped construct ID.
connectionSSHProvisionerConnection|WinrmProvisionerConnectionNo description.
countjava.lang.Number|TerraformCountNo description.
dependsOnjava.util.List<ITerraformDependable>No description.
forEachITerraformIteratorNo description.
lifecycleTerraformResourceLifecycleNo description.
providerTerraformProviderNo description.
provisionersjava.util.List<FileProvisioner|LocalExecProvisioner|RemoteExecProvisioner>No description.
inputjava.util.Map< java.lang.String, java.lang.Object >(Optional) A value which will be stored in the instance state, and reflected in the output attribute after apply.
triggersReplacejava.util.Map< java.lang.String, java.lang.Object >(Optional) A value which is stored in the instance state, and will force replacement when the value changes.

scopeRequired

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

idRequired

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

connectionOptional


countOptional


dependsOnOptional


forEachOptional


lifecycleOptional


providerOptional


provisionersOptional


inputOptional

  • Type: java.util.Map< java.lang.String, java.lang.Object >
(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

triggersReplaceOptional

  • Type: java.util.Map< java.lang.String, java.lang.Object >
(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

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 java.lang.String toString()
Returns a string representation of this construct.

addOverride

public void addOverride(java.lang.String path, java.lang.Object value)

pathRequired

  • Type: java.lang.String

valueRequired

  • Type: java.lang.Object

overrideLogicalId

public void overrideLogicalId(java.lang.String newLogicalId)
Overrides the auto-generated logical ID with a specific ID.

newLogicalIdRequired

  • Type: java.lang.String
The new logical ID to use for this stack element.

resetOverrideLogicalId

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

toHclTerraform

public java.lang.Object toHclTerraform()

toMetadata

public java.lang.Object toMetadata()

toTerraform

public java.lang.Object toTerraform()
Adds this resource to the terraform JSON output.

addMoveTarget

public void addMoveTarget(java.lang.String moveTarget)
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: java.lang.String
The string move target that will correspond to this resource.

getAnyMapAttribute

public java.util.Map<java.lang.String, java.lang.Object> getAnyMapAttribute(java.lang.String terraformAttribute)

terraformAttributeRequired

  • Type: java.lang.String

getBooleanAttribute

public IResolvable getBooleanAttribute(java.lang.String terraformAttribute)

terraformAttributeRequired

  • Type: java.lang.String

getBooleanMapAttribute

public java.util.Map<java.lang.String, java.lang.Boolean> getBooleanMapAttribute(java.lang.String terraformAttribute)

terraformAttributeRequired

  • Type: java.lang.String

getListAttribute

public java.util.List<java.lang.String> getListAttribute(java.lang.String terraformAttribute)

terraformAttributeRequired

  • Type: java.lang.String

getNumberAttribute

public java.lang.Number getNumberAttribute(java.lang.String terraformAttribute)

terraformAttributeRequired

  • Type: java.lang.String

getNumberListAttribute

public java.util.List<java.lang.Number> getNumberListAttribute(java.lang.String terraformAttribute)

terraformAttributeRequired

  • Type: java.lang.String

getNumberMapAttribute

public java.util.Map<java.lang.String, java.lang.Number> getNumberMapAttribute(java.lang.String terraformAttribute)

terraformAttributeRequired

  • Type: java.lang.String

getStringAttribute

public java.lang.String getStringAttribute(java.lang.String terraformAttribute)

terraformAttributeRequired

  • Type: java.lang.String

getStringMapAttribute

public java.util.Map<java.lang.String, java.lang.String> getStringMapAttribute(java.lang.String terraformAttribute)

terraformAttributeRequired

  • Type: java.lang.String

hasResourceMove

public TerraformResourceMoveByTarget|TerraformResourceMoveById hasResourceMove()

importFrom

public void importFrom(java.lang.String id)
public void importFrom(java.lang.String id, TerraformProvider provider)

idRequired

  • Type: java.lang.String

providerOptional


interpolationForAttribute

public IResolvable interpolationForAttribute(java.lang.String terraformAttribute)

terraformAttributeRequired

  • Type: java.lang.String

moveFromId

public void moveFromId(java.lang.String id)
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: java.lang.String
Full id of resource being moved from, e.g. “aws_s3_bucket.example”.

moveTo

public void moveTo(java.lang.String moveTarget)
public void moveTo(java.lang.String moveTarget, java.lang.String|java.lang.Number index)
Moves this resource to the target resource given by moveTarget.

moveTargetRequired

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

indexOptional

  • Type: java.lang.String|java.lang.Number
Optional The index corresponding to the key the resource is to appear in the foreach of a resource to move to.

moveToId

public void moveToId(java.lang.String id)
Moves this resource to the resource corresponding to “id”.

idRequired

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

resetInput

public void resetInput()

resetTriggersReplace

public void resetTriggersReplace()

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 io.cdktn.cdktn.DataResource;

DataResource.isConstruct(java.lang.Object x)
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: java.lang.Object
Any object.

isTerraformElement

import io.cdktn.cdktn.DataResource;

DataResource.isTerraformElement(java.lang.Object x)

xRequired

  • Type: java.lang.Object

isTerraformResource

import io.cdktn.cdktn.DataResource;

DataResource.isTerraformResource(java.lang.Object x)

xRequired

  • Type: java.lang.Object

generateConfigForImport

import io.cdktn.cdktn.DataResource;

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

scopeRequired

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

importToIdRequired

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

importFromIdRequired

  • Type: java.lang.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
nodesoftware.constructs.NodeThe tree node.
cdktfStackTerraformStackNo description.
fqnjava.lang.StringNo description.
friendlyUniqueIdjava.lang.StringNo description.
terraformMetaArgumentsjava.util.Map< java.lang.String, java.lang.Object >No description.
terraformResourceTypejava.lang.StringNo description.
terraformGeneratorMetadataTerraformProviderGeneratorMetadataNo description.
connectionSSHProvisionerConnection|WinrmProvisionerConnectionNo description.
countjava.lang.Number|TerraformCountNo description.
dependsOnjava.util.List< java.lang.String >No description.
forEachITerraformIteratorNo description.
lifecycleTerraformResourceLifecycleNo description.
providerTerraformProviderNo description.
provisionersjava.util.List<FileProvisioner|LocalExecProvisioner|RemoteExecProvisioner>No description.
idjava.lang.StringNo description.
outputAnyMapNo description.
inputInputjava.util.Map< java.lang.String, java.lang.Object >No description.
triggersReplaceInputjava.util.Map< java.lang.String, java.lang.Object >No description.
inputjava.util.Map< java.lang.String, java.lang.Object >(Optional) A value which will be stored in the instance state, and reflected in the output attribute after apply.
triggersReplacejava.util.Map< java.lang.String, java.lang.Object >(Optional) A value which is stored in the instance state, and will force replacement when the value changes.

nodeRequired

public Node getNode();
  • Type: software.constructs.Node
The tree node.

cdktfStackRequired

public TerraformStack getCdktfStack();

fqnRequired

public java.lang.String getFqn();
  • Type: java.lang.String

friendlyUniqueIdRequired

public java.lang.String getFriendlyUniqueId();
  • Type: java.lang.String

terraformMetaArgumentsRequired

public java.util.Map<java.lang.String, java.lang.Object> getTerraformMetaArguments();
  • Type: java.util.Map< java.lang.String, java.lang.Object >

terraformResourceTypeRequired

public java.lang.String getTerraformResourceType();
  • Type: java.lang.String

terraformGeneratorMetadataOptional

public TerraformProviderGeneratorMetadata getTerraformGeneratorMetadata();

connectionOptional

public SSHProvisionerConnection|WinrmProvisionerConnection getConnection();

countOptional

public java.lang.Number|TerraformCount getCount();

dependsOnOptional

public java.util.List<java.lang.String> getDependsOn();
  • Type: java.util.List< java.lang.String >

forEachOptional

public ITerraformIterator getForEach();

lifecycleOptional

public TerraformResourceLifecycle getLifecycle();

providerOptional

public TerraformProvider getProvider();

provisionersOptional

public java.util.List<FileProvisioner|LocalExecProvisioner|RemoteExecProvisioner> getProvisioners();

idRequired

public java.lang.String getId();
  • Type: java.lang.String

outputRequired

public AnyMap getOutput();

inputInputOptional

public java.util.Map<java.lang.String, java.lang.Object> getInputInput();
  • Type: java.util.Map< java.lang.String, java.lang.Object >

triggersReplaceInputOptional

public java.util.Map<java.lang.String, java.lang.Object> getTriggersReplaceInput();
  • Type: java.util.Map< java.lang.String, java.lang.Object >

inputRequired

public java.util.Map<java.lang.String, java.lang.Object> getInput();
  • Type: java.util.Map< java.lang.String, java.lang.Object >
(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 java.util.Map<java.lang.String, java.lang.Object> getTriggersReplace();
  • Type: java.util.Map< java.lang.String, java.lang.Object >
(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
tfResourceTypejava.lang.StringNo description.

tfResourceTypeRequired

public java.lang.String getTfResourceType();
  • Type: java.lang.String