CfnMapping
- class aws_cdk.CfnMapping(scope, id, *, lazy=None, mapping=None)
Bases:
CfnRefElementRepresents a CloudFormation mapping.
- ExampleMetadata:
infused
Example:
region_table = CfnMapping(self, "RegionTable", mapping={ "us-east-1": { "region_name": "US East (N. Virginia)" }, "us-east-2": { "region_name": "US East (Ohio)" } } ) region_table.find_in_map(Aws.REGION, "regionName")
- Parameters:
scope (
Construct)id (
str)lazy (
Optional[bool])mapping (
Optional[Mapping[str,Mapping[str,Any]]]) – Mapping of key to a set of corresponding set of named values. The key identifies a map of name-value pairs and must be unique within the mapping. For example, if you want to set values based on a region, you can create a mapping that uses the region name as a key and contains the values you want to specify for each specific region. Default: - No mapping.
Methods
- find_in_map(key1, key2, default_value=None)
- Parameters:
key1 (
str)key2 (
str)default_value (
Optional[str])
- Return type:
str- Returns:
A reference to a value in the map based on the two keys. If mapping is lazy, the value from the map or default value is returned instead of the reference and the mapping is not rendered in the template.
- override_logical_id(new_logical_id)
Overrides the auto-generated logical ID with a specific ID.
- Parameters:
new_logical_id (
str) – The new logical ID to use for this stack element.- Return type:
None
- set_value(key1, key2, value)
Sets a value in the map based on the two keys.
- Parameters:
key1 (
str)key2 (
str)value (
Any)
- Return type:
None
- to_string()
Returns a string representation of this construct.
- Return type:
str
Attributes
- creation_stack
return:
the stack trace of the point where this Resource was created from, sourced from the +metadata+ entry typed +aws:cdk:logicalId+, and with the bottom-most node +internal+ entries filtered.
- logical_id
The logical ID for this CloudFormation stack element.
The logical ID of the element is calculated from the path of the resource node in the construct tree.
To override this value, use
overrideLogicalId(newLogicalId).- Returns:
the logical ID as a stringified token. This value will only get resolved during synthesis.
- node
The tree node.
- ref
Return a string that will be resolved to a CloudFormation
{ Ref }for this element.If, by any chance, the intrinsic reference of a resource is not a string, you could coerce it to an IResolvable through
Lazy.any({ produce: resource.ref }).
- stack
The stack in which this element is defined.
CfnElements must be defined within a stack scope (directly or indirectly).
Static Methods
- classmethod is_cfn_element(x)
Returns
trueif a construct is a stack element (i.e. part of the synthesized cloudformation template).Uses duck-typing instead of
instanceofto allow stack elements from different versions of this library to be included in the same stack.- Parameters:
x (
Any)- Return type:
bool- Returns:
The construct as a stack element or undefined if it is not a stack element.
- classmethod is_construct(x)
Checks if
xis a construct.Use this method instead of
instanceofto properly detectConstructinstances, even when the construct library is symlinked.Explanation: in JavaScript, multiple copies of the
constructslibrary on disk are seen as independent, completely different libraries. As a consequence, the classConstructin each copy of theconstructslibrary is seen as a different class, and an instance of one class will not test asinstanceofthe other class.npm installwill not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of theconstructslibrary can be accidentally installed, andinstanceofwill behave unpredictably. It is safest to avoid usinginstanceof, and using this type-testing method instead.- Parameters:
x (
Any) – Any object.- Return type:
bool- Returns:
true if
xis an object created from a class which extendsConstruct.