CombineStrategyOptions Struct
Options for the combine strategy.
| Source | core/lib/mixins/property-merge-strategy.ts |
|---|---|
| Type last changed |
Example
ts
// TableV2 uses a Box internally for replicas.
// The mixin defers the merge and appends the new replica at synthesis time.
const table = new dynamodb.TableV2(scope, 'Table', {
partitionKey: { name: 'pk', type: dynamodb.AttributeType.STRING },
// L2 prop: pointInTimeRecovery is a boolean
replicas: [{ region: 'us-east-1', pointInTimeRecovery: true }],
});
// Mixins always use L1 (CloudFormation) property names and shapes,
// regardless of what the L2 API looks like.
table.with(new CfnGlobalTablePropsMixin({
replicas: [{
region: 'eu-west-1',
// L1 prop: pointInTimeRecoverySpecification is an object
pointInTimeRecoverySpecification: { pointInTimeRecoveryEnabled: true },
}],
}, { strategy: PropertyMergeStrategy.combine({ arrays: ArrayMergeStrategy.append() }) }));
// Result (synthesized CloudFormation):
// Replicas:
// - Region: us-east-1
// PointInTimeRecoverySpecification:
// PointInTimeRecoveryEnabled: true
// - Region: us-west-2 <-- primary region, added by L2
// - Region: eu-west-1 <-- added by mixin
// PointInTimeRecoverySpecification:
// PointInTimeRecoveryEnabled: true
python
from aws_cdk.cfn_property_mixins.aws_dynamodb import CfnGlobalTableMixinProps
# TableV2 uses a Box internally for replicas.
# The mixin defers the merge and appends the new replica at synthesis time.
table = dynamodb.TableV2(scope, "Table",
partition_key=dynamodb.Attribute(name="pk", type=dynamodb.AttributeType.STRING),
# L2 prop: pointInTimeRecovery is a boolean
replicas=[dynamodb.ReplicaTableProps(region="us-east-1", point_in_time_recovery=True)]
)
# Mixins always use L1 (CloudFormation) property names and shapes,
# regardless of what the L2 API looks like.
table.with(CfnGlobalTablePropsMixin(CfnGlobalTableMixinProps(
replicas=[CfnGlobalTablePropsMixin.ReplicaSpecificationProperty(
region="eu-west-1",
# L1 prop: pointInTimeRecoverySpecification is an object
point_in_time_recovery_specification=CfnGlobalTablePropsMixin.PointInTimeRecoverySpecificationProperty(point_in_time_recovery_enabled=True)
)]
), strategy=PropertyMergeStrategy.combine(arrays=ArrayMergeStrategy.append())))
java
// TableV2 uses a Box internally for replicas.
// The mixin defers the merge and appends the new replica at synthesis time.
TableV2 table = TableV2.Builder.create(scope, "Table")
.partitionKey(Attribute.builder().name("pk").type(AttributeType.STRING).build())
// L2 prop: pointInTimeRecovery is a boolean
.replicas(List.of(ReplicaTableProps.builder().region("us-east-1").pointInTimeRecovery(true).build()))
.build();
// Mixins always use L1 (CloudFormation) property names and shapes,
// regardless of what the L2 API looks like.
table.with(CfnGlobalTablePropsMixin.Builder.create(CfnGlobalTableMixinProps.builder()
.replicas(List.of(ReplicaSpecificationProperty.builder()
.region("eu-west-1")
// L1 prop: pointInTimeRecoverySpecification is an object
.pointInTimeRecoverySpecification(PointInTimeRecoverySpecificationProperty.builder().pointInTimeRecoveryEnabled(true).build())
.build()))
.build()).strategy(PropertyMergeStrategy.combine(CombineStrategyOptions.builder().arrays(ArrayMergeStrategy.append()).build())).build());
csharp
// Install: dotnet add package Amazon.CDK.Lib
// TableV2 uses a Box internally for replicas.
// The mixin defers the merge and appends the new replica at synthesis time.
var table = new TableV2(scope, "Table", new TablePropsV2 {
PartitionKey = new Attribute { Name = "pk", Type = AttributeType.STRING },
// L2 prop: pointInTimeRecovery is a boolean
Replicas = new [] { new ReplicaTableProps { Region = "us-east-1", PointInTimeRecovery = true } }
});
// Mixins always use L1 (CloudFormation) property names and shapes,
// regardless of what the L2 API looks like.
table.With(new CfnGlobalTablePropsMixin(new CfnGlobalTableMixinProps {
Replicas = new [] { new ReplicaSpecificationProperty {
Region = "eu-west-1",
// L1 prop: pointInTimeRecoverySpecification is an object
PointInTimeRecoverySpecification = new PointInTimeRecoverySpecificationProperty { PointInTimeRecoveryEnabled = true }
} }
}, new CfnPropertyMixinOptions { Strategy = PropertyMergeStrategy.Combine(new CombineStrategyOptions { Arrays = ArrayMergeStrategy.Append() }) }));
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// TableV2 uses a Box internally for replicas.
// The mixin defers the merge and appends the new replica at synthesis time.
table := dynamodb.NewTableV2(scope, jsii.String("Table"), &TablePropsV2{
PartitionKey: &Attribute{
Name: jsii.String("pk"),
Type: dynamodb.AttributeType_STRING,
},
// L2 prop: pointInTimeRecovery is a boolean
Replicas: []ReplicaTableProps{
&ReplicaTableProps{
Region: jsii.String("us-east-1"),
PointInTimeRecovery: jsii.Boolean(true),
},
},
})
// Mixins always use L1 (CloudFormation) property names and shapes,
// regardless of what the L2 API looks like.
table.With(awscdkcfnpropertymixins.NewCfnGlobalTablePropsMixin(&CfnGlobalTableMixinProps{
Replicas: []interface{}{
&ReplicaSpecificationProperty{
Region: jsii.String("eu-west-1"),
// L1 prop: pointInTimeRecoverySpecification is an object
PointInTimeRecoverySpecification: &PointInTimeRecoverySpecificationProperty{
PointInTimeRecoveryEnabled: jsii.Boolean(true),
},
},
},
}, &CfnPropertyMixinOptions{
Strategy: awscdk.PropertyMergeStrategy_Combine(&CombineStrategyOptions{
Arrays: awscdk.ArrayMergeStrategy_Append(),
}),
}))
Properties
arraysoptionalIArrayMergeStrategyarraysoptionalIArrayMergeStrategyarraysoptionalIArrayMergeStrategyArraysoptionalIArrayMergeStrategyArraysoptionalIArrayMergeStrategy = ArrayMergeStrategy.replace() #Strategy for merging arrays.