CfnMapping L1 construct
Represents a CloudFormation mapping.
Example
const regionTable = new CfnMapping(this, 'RegionTable', {
mapping: {
'us-east-1': {
regionName: 'US East (N. Virginia)',
// ...
},
'us-east-2': {
regionName: 'US East (Ohio)',
// ...
},
// ...
}
});
regionTable.findInMap(Aws.REGION, 'regionName')
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")
CfnMapping regionTable = CfnMapping.Builder.create(this, "RegionTable")
.mapping(Map.of(
"us-east-1", Map.of(
"regionName", "US East (N. Virginia)"),
"us-east-2", Map.of(
"regionName", "US East (Ohio)")))
.build();
regionTable.findInMap(Aws.REGION, "regionName");
// Install: dotnet add package Amazon.CDK.Lib
var regionTable = new CfnMapping(this, "RegionTable", new CfnMappingProps {
Mapping = new Dictionary<string, IDictionary<string, object>> {
{ "us-east-1", new Dictionary<string, object> {
{ "regionName", "US East (N. Virginia)" }
} },
{ "us-east-2", new Dictionary<string, object> {
{ "regionName", "US East (Ohio)" }
} }
}
});
regionTable.FindInMap(Aws.REGION, "regionName");
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
regionTable := awscdk.NewCfnMapping(this, jsii.String("RegionTable"), &CfnMappingProps{
Mapping: map[string]map[string]interface{}{
"us-east-1": map[string]interface{}{
"regionName": jsii.String("US East (N. Virginia)"),
},
"us-east-2": map[string]interface{}{
"regionName": jsii.String("US East (Ohio)"),
},
},
})
regionTable.FindInMap(awscdk.Aws_REGION(), jsii.String("regionName"))
Initializer
new CfnMapping(scope: Construct, id: string, props?: CfnMappingProps)
CfnMapping(scope: Construct, id: str, props: typing.Optional[CfnMappingProps] = None)
new CfnMapping(Construct scope, String id, CfnMappingProps props)
new CfnMapping(Construct scope, string id, CfnMappingProps? props = null)
NewCfnMapping(Scope Construct, Id *string, Props CfnMappingProps)
Construct Props
mapping{ [key: string]: { [key: string]: any } }mappingtyping.Mapping[str, typing.Mapping[str, Any]]mappingMap<String, Map<String, Object>>MappingIDictionary<string, IDictionary<string, object>>Mapping*map[string]*map[string]interface{}= No mapping.#notes
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.
Properties
creationStackstring[]creation_stacktyping.List[str]creationStackList<String>CreationStackstring[]CreationStack*[]*stringrequired#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).
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 }).
Methods
findInMap(key1: string, key2: string, defaultValue?: string): stringdef find_in_map(self, key1: str, key2: str, default_value: typing.Optional[str] = None) -> strpublic String findInMap(String key1, String key2, String defaultValue)public string FindInMap(string key1, string key2, string? defaultValue = null)func FindInMap(Key1 *string, Key2 *string, DefaultValue *string) *string#returns
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.
isCfnElement(x: any): boolean@staticmethod def is_cfn_element(x: Any) -> boolpublic static Boolean isCfnElement(Object x)public static bool IsCfnElement(object x)func IsCfnElement(X interface{}) *boolstatic#Uses duck-typing instead of instanceof to allow stack elements from different versions of this library to be included in the same stack.
returns
Returns: The construct as a stack element or undefined if it is not a stack element.
isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#notes · 1 parameter · returns
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.
Parameters
xxxxX— Any object.
Returns: true if x is an object created from a class which extends Construct.
overrideLogicalId(newLogicalId: string): voiddef override_logical_id(self, new_logical_id: str) -> Nonepublic void overrideLogicalId(String newLogicalId)public void OverrideLogicalId(string newLogicalId)func OverrideLogicalId(NewLogicalId *string)#1 parameter
Parameters
newLogicalIdnew_logical_idnewLogicalIdnewLogicalIdNewLogicalId— The new logical ID to use for this stack element.
setValue(key1: string, key2: string, value: any): voiddef set_value(self, key1: str, key2: str, value: Any) -> Nonepublic void setValue(String key1, String key2, Object value)public void SetValue(string key1, string key2, object value)func SetValue(Key1 *string, Key2 *string, Value interface{})#toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.