@Generated(value="jsii-pacmak/1.58.0 (build f8ba112)", date="2022-05-27T16:27:53.951Z") public class CfnResource extends CfnRefElement
Example:
import software.amazon.awscdk.core.*; public class MyConstruct extends Resource implements ITaggable { public final Object tags; public MyConstruct(Construct scope, String id) { super(scope, id); CfnResource.Builder.create(this, "Resource") .type("Whatever::The::Type") .properties(Map.of( // ... "Tags", this.tags.getRenderedTags())) .build(); } }
Modifier and Type | Class and Description |
---|---|
static class |
CfnResource.Builder
A fluent builder for
CfnResource . |
IConstruct.Jsii$Default
Modifier | Constructor and Description |
---|---|
protected |
CfnResource(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
CfnResource(software.amazon.jsii.JsiiObjectRef objRef) |
|
CfnResource(software.constructs.Construct scope,
java.lang.String id,
CfnResourceProps props)
Creates a resource construct.
|
Modifier and Type | Method and Description |
---|---|
void |
addDeletionOverride(java.lang.String path)
Syntactic sugar for `addOverride(path, undefined)`.
|
void |
addDependsOn(CfnResource target)
Indicates that this resource depends on another resource and cannot be provisioned unless the other resource has been successfully provisioned.
|
void |
addMetadata(java.lang.String key,
java.lang.Object value)
Add a value to the CloudFormation Resource Metadata.
|
void |
addOverride(java.lang.String path,
java.lang.Object value)
Adds an override to the synthesized CloudFormation resource.
|
void |
addPropertyDeletionOverride(java.lang.String propertyPath)
Adds an override that deletes the value of a property from the resource definition.
|
void |
addPropertyOverride(java.lang.String propertyPath,
java.lang.Object value)
Adds an override to a resource property.
|
void |
applyRemovalPolicy()
Sets the deletion policy of the resource based on the removal policy specified.
|
void |
applyRemovalPolicy(RemovalPolicy policy)
Sets the deletion policy of the resource based on the removal policy specified.
|
void |
applyRemovalPolicy(RemovalPolicy policy,
RemovalPolicyOptions options)
Sets the deletion policy of the resource based on the removal policy specified.
|
Reference |
getAtt(java.lang.String attributeName)
Returns a token for an runtime attribute of this resource.
|
ICfnResourceOptions |
getCfnOptions()
Options for this resource, such as condition, update policy etc.
|
protected java.util.Map<java.lang.String,java.lang.Object> |
getCfnProperties() |
java.lang.String |
getCfnResourceType()
AWS resource type.
|
java.lang.Object |
getMetadata(java.lang.String key)
Retrieve a value value from the CloudFormation Resource Metadata.
|
protected java.util.Map<java.lang.String,java.lang.Object> |
getUpdatedProperites()
Return properties modified after initiation.
|
static java.lang.Boolean |
isCfnResource(software.constructs.IConstruct construct)
Check whether the given construct is a CfnResource.
|
protected java.util.Map<java.lang.String,java.lang.Object> |
renderProperties(java.util.Map<java.lang.String,java.lang.Object> props) |
protected java.lang.Boolean |
shouldSynthesize()
Can be overridden by subclasses to determine if this resource will be rendered into the cloudformation template.
|
java.lang.String |
toString()
Returns a string representation of this construct.
|
protected void |
validateProperties(java.lang.Object _properties) |
getRef
getCreationStack, getLogicalId, getStack, isCfnElement, overrideLogicalId
getNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesize, validate
protected CfnResource(software.amazon.jsii.JsiiObjectRef objRef)
protected CfnResource(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
public CfnResource(software.constructs.Construct scope, java.lang.String id, CfnResourceProps props)
scope
- This parameter is required.id
- This parameter is required.props
- This parameter is required.public static java.lang.Boolean isCfnResource(software.constructs.IConstruct construct)
construct
- This parameter is required.public void addDeletionOverride(java.lang.String path)
path
- The path of the value to delete. This parameter is required.public void addDependsOn(CfnResource target)
This can be used for resources across stacks (or nested stack) boundaries and the dependency will automatically be transferred to the relevant scope.
target
- This parameter is required.public void addMetadata(java.lang.String key, java.lang.Object value)
key
- This parameter is required.value
- This parameter is required.Note that this is a different set of metadata from CDK node metadata; this
metadata ends up in the stack template under the resource, whereas CDK
node metadata ends up in the Cloud Assembly.
public void addOverride(java.lang.String path, java.lang.Object value)
To add a
property override, either use addPropertyOverride
or prefix path
with
"Properties." (i.e. Properties.TopicName
).
If the override is nested, separate each nested level using a dot (.) in the path parameter. If there is an array as part of the nesting, specify the index in the path.
To include a literal .
in the property name, prefix with a \
. In most
programming languages you will need to write this as "\\."
because the
\
itself will need to be escaped.
For example,
cfnResource.addOverride("Properties.GlobalSecondaryIndexes.0.Projection.NonKeyAttributes", List.of("myattribute")); cfnResource.addOverride("Properties.GlobalSecondaryIndexes.1.ProjectionType", "INCLUDE");
would add the overrides
"Properties": { "GlobalSecondaryIndexes": [ { "Projection": { "NonKeyAttributes": [ "myattribute" ] ... } ... }, { "ProjectionType": "INCLUDE" ... }, ] ... }
The value
argument to addOverride
will not be processed or translated
in any way. Pass raw JSON values in here with the correct capitalization
for CloudFormation. If you pass CDK classes or structs, they will be
rendered with lowercased key names, and CloudFormation will reject the
template.
path
- - The path of the property, you can use dot notation to override values in complex types. This parameter is required.value
- - The value. This parameter is required.public void addPropertyDeletionOverride(java.lang.String propertyPath)
propertyPath
- The path to the property. This parameter is required.public void addPropertyOverride(java.lang.String propertyPath, java.lang.Object value)
Syntactic sugar for addOverride("Properties.<...>", value)
.
propertyPath
- The path of the property. This parameter is required.value
- The value. This parameter is required.public void applyRemovalPolicy(RemovalPolicy policy, RemovalPolicyOptions options)
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.
The resource can be deleted (RemovalPolicy.DESTROY
), or left in your AWS
account for data recovery and cleanup later (RemovalPolicy.RETAIN
).
policy
- options
- public void applyRemovalPolicy(RemovalPolicy policy)
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.
The resource can be deleted (RemovalPolicy.DESTROY
), or left in your AWS
account for data recovery and cleanup later (RemovalPolicy.RETAIN
).
policy
- public void applyRemovalPolicy()
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.
The resource can be deleted (RemovalPolicy.DESTROY
), or left in your AWS
account for data recovery and cleanup later (RemovalPolicy.RETAIN
).
public Reference getAtt(java.lang.String attributeName)
Ideally, use generated attribute accessors (e.g. resource.arn
), but this can be used for future compatibility
in case there is no generated attribute.
attributeName
- The name of the attribute. This parameter is required.public java.lang.Object getMetadata(java.lang.String key)
key
- This parameter is required.Note that this is a different set of metadata from CDK node metadata; this
metadata ends up in the stack template under the resource, whereas CDK
node metadata ends up in the Cloud Assembly.
protected java.util.Map<java.lang.String,java.lang.Object> renderProperties(java.util.Map<java.lang.String,java.lang.Object> props)
props
- This parameter is required.protected java.lang.Boolean shouldSynthesize()
public java.lang.String toString()
protected void validateProperties(java.lang.Object _properties)
_properties
- This parameter is required.public ICfnResourceOptions getCfnOptions()
protected java.util.Map<java.lang.String,java.lang.Object> getCfnProperties()
public java.lang.String getCfnResourceType()
protected java.util.Map<java.lang.String,java.lang.Object> getUpdatedProperites()
Resources that expose mutable properties should override this function to collect and return the properties object for this resource.