aws-cdk-lib.CfnMapping

class CfnMapping (construct)

LanguageType name
.NETAmazon.CDK.CfnMapping
Gogithub.com/aws/aws-cdk-go/awscdk/v2#CfnMapping
Javasoftware.amazon.awscdk.CfnMapping
Pythonaws_cdk.CfnMapping
TypeScript (source)aws-cdk-lib » CfnMapping

Implements IConstruct, IDependable

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')

Initializer

new CfnMapping(scope: Construct, id: string, props?: CfnMappingProps)

Parameters

  • scope Construct
  • id string
  • props CfnMappingProps

Construct Props

NameTypeDescription
lazy?boolean
mapping?{ [string]: { [string]: any } }Mapping of key to a set of corresponding set of named values.

lazy?

Type: boolean (optional)


mapping?

Type: { [string]: { [string]: any } } (optional, default: No mapping.)

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.

Properties

NameTypeDescription
creationStackstring[]
logicalIdstringThe logical ID for this CloudFormation stack element.
nodeNodeThe tree node.
refstringReturn a string that will be resolved to a CloudFormation { Ref } for this element.
stackStackThe stack in which this element is defined.

creationStack

Type: string[]


logicalId

Type: string

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).


node

Type: Node

The tree node.


ref

Type: string

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

Type: Stack

The stack in which this element is defined.

CfnElements must be defined within a stack scope (directly or indirectly).

Methods

NameDescription
findInMap(key1, key2)
overrideLogicalId(newLogicalId)Overrides the auto-generated logical ID with a specific ID.
setValue(key1, key2, value)Sets a value in the map based on the two keys.
toString()Returns a string representation of this construct.

findInMap(key1, key2)

public findInMap(key1: string, key2: string): string

Parameters

  • key1 string
  • key2 string

Returns

  • string

overrideLogicalId(newLogicalId)

public overrideLogicalId(newLogicalId: string): void

Parameters

  • newLogicalId string — The new logical ID to use for this stack element.

Overrides the auto-generated logical ID with a specific ID.


setValue(key1, key2, value)

public setValue(key1: string, key2: string, value: any): void

Parameters

  • key1 string
  • key2 string
  • value any

Sets a value in the map based on the two keys.


toString()

public toString(): string

Returns

  • string

Returns a string representation of this construct.