CreateGlobalTable

Description

The CreateGlobalTable function creates a global table from an already created table. A global table creates a replication relationship between two or more DynamoDB tables with the same table name in the provided regions.

For more information, see CreateGlobalTable.

Category

History

ColdFusion (2021 release): Added this function.

Syntax

serviceHandle.CreateGlobalTable(requestParameters)
serviceHandle.CreateGlobalTable(requestParameters)
serviceHandle.CreateGlobalTable(requestParameters)

Parameters

See parameters of CreateGlobalTable.

Example

<cfscript>
// configuration for first region
cred = {
"credentialAlias" : "myalias",
"vendorName" : "AWS",
"region" : "us-east-2",
"secretAccessKey" : "xxxxx",
"accessKeyId" : "xxxx"
}
config = {
"serviceName" = "DYNAMODB"
}
dynamoUSEast2 = getCloudService(cred, config);
// configuration for second region
cred = {
"credentialAlias" : "myalias",
"vendorName" : "AWS",
"region" : "us-east-1",
"secretAccessKey" : "xxxxx",
"accessKeyId" : "xxxx"
}
config = {
"serviceName" = "DYNAMODB"
}
dynamoUSEast1 = cloudService(cred, config);
tableName="Movies005"
// create table
tableStruct={
"TableName" : "#tableName#",
"KeySchema":[
{ AttributeName: "year", KeyType: "HASH"}, //Partition key
{ AttributeName: "title", KeyType: "RANGE"} //Sort key
],
"AttributeDefinitions":[
{ AttributeName: "year", AttributeType: "N" },
{ AttributeName: "title", AttributeType: "S" }
],
"ProvisionedThroughput":{
ReadCapacityUnits: 10,
WriteCapacityUnits: 10
},
"StreamSpecification": {
"StreamEnabled": true, // enable stream for replication
"StreamViewType": "NEW_AND_OLD_IMAGES"
}
}
// create table in both regions
dynamoUSEast1.createTable(tableStruct)
dynamoUSEast2.createTable(tableStruct)
// cred and configuration for replication
cred = {
"credentialAlias" : "myalias",
"vendorName" : "AWS",
"region" : "us-east-2",
"secretAccessKey" : "xxxxx",
"accessKeyId" : "xxxx"
}
config = {
"serviceName" = "DYNAMODB"
}
dynamo = cloudService(cred, config)
// create global table
globalTableStruct={
"GlobalTableName": "#tableName#",
"ReplicationGroup": [
{
"RegionName": "us-east-2"
},
{
"RegionName": "us-east-1"
}
]
}
globalTableResponse=dynamo.CreateGlobalTable(globalTableStruct)
writeDump(globalTableResponse)
</cfscript>
<cfscript> // configuration for first region cred = { "credentialAlias" : "myalias", "vendorName" : "AWS", "region" : "us-east-2", "secretAccessKey" : "xxxxx", "accessKeyId" : "xxxx" } config = { "serviceName" = "DYNAMODB" } dynamoUSEast2 = getCloudService(cred, config); // configuration for second region cred = { "credentialAlias" : "myalias", "vendorName" : "AWS", "region" : "us-east-1", "secretAccessKey" : "xxxxx", "accessKeyId" : "xxxx" } config = { "serviceName" = "DYNAMODB" } dynamoUSEast1 = cloudService(cred, config); tableName="Movies005" // create table tableStruct={ "TableName" : "#tableName#", "KeySchema":[ { AttributeName: "year", KeyType: "HASH"}, //Partition key { AttributeName: "title", KeyType: "RANGE"} //Sort key ], "AttributeDefinitions":[ { AttributeName: "year", AttributeType: "N" }, { AttributeName: "title", AttributeType: "S" } ], "ProvisionedThroughput":{ ReadCapacityUnits: 10, WriteCapacityUnits: 10 }, "StreamSpecification": { "StreamEnabled": true, // enable stream for replication "StreamViewType": "NEW_AND_OLD_IMAGES" } } // create table in both regions dynamoUSEast1.createTable(tableStruct) dynamoUSEast2.createTable(tableStruct) // cred and configuration for replication cred = { "credentialAlias" : "myalias", "vendorName" : "AWS", "region" : "us-east-2", "secretAccessKey" : "xxxxx", "accessKeyId" : "xxxx" } config = { "serviceName" = "DYNAMODB" } dynamo = cloudService(cred, config) // create global table globalTableStruct={ "GlobalTableName": "#tableName#", "ReplicationGroup": [ { "RegionName": "us-east-2" }, { "RegionName": "us-east-1" } ] } globalTableResponse=dynamo.CreateGlobalTable(globalTableStruct) writeDump(globalTableResponse) </cfscript>
<cfscript> 
  // configuration for first region 
  cred = { 
    "credentialAlias" : "myalias", 
    "vendorName" : "AWS", 
    "region" : "us-east-2", 
    "secretAccessKey" : "xxxxx", 
    "accessKeyId" : "xxxx" 
  } 
  config = { 
    "serviceName" = "DYNAMODB" 
  } 
  dynamoUSEast2 = getCloudService(cred, config); 
  // configuration for second region 
 cred = { 
    "credentialAlias" : "myalias", 
    "vendorName" : "AWS", 
    "region" : "us-east-1", 
    "secretAccessKey" : "xxxxx", 
    "accessKeyId" : "xxxx" 
  } 
  config = { 
    "serviceName" = "DYNAMODB" 
  } 
  dynamoUSEast1 = cloudService(cred, config); 
 
  tableName="Movies005" 
  // create table 
  tableStruct={ 
    "TableName" : "#tableName#", 
    "KeySchema":[ 
        { AttributeName: "year", KeyType: "HASH"},  //Partition key 
        { AttributeName: "title", KeyType: "RANGE"}  //Sort key 
    ], 
    "AttributeDefinitions":[ 
        { AttributeName: "year", AttributeType: "N" }, 
        { AttributeName: "title", AttributeType: "S" } 
    ], 
    "ProvisionedThroughput":{ 
        ReadCapacityUnits: 10, 
        WriteCapacityUnits: 10 
    }, 
    "StreamSpecification": { 
        "StreamEnabled": true,  // enable stream for replication 
        "StreamViewType": "NEW_AND_OLD_IMAGES" 
    } 
  } 
  // create table in both regions 
  dynamoUSEast1.createTable(tableStruct) 
  dynamoUSEast2.createTable(tableStruct) 
 
  // cred and configuration for replication 
  cred = { 
    "credentialAlias" : "myalias", 
    "vendorName" : "AWS", 
    "region" : "us-east-2", 
    "secretAccessKey" : "xxxxx", 
    "accessKeyId" : "xxxx" 
  } 
  config = { 
    "serviceName" = "DYNAMODB" 
  } 
  dynamo = cloudService(cred, config) 
 
  // create global table 
  globalTableStruct={ 
    "GlobalTableName": "#tableName#", 
    "ReplicationGroup": [ 
      { 
         "RegionName": "us-east-2" 
      }, 
      { 
         "RegionName": "us-east-1" 
      } 
   ] 
  } 
  globalTableResponse=dynamo.CreateGlobalTable(globalTableStruct) 
  writeDump(globalTableResponse) 
</cfscript> 

Output

CreateGlobalTable output
CreateGlobalTable output

Get help faster and easier

New user?