mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 22:11:36 -05:00
fix(cloudformation): keep a generated DynamoDB table name across updates (#3721)
A table without an explicit TableName got a fresh generated name on every UpdateStack, which created a second table and re-pointed Ref at it. TableName is create-only, so the provisioner now resolves the name through ProvisionContext.stablePhysicalName: the template's name, else the name the resource already has, and only failing both a generated one. This is the same fix earlier batches applied to other types, split out of #3699 at the reviewers' request so that refactor stayed behaviour-preserving.
This commit is contained in:
1 parent
32594a9dd5
commit
2d444801fd
2 files changed
+35
-4
No files matched your search
+5
-4
@@ -99,10 +99,11 @@ public class DynamoDbCfnProvisioner implements CfnResourceProvisioner {
|
||||
private void provisionTable(StackResource r, JsonNode props, ProvisionContext ctx) {
|
||||
CloudFormationTemplateEngine engine = ctx.engine();
|
||||
String region = ctx.region();
|
||||
String tableName = ctx.resolveOptional(props, "TableName");
|
||||
if (tableName == null || tableName.isBlank()) {
|
||||
tableName = ctx.generatePhysicalName(r.getLogicalId(), TABLE_NAME_MAX_LENGTH, false);
|
||||
}
|
||||
// TableName is create-only, so an update without one must keep the name generated on
|
||||
// create rather than mint another: a fresh name here created a second table on every
|
||||
// UpdateStack and re-pointed Ref at it.
|
||||
String tableName = ctx.stablePhysicalName(ctx.resolveOptional(props, "TableName"),
|
||||
r.getLogicalId(), TABLE_NAME_MAX_LENGTH, false);
|
||||
|
||||
List<KeySchemaElement> keySchema = new ArrayList<>();
|
||||
List<AttributeDefinition> attrDefs = new ArrayList<>();
|
||||
|
||||
Reference in new issue
Block a user