From da8a4caaa06e122f5da5d20981b23a3945d9481b Mon Sep 17 00:00:00 2001 From: Lee Hannigan Date: Thu, 5 Dec 2024 13:02:36 +0000 Subject: [PATCH] feat(dynamodb): add warm-throughput to L2 constructs --- .../cdk.out | 1 + .../integ.json | 12 ++ .../manifest.json | 113 ++++++++++ .../tree.json | 202 ++++++++++++++++++ .../warm-throughput-stack-v2.assets.json | 20 ++ .../warm-throughput-stack-v2.template.json | 123 +++++++++++ ...efaultTestDeployAssertA2FD11C0.assets.json | 19 ++ ...aultTestDeployAssertA2FD11C0.template.json | 36 ++++ .../test/integ.dynamodb-v2.warm-throughput.ts | 50 +++++ .../cdk.out | 1 + .../integ.json | 12 ++ .../manifest.json | 113 ++++++++++ .../tree.json | 178 +++++++++++++++ .../warm-throughput-stack.assets.json | 19 ++ .../warm-throughput-stack.template.json | 91 ++++++++ ...efaultTestDeployAssertA9A62BB4.assets.json | 19 ++ ...aultTestDeployAssertA9A62BB4.template.json | 36 ++++ .../test/integ.dynamodb.warm-throughput.ts | 42 ++++ packages/aws-cdk-lib/aws-dynamodb/README.md | 19 ++ .../aws-cdk-lib/aws-dynamodb/TABLE_V1_API.md | 19 ++ .../aws-cdk-lib/aws-dynamodb/lib/shared.ts | 16 ++ .../aws-cdk-lib/aws-dynamodb/lib/table-v2.ts | 19 ++ .../aws-cdk-lib/aws-dynamodb/lib/table.ts | 19 +- .../aws-dynamodb/test/dynamodb.test.ts | 141 ++++++++++++ .../aws-dynamodb/test/table-v2.test.ts | 66 ++++++ 25 files changed, 1385 insertions(+), 1 deletion(-) create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb-v2.warm-throughput.js.snapshot/cdk.out create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb-v2.warm-throughput.js.snapshot/integ.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb-v2.warm-throughput.js.snapshot/manifest.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb-v2.warm-throughput.js.snapshot/tree.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb-v2.warm-throughput.js.snapshot/warm-throughput-stack-v2.assets.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb-v2.warm-throughput.js.snapshot/warm-throughput-stack-v2.template.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb-v2.warm-throughput.js.snapshot/warmthroughputintegtestv2DefaultTestDeployAssertA2FD11C0.assets.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb-v2.warm-throughput.js.snapshot/warmthroughputintegtestv2DefaultTestDeployAssertA2FD11C0.template.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb-v2.warm-throughput.ts create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb.warm-throughput.js.snapshot/cdk.out create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb.warm-throughput.js.snapshot/integ.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb.warm-throughput.js.snapshot/manifest.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb.warm-throughput.js.snapshot/tree.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb.warm-throughput.js.snapshot/warm-throughput-stack.assets.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb.warm-throughput.js.snapshot/warm-throughput-stack.template.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb.warm-throughput.js.snapshot/warmthroughputintegtestDefaultTestDeployAssertA9A62BB4.assets.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb.warm-throughput.js.snapshot/warmthroughputintegtestDefaultTestDeployAssertA9A62BB4.template.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb.warm-throughput.ts diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb-v2.warm-throughput.js.snapshot/cdk.out b/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb-v2.warm-throughput.js.snapshot/cdk.out new file mode 100644 index 0000000000000..c6e612584e352 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb-v2.warm-throughput.js.snapshot/cdk.out @@ -0,0 +1 @@ +{"version":"38.0.1"} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb-v2.warm-throughput.js.snapshot/integ.json b/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb-v2.warm-throughput.js.snapshot/integ.json new file mode 100644 index 0000000000000..1f417fdea8e00 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb-v2.warm-throughput.js.snapshot/integ.json @@ -0,0 +1,12 @@ +{ + "version": "38.0.1", + "testCases": { + "warm-throughput-integ-test-v2/DefaultTest": { + "stacks": [ + "warm-throughput-stack-v2" + ], + "assertionStack": "warm-throughput-integ-test-v2/DefaultTest/DeployAssert", + "assertionStackName": "warmthroughputintegtestv2DefaultTestDeployAssertA2FD11C0" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb-v2.warm-throughput.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb-v2.warm-throughput.js.snapshot/manifest.json new file mode 100644 index 0000000000000..4954a71aa0eb0 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb-v2.warm-throughput.js.snapshot/manifest.json @@ -0,0 +1,113 @@ +{ + "version": "38.0.1", + "artifacts": { + "warm-throughput-stack-v2.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "warm-throughput-stack-v2.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "warm-throughput-stack-v2": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/eu-west-1", + "properties": { + "templateFile": "warm-throughput-stack-v2.template.json", + "terminationProtection": false, + "validateOnSynth": false, + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-eu-west-1", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-eu-west-1", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-eu-west-1/e8d4da32962e661c67793742bfac886e53ea102f30d7fc024b5496d04e6fdb4a.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "warm-throughput-stack-v2.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-eu-west-1", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "warm-throughput-stack-v2.assets" + ], + "metadata": { + "/warm-throughput-stack-v2/TableTest1/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "TableTest143E55AA2" + } + ], + "/warm-throughput-stack-v2/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/warm-throughput-stack-v2/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "warm-throughput-stack-v2" + }, + "warmthroughputintegtestv2DefaultTestDeployAssertA2FD11C0.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "warmthroughputintegtestv2DefaultTestDeployAssertA2FD11C0.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "warmthroughputintegtestv2DefaultTestDeployAssertA2FD11C0": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "warmthroughputintegtestv2DefaultTestDeployAssertA2FD11C0.template.json", + "terminationProtection": false, + "validateOnSynth": false, + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "warmthroughputintegtestv2DefaultTestDeployAssertA2FD11C0.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "warmthroughputintegtestv2DefaultTestDeployAssertA2FD11C0.assets" + ], + "metadata": { + "/warm-throughput-integ-test-v2/DefaultTest/DeployAssert/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/warm-throughput-integ-test-v2/DefaultTest/DeployAssert/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "warm-throughput-integ-test-v2/DefaultTest/DeployAssert" + }, + "Tree": { + "type": "cdk:tree", + "properties": { + "file": "tree.json" + } + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb-v2.warm-throughput.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb-v2.warm-throughput.js.snapshot/tree.json new file mode 100644 index 0000000000000..8fa334fb8e01b --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb-v2.warm-throughput.js.snapshot/tree.json @@ -0,0 +1,202 @@ +{ + "version": "tree-0.1", + "tree": { + "id": "App", + "path": "", + "children": { + "warm-throughput-stack-v2": { + "id": "warm-throughput-stack-v2", + "path": "warm-throughput-stack-v2", + "children": { + "TableTest1": { + "id": "TableTest1", + "path": "warm-throughput-stack-v2/TableTest1", + "children": { + "Resource": { + "id": "Resource", + "path": "warm-throughput-stack-v2/TableTest1/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::DynamoDB::GlobalTable", + "aws:cdk:cloudformation:props": { + "attributeDefinitions": [ + { + "attributeName": "id", + "attributeType": "S" + }, + { + "attributeName": "gsi1pk", + "attributeType": "S" + } + ], + "billingMode": "PAY_PER_REQUEST", + "globalSecondaryIndexes": [ + { + "indexName": "my-index-1", + "keySchema": [ + { + "attributeName": "gsi1pk", + "keyType": "HASH" + } + ], + "projection": { + "projectionType": "ALL" + }, + "warmThroughput": { + "readUnitsPerSecond": 15000, + "writeUnitsPerSecond": 6000 + } + }, + { + "indexName": "my-index-2", + "keySchema": [ + { + "attributeName": "gsi1pk", + "keyType": "HASH" + } + ], + "projection": { + "projectionType": "ALL" + } + } + ], + "keySchema": [ + { + "attributeName": "id", + "keyType": "HASH" + } + ], + "replicas": [ + { + "region": "us-west-2", + "globalSecondaryIndexes": [ + { + "indexName": "my-index-1" + }, + { + "indexName": "my-index-2" + } + ] + }, + { + "region": "eu-west-1", + "globalSecondaryIndexes": [ + { + "indexName": "my-index-1" + }, + { + "indexName": "my-index-2" + } + ] + } + ], + "streamSpecification": { + "streamViewType": "NEW_AND_OLD_IMAGES" + }, + "warmThroughput": { + "readUnitsPerSecond": 14000, + "writeUnitsPerSecond": 5000 + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "warm-throughput-stack-v2/BootstrapVersion", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "warm-throughput-stack-v2/CheckBootstrapVersion", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "warm-throughput-integ-test-v2": { + "id": "warm-throughput-integ-test-v2", + "path": "warm-throughput-integ-test-v2", + "children": { + "DefaultTest": { + "id": "DefaultTest", + "path": "warm-throughput-integ-test-v2/DefaultTest", + "children": { + "Default": { + "id": "Default", + "path": "warm-throughput-integ-test-v2/DefaultTest/Default", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "DeployAssert": { + "id": "DeployAssert", + "path": "warm-throughput-integ-test-v2/DefaultTest/DeployAssert", + "children": { + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "warm-throughput-integ-test-v2/DefaultTest/DeployAssert/BootstrapVersion", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "warm-throughput-integ-test-v2/DefaultTest/DeployAssert/CheckBootstrapVersion", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.IntegTestCase", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.IntegTest", + "version": "0.0.0" + } + }, + "Tree": { + "id": "Tree", + "path": "Tree", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb-v2.warm-throughput.js.snapshot/warm-throughput-stack-v2.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb-v2.warm-throughput.js.snapshot/warm-throughput-stack-v2.assets.json new file mode 100644 index 0000000000000..4070991ce6d09 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb-v2.warm-throughput.js.snapshot/warm-throughput-stack-v2.assets.json @@ -0,0 +1,20 @@ +{ + "version": "38.0.1", + "files": { + "e8d4da32962e661c67793742bfac886e53ea102f30d7fc024b5496d04e6fdb4a": { + "source": { + "path": "warm-throughput-stack-v2.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-eu-west-1": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-eu-west-1", + "objectKey": "e8d4da32962e661c67793742bfac886e53ea102f30d7fc024b5496d04e6fdb4a.json", + "region": "eu-west-1", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-eu-west-1" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb-v2.warm-throughput.js.snapshot/warm-throughput-stack-v2.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb-v2.warm-throughput.js.snapshot/warm-throughput-stack-v2.template.json new file mode 100644 index 0000000000000..69850a26b531d --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb-v2.warm-throughput.js.snapshot/warm-throughput-stack-v2.template.json @@ -0,0 +1,123 @@ +{ + "Resources": { + "TableTest143E55AA2": { + "Type": "AWS::DynamoDB::GlobalTable", + "Properties": { + "AttributeDefinitions": [ + { + "AttributeName": "id", + "AttributeType": "S" + }, + { + "AttributeName": "gsi1pk", + "AttributeType": "S" + } + ], + "BillingMode": "PAY_PER_REQUEST", + "GlobalSecondaryIndexes": [ + { + "IndexName": "my-index-1", + "KeySchema": [ + { + "AttributeName": "gsi1pk", + "KeyType": "HASH" + } + ], + "Projection": { + "ProjectionType": "ALL" + }, + "WarmThroughput": { + "ReadUnitsPerSecond": 15000, + "WriteUnitsPerSecond": 6000 + } + }, + { + "IndexName": "my-index-2", + "KeySchema": [ + { + "AttributeName": "gsi1pk", + "KeyType": "HASH" + } + ], + "Projection": { + "ProjectionType": "ALL" + } + } + ], + "KeySchema": [ + { + "AttributeName": "id", + "KeyType": "HASH" + } + ], + "Replicas": [ + { + "GlobalSecondaryIndexes": [ + { + "IndexName": "my-index-1" + }, + { + "IndexName": "my-index-2" + } + ], + "Region": "us-west-2" + }, + { + "GlobalSecondaryIndexes": [ + { + "IndexName": "my-index-1" + }, + { + "IndexName": "my-index-2" + } + ], + "Region": "eu-west-1" + } + ], + "StreamSpecification": { + "StreamViewType": "NEW_AND_OLD_IMAGES" + }, + "WarmThroughput": { + "ReadUnitsPerSecond": 14000, + "WriteUnitsPerSecond": 5000 + } + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + } + }, + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb-v2.warm-throughput.js.snapshot/warmthroughputintegtestv2DefaultTestDeployAssertA2FD11C0.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb-v2.warm-throughput.js.snapshot/warmthroughputintegtestv2DefaultTestDeployAssertA2FD11C0.assets.json new file mode 100644 index 0000000000000..9f1c36d556723 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb-v2.warm-throughput.js.snapshot/warmthroughputintegtestv2DefaultTestDeployAssertA2FD11C0.assets.json @@ -0,0 +1,19 @@ +{ + "version": "38.0.1", + "files": { + "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { + "source": { + "path": "warmthroughputintegtestv2DefaultTestDeployAssertA2FD11C0.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb-v2.warm-throughput.js.snapshot/warmthroughputintegtestv2DefaultTestDeployAssertA2FD11C0.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb-v2.warm-throughput.js.snapshot/warmthroughputintegtestv2DefaultTestDeployAssertA2FD11C0.template.json new file mode 100644 index 0000000000000..ad9d0fb73d1dd --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb-v2.warm-throughput.js.snapshot/warmthroughputintegtestv2DefaultTestDeployAssertA2FD11C0.template.json @@ -0,0 +1,36 @@ +{ + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb-v2.warm-throughput.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb-v2.warm-throughput.ts new file mode 100644 index 0000000000000..cff0ce1740ac5 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb-v2.warm-throughput.ts @@ -0,0 +1,50 @@ +import { App, RemovalPolicy, Stack, StackProps } from 'aws-cdk-lib'; +import { Construct } from 'constructs'; +import * as dynamodb from 'aws-cdk-lib/aws-dynamodb'; +import { IntegTest } from '@aws-cdk/integ-tests-alpha'; + +export class TestStack extends Stack { + + readonly table: dynamodb.TableV2; + + constructor(scope: Construct, id: string, props?: StackProps) { + super(scope, id, props); + + this.table = new dynamodb.TableV2(this, 'TableTest1', { + partitionKey: { + name: 'id', + type: dynamodb.AttributeType.STRING, + }, + warmThroughput: { + readUnitsPerSecond: 14000, + writeUnitsPerSecond: 5000, + }, + replicas: [{ + region: 'us-west-2', + }], + globalSecondaryIndexes: [ + { + indexName: 'my-index-1', + partitionKey: { name: 'gsi1pk', type: dynamodb.AttributeType.STRING }, + warmThroughput: { + readUnitsPerSecond: 15000, + writeUnitsPerSecond: 6000, + }, + }, + { + indexName: 'my-index-2', + partitionKey: { name: 'gsi1pk', type: dynamodb.AttributeType.STRING }, + }, + ], + removalPolicy: RemovalPolicy.DESTROY, + }); + + } +} + +const app = new App(); +const stack = new TestStack(app, 'warm-throughput-stack-v2', { env: { region: 'eu-west-1' } }); + +new IntegTest(app, 'warm-throughput-integ-test-v2', { + testCases: [stack], +}); diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb.warm-throughput.js.snapshot/cdk.out b/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb.warm-throughput.js.snapshot/cdk.out new file mode 100644 index 0000000000000..c6e612584e352 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb.warm-throughput.js.snapshot/cdk.out @@ -0,0 +1 @@ +{"version":"38.0.1"} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb.warm-throughput.js.snapshot/integ.json b/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb.warm-throughput.js.snapshot/integ.json new file mode 100644 index 0000000000000..67c2aef09eb5b --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb.warm-throughput.js.snapshot/integ.json @@ -0,0 +1,12 @@ +{ + "version": "38.0.1", + "testCases": { + "warm-throughput-integ-test/DefaultTest": { + "stacks": [ + "warm-throughput-stack" + ], + "assertionStack": "warm-throughput-integ-test/DefaultTest/DeployAssert", + "assertionStackName": "warmthroughputintegtestDefaultTestDeployAssertA9A62BB4" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb.warm-throughput.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb.warm-throughput.js.snapshot/manifest.json new file mode 100644 index 0000000000000..a8a4f40ca87f2 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb.warm-throughput.js.snapshot/manifest.json @@ -0,0 +1,113 @@ +{ + "version": "38.0.1", + "artifacts": { + "warm-throughput-stack.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "warm-throughput-stack.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "warm-throughput-stack": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "warm-throughput-stack.template.json", + "terminationProtection": false, + "validateOnSynth": false, + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/49ac99a4afc26a3c2b01a72fd651e3635180fbb98a34d1996729d3bfa6489397.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "warm-throughput-stack.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "warm-throughput-stack.assets" + ], + "metadata": { + "/warm-throughput-stack/TableTest1/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "TableTest143E55AA2" + } + ], + "/warm-throughput-stack/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/warm-throughput-stack/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "warm-throughput-stack" + }, + "warmthroughputintegtestDefaultTestDeployAssertA9A62BB4.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "warmthroughputintegtestDefaultTestDeployAssertA9A62BB4.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "warmthroughputintegtestDefaultTestDeployAssertA9A62BB4": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "warmthroughputintegtestDefaultTestDeployAssertA9A62BB4.template.json", + "terminationProtection": false, + "validateOnSynth": false, + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "warmthroughputintegtestDefaultTestDeployAssertA9A62BB4.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "warmthroughputintegtestDefaultTestDeployAssertA9A62BB4.assets" + ], + "metadata": { + "/warm-throughput-integ-test/DefaultTest/DeployAssert/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/warm-throughput-integ-test/DefaultTest/DeployAssert/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "warm-throughput-integ-test/DefaultTest/DeployAssert" + }, + "Tree": { + "type": "cdk:tree", + "properties": { + "file": "tree.json" + } + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb.warm-throughput.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb.warm-throughput.js.snapshot/tree.json new file mode 100644 index 0000000000000..97b2aee402005 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb.warm-throughput.js.snapshot/tree.json @@ -0,0 +1,178 @@ +{ + "version": "tree-0.1", + "tree": { + "id": "App", + "path": "", + "children": { + "warm-throughput-stack": { + "id": "warm-throughput-stack", + "path": "warm-throughput-stack", + "children": { + "TableTest1": { + "id": "TableTest1", + "path": "warm-throughput-stack/TableTest1", + "children": { + "Resource": { + "id": "Resource", + "path": "warm-throughput-stack/TableTest1/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::DynamoDB::Table", + "aws:cdk:cloudformation:props": { + "attributeDefinitions": [ + { + "attributeName": "id", + "attributeType": "S" + }, + { + "attributeName": "gsi1pk", + "attributeType": "S" + } + ], + "globalSecondaryIndexes": [ + { + "indexName": "my-index", + "keySchema": [ + { + "attributeName": "gsi1pk", + "keyType": "HASH" + } + ], + "projection": { + "projectionType": "ALL" + }, + "provisionedThroughput": { + "readCapacityUnits": 5, + "writeCapacityUnits": 5 + }, + "warmThroughput": { + "readUnitsPerSecond": 15000, + "writeUnitsPerSecond": 5000 + } + } + ], + "keySchema": [ + { + "attributeName": "id", + "keyType": "HASH" + } + ], + "provisionedThroughput": { + "readCapacityUnits": 5, + "writeCapacityUnits": 5 + }, + "warmThroughput": { + "readUnitsPerSecond": 14000, + "writeUnitsPerSecond": 5000 + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "ScalingRole": { + "id": "ScalingRole", + "path": "warm-throughput-stack/TableTest1/ScalingRole", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "warm-throughput-stack/BootstrapVersion", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "warm-throughput-stack/CheckBootstrapVersion", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "warm-throughput-integ-test": { + "id": "warm-throughput-integ-test", + "path": "warm-throughput-integ-test", + "children": { + "DefaultTest": { + "id": "DefaultTest", + "path": "warm-throughput-integ-test/DefaultTest", + "children": { + "Default": { + "id": "Default", + "path": "warm-throughput-integ-test/DefaultTest/Default", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "DeployAssert": { + "id": "DeployAssert", + "path": "warm-throughput-integ-test/DefaultTest/DeployAssert", + "children": { + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "warm-throughput-integ-test/DefaultTest/DeployAssert/BootstrapVersion", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "warm-throughput-integ-test/DefaultTest/DeployAssert/CheckBootstrapVersion", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.IntegTestCase", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.IntegTest", + "version": "0.0.0" + } + }, + "Tree": { + "id": "Tree", + "path": "Tree", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb.warm-throughput.js.snapshot/warm-throughput-stack.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb.warm-throughput.js.snapshot/warm-throughput-stack.assets.json new file mode 100644 index 0000000000000..bd15495c0b68a --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb.warm-throughput.js.snapshot/warm-throughput-stack.assets.json @@ -0,0 +1,19 @@ +{ + "version": "38.0.1", + "files": { + "49ac99a4afc26a3c2b01a72fd651e3635180fbb98a34d1996729d3bfa6489397": { + "source": { + "path": "warm-throughput-stack.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "49ac99a4afc26a3c2b01a72fd651e3635180fbb98a34d1996729d3bfa6489397.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb.warm-throughput.js.snapshot/warm-throughput-stack.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb.warm-throughput.js.snapshot/warm-throughput-stack.template.json new file mode 100644 index 0000000000000..a058b4d0c432f --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb.warm-throughput.js.snapshot/warm-throughput-stack.template.json @@ -0,0 +1,91 @@ +{ + "Resources": { + "TableTest143E55AA2": { + "Type": "AWS::DynamoDB::Table", + "Properties": { + "AttributeDefinitions": [ + { + "AttributeName": "id", + "AttributeType": "S" + }, + { + "AttributeName": "gsi1pk", + "AttributeType": "S" + } + ], + "GlobalSecondaryIndexes": [ + { + "IndexName": "my-index", + "KeySchema": [ + { + "AttributeName": "gsi1pk", + "KeyType": "HASH" + } + ], + "Projection": { + "ProjectionType": "ALL" + }, + "ProvisionedThroughput": { + "ReadCapacityUnits": 5, + "WriteCapacityUnits": 5 + }, + "WarmThroughput": { + "ReadUnitsPerSecond": 15000, + "WriteUnitsPerSecond": 5000 + } + } + ], + "KeySchema": [ + { + "AttributeName": "id", + "KeyType": "HASH" + } + ], + "ProvisionedThroughput": { + "ReadCapacityUnits": 5, + "WriteCapacityUnits": 5 + }, + "WarmThroughput": { + "ReadUnitsPerSecond": 14000, + "WriteUnitsPerSecond": 5000 + } + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + } + }, + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb.warm-throughput.js.snapshot/warmthroughputintegtestDefaultTestDeployAssertA9A62BB4.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb.warm-throughput.js.snapshot/warmthroughputintegtestDefaultTestDeployAssertA9A62BB4.assets.json new file mode 100644 index 0000000000000..fb5392eb67670 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb.warm-throughput.js.snapshot/warmthroughputintegtestDefaultTestDeployAssertA9A62BB4.assets.json @@ -0,0 +1,19 @@ +{ + "version": "38.0.1", + "files": { + "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { + "source": { + "path": "warmthroughputintegtestDefaultTestDeployAssertA9A62BB4.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb.warm-throughput.js.snapshot/warmthroughputintegtestDefaultTestDeployAssertA9A62BB4.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb.warm-throughput.js.snapshot/warmthroughputintegtestDefaultTestDeployAssertA9A62BB4.template.json new file mode 100644 index 0000000000000..ad9d0fb73d1dd --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb.warm-throughput.js.snapshot/warmthroughputintegtestDefaultTestDeployAssertA9A62BB4.template.json @@ -0,0 +1,36 @@ +{ + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb.warm-throughput.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb.warm-throughput.ts new file mode 100644 index 0000000000000..5e297d83331b3 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb.warm-throughput.ts @@ -0,0 +1,42 @@ +import { App, RemovalPolicy, Stack, StackProps } from 'aws-cdk-lib'; +import { Construct } from 'constructs'; +import * as dynamodb from 'aws-cdk-lib/aws-dynamodb'; +import { IntegTest } from '@aws-cdk/integ-tests-alpha'; + +export class TestStack extends Stack { + + readonly table: dynamodb.Table; + + constructor(scope: Construct, id: string, props?: StackProps) { + super(scope, id, props); + + this.table = new dynamodb.Table(this, 'TableTest1', { + partitionKey: { + name: 'id', + type: dynamodb.AttributeType.STRING, + }, + warmThroughput: { + readUnitsPerSecond: 14000, + writeUnitsPerSecond: 5000, + }, + removalPolicy: RemovalPolicy.DESTROY, + }); + + this.table.addGlobalSecondaryIndex({ + indexName: 'my-index', + partitionKey: { name: 'gsi1pk', type: dynamodb.AttributeType.STRING }, + warmThroughput: { + readUnitsPerSecond: 15000, + writeUnitsPerSecond: 5000, + }, + }); + + } +} + +const app = new App(); +const stack = new TestStack(app, 'warm-throughput-stack', {}); + +new IntegTest(app, 'warm-throughput-integ-test', { + testCases: [stack], +}); diff --git a/packages/aws-cdk-lib/aws-dynamodb/README.md b/packages/aws-cdk-lib/aws-dynamodb/README.md index 41244dec60ea9..133c1b9efa296 100644 --- a/packages/aws-cdk-lib/aws-dynamodb/README.md +++ b/packages/aws-cdk-lib/aws-dynamodb/README.md @@ -229,6 +229,25 @@ const globalTable = new dynamodb.TableV2(this, 'Table', { Further reading: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.ReadWriteCapacityMode.html +## Warm Throughput +Warm throughput refers to the number of read and write operations your DynamoDB table can instantaneously support. + +This optional configuration allows you to pre-warm your table or index to handle anticipated throughput, ensuring optimal performance under expected load. + +The Warm Throughput configuration settings are automatically replicated across all Global Table replicas. + +```ts +const table = new dynamodb.TableV2(this, 'Table', { + partitionKey: { name: 'id', type: dynamodb.AttributeType.STRING }, + warmThroughput: { + readUnitsPerSecond: 15000, + writeUnitsPerSecond: 20000, + }, +}); +``` +Further reading: +https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/warm-throughput.html + ## Encryption All user data stored in a DynamoDB table is fully encrypted at rest. When creating an instance of the `TableV2` construct, you can select the following table encryption options: diff --git a/packages/aws-cdk-lib/aws-dynamodb/TABLE_V1_API.md b/packages/aws-cdk-lib/aws-dynamodb/TABLE_V1_API.md index 34cf25434d6b2..9d62a170a3676 100644 --- a/packages/aws-cdk-lib/aws-dynamodb/TABLE_V1_API.md +++ b/packages/aws-cdk-lib/aws-dynamodb/TABLE_V1_API.md @@ -60,6 +60,25 @@ const table = new dynamodb.Table(this, 'Table', { Further reading: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.ReadWriteCapacityMode. +## Warm Throughput +Warm throughput refers to the number of read and write operations your DynamoDB table can instantaneously support. + +This optional configuration allows you to pre-warm your table or index to handle anticipated throughput, ensuring optimal performance under expected load. + +Note: The Warm Throughput feature is not available for Global Table replicas using `Table` construct; use the `TableV2` construct instead to enable this functionality. + +```ts +const table = new dynamodb.Table(this, 'Table', { + partitionKey: { name: 'id', type: dynamodb.AttributeType.STRING }, + warmThroughput: { + readUnitsPerSecond: 15000, + writeUnitsPerSecond: 20000, + }, +}); +``` +Further reading: +https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/warm-throughput.html + ## Table Class DynamoDB supports two table classes: diff --git a/packages/aws-cdk-lib/aws-dynamodb/lib/shared.ts b/packages/aws-cdk-lib/aws-dynamodb/lib/shared.ts index 1955ef7fccd35..d73540650d99d 100644 --- a/packages/aws-cdk-lib/aws-dynamodb/lib/shared.ts +++ b/packages/aws-cdk-lib/aws-dynamodb/lib/shared.ts @@ -85,6 +85,22 @@ export interface Attribute { readonly type: AttributeType; } +/** + * Reference to WarmThroughput for a DynamoDB table + */ +export interface WarmThroughput { + /** + * Configures the number of read units per second a table will be able to handle instantly + * @default - no readUnitsPerSecond configured + */ + readonly readUnitsPerSecond?: number; + /** + * Configures the number of write units per second a table will be able to handle instantly + * @default - no writeUnitsPerSecond configured + */ + readonly writeUnitsPerSecond?: number; +} + /** * Data types for attributes within a table * diff --git a/packages/aws-cdk-lib/aws-dynamodb/lib/table-v2.ts b/packages/aws-cdk-lib/aws-dynamodb/lib/table-v2.ts index ac79fb6fad792..1dd55b0ba23f6 100644 --- a/packages/aws-cdk-lib/aws-dynamodb/lib/table-v2.ts +++ b/packages/aws-cdk-lib/aws-dynamodb/lib/table-v2.ts @@ -11,6 +11,7 @@ import { SecondaryIndexProps, StreamViewType, TableClass, + WarmThroughput, } from './shared'; import { ITableV2, TableBaseV2 } from './table-v2-base'; import { PolicyDocument } from '../../aws-iam'; @@ -118,6 +119,13 @@ export interface GlobalSecondaryIndexPropsV2 extends SecondaryIndexProps { * @default - inherited from the primary table. */ readonly maxWriteRequestUnits?: number; + + /** + * The warm throughput configuration for the global secondary index. + * + * @default - no warm throughput is configured + */ + readonly warmThroughput?: WarmThroughput; } /** @@ -298,6 +306,13 @@ export interface TablePropsV2 extends TableOptionsV2 { * @default TableEncryptionV2.dynamoOwnedKey() */ readonly encryption?: TableEncryptionV2; + + /** + * The warm throughput configuration for the table. + * + * @default - no warm throughput is configured + */ + readonly warmThroughput?: WarmThroughput; } /** @@ -576,6 +591,7 @@ export class TableV2 extends TableBaseV2 { timeToLiveSpecification: props.timeToLiveAttribute ? { attributeName: props.timeToLiveAttribute, enabled: true } : undefined, + warmThroughput: props.warmThroughput ?? undefined, }); resource.applyRemovalPolicy(props.removalPolicy); @@ -741,6 +757,8 @@ export class TableV2 extends TableBaseV2 { props.maxReadRequestUnits && this.globalSecondaryIndexMaxReadUnits.set(props.indexName, props.maxReadRequestUnits); + const warmThroughput = props.warmThroughput ?? undefined; + const writeOnDemandThroughputSettings: CfnGlobalTable.WriteOnDemandThroughputSettingsProperty | undefined = props.maxWriteRequestUnits ? { maxWriteRequestUnits: props.maxWriteRequestUnits } : undefined; @@ -751,6 +769,7 @@ export class TableV2 extends TableBaseV2 { projection, writeProvisionedThroughputSettings, writeOnDemandThroughputSettings, + warmThroughput, }; } diff --git a/packages/aws-cdk-lib/aws-dynamodb/lib/table.ts b/packages/aws-cdk-lib/aws-dynamodb/lib/table.ts index 0b381a5f90dcb..a020bf33b0011 100644 --- a/packages/aws-cdk-lib/aws-dynamodb/lib/table.ts +++ b/packages/aws-cdk-lib/aws-dynamodb/lib/table.ts @@ -8,7 +8,7 @@ import { ScalableTableAttribute } from './scalable-table-attribute'; import { Operation, OperationsMetricOptions, SystemErrorsForOperationsMetricOptions, Attribute, BillingMode, ProjectionType, ITable, SecondaryIndexProps, TableClass, - LocalSecondaryIndexProps, TableEncryption, StreamViewType, + LocalSecondaryIndexProps, TableEncryption, StreamViewType, WarmThroughput, } from './shared'; import * as appscaling from '../../aws-applicationautoscaling'; import * as cloudwatch from '../../aws-cloudwatch'; @@ -259,6 +259,14 @@ export interface TableOptions extends SchemaOptions { */ readonly billingMode?: BillingMode; + /** + * Specify values to pre-warm you DynamoDB Table + * Warm Throughput feature is not available for Global Table replicas using the `Table` construct. To enable Warm Throughput, use the `TableV2` construct instead. + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-dynamodb-table.html#cfn-dynamodb-table-warmthroughput + * @default - warm throughput is not configured + */ + readonly warmThroughput?: WarmThroughput; + /** * Whether point-in-time recovery is enabled. * @default - point-in-time recovery is disabled @@ -457,6 +465,13 @@ export interface GlobalSecondaryIndexProps extends SecondaryIndexProps, SchemaOp */ readonly maxWriteRequestUnits?: number; + /** + * The warm throughput configuration for the global secondary index. + * + * @default - no warm throughput is configured + */ + readonly warmThroughput?: WarmThroughput; + /** * Whether CloudWatch contributor insights is enabled for the specified global secondary index. * @@ -1187,6 +1202,7 @@ export class Table extends TableBase { resourcePolicy: props.resourcePolicy ? { policyDocument: props.resourcePolicy } : undefined, + warmThroughput: props.warmThroughput?? undefined, }); this.table.applyRemovalPolicy(props.removalPolicy); @@ -1249,6 +1265,7 @@ export class Table extends TableBase { maxWriteRequestUnits: props.maxWriteRequestUnits || undefined, }, } : undefined), + warmThroughput: props.warmThroughput ?? undefined, }); this.secondaryIndexSchemas.set(props.indexName, { diff --git a/packages/aws-cdk-lib/aws-dynamodb/test/dynamodb.test.ts b/packages/aws-cdk-lib/aws-dynamodb/test/dynamodb.test.ts index 420d8ce7a8290..0a95fea266ea3 100644 --- a/packages/aws-cdk-lib/aws-dynamodb/test/dynamodb.test.ts +++ b/packages/aws-cdk-lib/aws-dynamodb/test/dynamodb.test.ts @@ -3642,3 +3642,144 @@ test('Resource policy test', () => { }, }); }); + +test('Warm Throughput test on-demand', () => { + // GIVEN + const app = new App(); + const stack = new Stack(app, 'Stack'); + + // WHEN + const table = new Table(stack, 'Table', { + partitionKey: { name: 'id', type: AttributeType.STRING }, + warmThroughput: { + readUnitsPerSecond: 13000, + writeUnitsPerSecond: 5000, + }, + }); + + table.addGlobalSecondaryIndex({ + indexName: 'my-index-1', + partitionKey: { name: 'gsi1pk', type: AttributeType.STRING }, + warmThroughput: { + readUnitsPerSecond: 15000, + writeUnitsPerSecond: 6000, + }, + }); + + table.addGlobalSecondaryIndex({ + indexName: 'my-index-2', + partitionKey: { name: 'gsi2pk', type: AttributeType.STRING }, + }); + + // THEN + Template.fromStack(stack).hasResourceProperties('AWS::DynamoDB::Table', { + KeySchema: [ + { AttributeName: 'id', KeyType: 'HASH' }, + ], + AttributeDefinitions: [ + { AttributeName: 'id', AttributeType: 'S' }, + { AttributeName: 'gsi1pk', AttributeType: 'S' }, + { AttributeName: 'gsi2pk', AttributeType: 'S' }, + ], + WarmThroughput: { + ReadUnitsPerSecond: 13000, + WriteUnitsPerSecond: 5000, + }, + GlobalSecondaryIndexes: [ + { + IndexName: 'my-index-1', + KeySchema: [ + { AttributeName: 'gsi1pk', KeyType: 'HASH' }, + ], + Projection: { ProjectionType: 'ALL' }, + WarmThroughput: { + ReadUnitsPerSecond: 15000, + WriteUnitsPerSecond: 6000, + }, + }, + { + IndexName: 'my-index-2', + KeySchema: [ + { AttributeName: 'gsi2pk', KeyType: 'HASH' }, + ], + Projection: { ProjectionType: 'ALL' }, + }, + ], + }); + +}); + +test('Warm Throughput test provisioned', () => { + // GIVEN + const app = new App(); + const stack = new Stack(app, 'Stack'); + + // WHEN + const table = new Table(stack, 'Table', { + partitionKey: { name: 'id', type: AttributeType.STRING }, + readCapacity: 5, + writeCapacity: 6, + warmThroughput: { + readUnitsPerSecond: 2000, + writeUnitsPerSecond: 1000, + }, + }); + + table.addGlobalSecondaryIndex({ + indexName: 'my-index-1', + partitionKey: { name: 'gsi1pk', type: AttributeType.STRING }, + readCapacity: 7, + writeCapacity: 8, + warmThroughput: { + readUnitsPerSecond: 3000, + writeUnitsPerSecond: 4000, + }, + }); + + table.addGlobalSecondaryIndex({ + indexName: 'my-index-2', + partitionKey: { name: 'gsi2pk', type: AttributeType.STRING }, + readCapacity: 9, + writeCapacity: 10, + }); + + // THEN + Template.fromStack(stack).hasResourceProperties('AWS::DynamoDB::Table', { + KeySchema: [ + { AttributeName: 'id', KeyType: 'HASH' }, + ], + AttributeDefinitions: [ + { AttributeName: 'id', AttributeType: 'S' }, + { AttributeName: 'gsi1pk', AttributeType: 'S' }, + { AttributeName: 'gsi2pk', AttributeType: 'S' }, + ], + WarmThroughput: { + ReadUnitsPerSecond: 2000, + WriteUnitsPerSecond: 1000, + }, + ProvisionedThroughput: { ReadCapacityUnits: 5, WriteCapacityUnits: 6 }, + GlobalSecondaryIndexes: [ + { + IndexName: 'my-index-1', + KeySchema: [ + { AttributeName: 'gsi1pk', KeyType: 'HASH' }, + ], + Projection: { ProjectionType: 'ALL' }, + WarmThroughput: { + ReadUnitsPerSecond: 3000, + WriteUnitsPerSecond: 4000, + }, + ProvisionedThroughput: { ReadCapacityUnits: 7, WriteCapacityUnits: 8 }, + }, + { + IndexName: 'my-index-2', + KeySchema: [ + { AttributeName: 'gsi2pk', KeyType: 'HASH' }, + ], + Projection: { ProjectionType: 'ALL' }, + ProvisionedThroughput: { ReadCapacityUnits: 9, WriteCapacityUnits: 10 }, + }, + ], + }); + +}); diff --git a/packages/aws-cdk-lib/aws-dynamodb/test/table-v2.test.ts b/packages/aws-cdk-lib/aws-dynamodb/test/table-v2.test.ts index a4c9c66808ff2..b53c316199eff 100644 --- a/packages/aws-cdk-lib/aws-dynamodb/test/table-v2.test.ts +++ b/packages/aws-cdk-lib/aws-dynamodb/test/table-v2.test.ts @@ -3109,3 +3109,69 @@ test('Resource policy test', () => { ], }); }); + +test('Warm Throughput test on-demand', () => { + // GIVEN + const stack = new Stack(undefined, 'Stack', { env: { region: 'eu-west-1' } }); + + // WHEN + const table = new TableV2(stack, 'Table', { + partitionKey: { name: 'id', type: AttributeType.STRING }, + warmThroughput: { + readUnitsPerSecond: 13000, + writeUnitsPerSecond: 5000, + }, + replicas: [{ + region: 'us-west-2', + }], + globalSecondaryIndexes: [{ + indexName: 'my-index-1', + partitionKey: { name: 'gsi1pk', type: AttributeType.STRING }, + warmThroughput: { + readUnitsPerSecond: 15000, + writeUnitsPerSecond: 6000, + }, + }, + { + indexName: 'my-index-2', + partitionKey: { name: 'gsi2pk', type: AttributeType.STRING }, + }], + }); + + // THEN + Template.fromStack(stack).hasResourceProperties('AWS::DynamoDB::GlobalTable', { + KeySchema: [ + { AttributeName: 'id', KeyType: 'HASH' }, + ], + AttributeDefinitions: [ + { AttributeName: 'id', AttributeType: 'S' }, + { AttributeName: 'gsi1pk', AttributeType: 'S' }, + { AttributeName: 'gsi2pk', AttributeType: 'S' }, + ], + WarmThroughput: { + ReadUnitsPerSecond: 13000, + WriteUnitsPerSecond: 5000, + }, + GlobalSecondaryIndexes: [ + { + IndexName: 'my-index-1', + KeySchema: [ + { AttributeName: 'gsi1pk', KeyType: 'HASH' }, + ], + Projection: { ProjectionType: 'ALL' }, + WarmThroughput: { + ReadUnitsPerSecond: 15000, + WriteUnitsPerSecond: 6000, + }, + }, + { + IndexName: 'my-index-2', + KeySchema: [ + { AttributeName: 'gsi2pk', KeyType: 'HASH' }, + ], + Projection: { ProjectionType: 'ALL' }, + }, + ], + }); + +});