diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.record-weight-from-cfnparameter.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.record-weight-from-cfnparameter.js.snapshot/manifest.json index 73fe02989ebb3..2bec5691b4714 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.record-weight-from-cfnparameter.js.snapshot/manifest.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.record-weight-from-cfnparameter.js.snapshot/manifest.json @@ -19,7 +19,7 @@ "notificationArns": [], "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}/a45fab474cff7ba97e8d31e7eb404ad1526a3bac8e68dbc1951fcc7c99fe2a53.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/301b5b33e5e387daebea8b387f5d80fd6b29eadc0ea88a23bee6b15a7b159ee9.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ @@ -65,28 +65,28 @@ "data": "RecordWeight3" } ], - "/record-weight-from-cfnparameter/RecordWeightedFromCfnParameter0/Resource": [ + "/record-weight-from-cfnparameter/RecordWithParamWeight0/Resource": [ { "type": "aws:cdk:logicalId", - "data": "RecordWeightedFromCfnParameter0FB5DFC65" + "data": "RecordWithParamWeight01950FDF7" } ], - "/record-weight-from-cfnparameter/RecordWeightedFromCfnParameter1/Resource": [ + "/record-weight-from-cfnparameter/RecordWithParamWeight1/Resource": [ { "type": "aws:cdk:logicalId", - "data": "RecordWeightedFromCfnParameter11D8E5896" + "data": "RecordWithParamWeight182FF0BDE" } ], - "/record-weight-from-cfnparameter/RecordWeightedFromCfnParameter2/Resource": [ + "/record-weight-from-cfnparameter/RecordWithParamWeight2/Resource": [ { "type": "aws:cdk:logicalId", - "data": "RecordWeightedFromCfnParameter2B12A1DFB" + "data": "RecordWithParamWeight2C5120D0E" } ], - "/record-weight-from-cfnparameter/RecordWeightedFromCfnParameter3/Resource": [ + "/record-weight-from-cfnparameter/RecordWithParamWeight3/Resource": [ { "type": "aws:cdk:logicalId", - "data": "RecordWeightedFromCfnParameter3D5E67423" + "data": "RecordWithParamWeight37D431545" } ], "/record-weight-from-cfnparameter/BootstrapVersion": [ @@ -100,6 +100,42 @@ "type": "aws:cdk:logicalId", "data": "CheckBootstrapVersion" } + ], + "RecordWeightedFromParameter04394A234": [ + { + "type": "aws:cdk:logicalId", + "data": "RecordWeightedFromParameter04394A234", + "trace": [ + "!!DESTRUCTIVE_CHANGES: WILL_DESTROY" + ] + } + ], + "RecordWeightedFromParameter18B61ED39": [ + { + "type": "aws:cdk:logicalId", + "data": "RecordWeightedFromParameter18B61ED39", + "trace": [ + "!!DESTRUCTIVE_CHANGES: WILL_DESTROY" + ] + } + ], + "RecordWeightedFromParameter29583BE12": [ + { + "type": "aws:cdk:logicalId", + "data": "RecordWeightedFromParameter29583BE12", + "trace": [ + "!!DESTRUCTIVE_CHANGES: WILL_DESTROY" + ] + } + ], + "RecordWeightedFromParameter3511F1BB5": [ + { + "type": "aws:cdk:logicalId", + "data": "RecordWeightedFromParameter3511F1BB5", + "trace": [ + "!!DESTRUCTIVE_CHANGES: WILL_DESTROY" + ] + } ] }, "displayName": "record-weight-from-cfnparameter" diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.record-weight-from-cfnparameter.js.snapshot/record-weight-from-cfnparameter.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.record-weight-from-cfnparameter.js.snapshot/record-weight-from-cfnparameter.assets.json index 29d991a127f86..710b315e75cf4 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.record-weight-from-cfnparameter.js.snapshot/record-weight-from-cfnparameter.assets.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.record-weight-from-cfnparameter.js.snapshot/record-weight-from-cfnparameter.assets.json @@ -1,7 +1,7 @@ { "version": "38.0.1", "files": { - "a45fab474cff7ba97e8d31e7eb404ad1526a3bac8e68dbc1951fcc7c99fe2a53": { + "301b5b33e5e387daebea8b387f5d80fd6b29eadc0ea88a23bee6b15a7b159ee9": { "source": { "path": "record-weight-from-cfnparameter.template.json", "packaging": "file" @@ -9,7 +9,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "a45fab474cff7ba97e8d31e7eb404ad1526a3bac8e68dbc1951fcc7c99fe2a53.json", + "objectKey": "301b5b33e5e387daebea8b387f5d80fd6b29eadc0ea88a23bee6b15a7b159ee9.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.record-weight-from-cfnparameter.js.snapshot/record-weight-from-cfnparameter.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.record-weight-from-cfnparameter.js.snapshot/record-weight-from-cfnparameter.template.json index 8f14a21601af3..dc4d98afa2aaf 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.record-weight-from-cfnparameter.js.snapshot/record-weight-from-cfnparameter.template.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.record-weight-from-cfnparameter.js.snapshot/record-weight-from-cfnparameter.template.json @@ -6,7 +6,7 @@ "Name": "cdk.dev." } }, - "RecordWeightedFromCfnParameter0FB5DFC65": { + "RecordWithParamWeight01950FDF7": { "Type": "AWS::Route53::RecordSet", "Properties": { "HostedZoneId": { @@ -24,7 +24,7 @@ { "Ref": "RecordWeight0" }, - "_ID_recordweigParameter04970FE98" + "_ID_recordweightParamWeight059BCC4E1" ] ] }, @@ -35,7 +35,7 @@ } } }, - "RecordWeightedFromCfnParameter11D8E5896": { + "RecordWithParamWeight182FF0BDE": { "Type": "AWS::Route53::RecordSet", "Properties": { "HostedZoneId": { @@ -53,7 +53,7 @@ { "Ref": "RecordWeight1" }, - "_ID_recordweigParameter1EB51A657" + "_ID_recordweightParamWeight1304B1475" ] ] }, @@ -64,7 +64,7 @@ } } }, - "RecordWeightedFromCfnParameter2B12A1DFB": { + "RecordWithParamWeight2C5120D0E": { "Type": "AWS::Route53::RecordSet", "Properties": { "HostedZoneId": { @@ -82,7 +82,7 @@ { "Ref": "RecordWeight2" }, - "_ID_recordweigParameter208409FED" + "_ID_recordweightParamWeight25B9D18F1" ] ] }, @@ -93,7 +93,7 @@ } } }, - "RecordWeightedFromCfnParameter3D5E67423": { + "RecordWithParamWeight37D431545": { "Type": "AWS::Route53::RecordSet", "Properties": { "HostedZoneId": { @@ -111,7 +111,7 @@ { "Ref": "RecordWeight3" }, - "_ID_recordweigParameter3841525F4" + "_ID_recordweightParamWeight37DA83B23" ] ] }, diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.record-weight-from-cfnparameter.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.record-weight-from-cfnparameter.js.snapshot/tree.json index 62d57a5daa2c9..ffd8d88ab9f97 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.record-weight-from-cfnparameter.js.snapshot/tree.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.record-weight-from-cfnparameter.js.snapshot/tree.json @@ -64,13 +64,13 @@ "version": "0.0.0" } }, - "RecordWeightedFromCfnParameter0": { - "id": "RecordWeightedFromCfnParameter0", - "path": "record-weight-from-cfnparameter/RecordWeightedFromCfnParameter0", + "RecordWithParamWeight0": { + "id": "RecordWithParamWeight0", + "path": "record-weight-from-cfnparameter/RecordWithParamWeight0", "children": { "Resource": { "id": "Resource", - "path": "record-weight-from-cfnparameter/RecordWeightedFromCfnParameter0/Resource", + "path": "record-weight-from-cfnparameter/RecordWithParamWeight0/Resource", "attributes": { "aws:cdk:cloudformation:type": "AWS::Route53::RecordSet", "aws:cdk:cloudformation:props": { @@ -89,7 +89,7 @@ { "Ref": "RecordWeight0" }, - "_ID_recordweigParameter04970FE98" + "_ID_recordweightParamWeight059BCC4E1" ] ] }, @@ -107,17 +107,17 @@ } }, "constructInfo": { - "fqn": "aws-cdk-lib.aws_route53.ARecord", + "fqn": "aws-cdk-lib.Resource", "version": "0.0.0" } }, - "RecordWeightedFromCfnParameter1": { - "id": "RecordWeightedFromCfnParameter1", - "path": "record-weight-from-cfnparameter/RecordWeightedFromCfnParameter1", + "RecordWithParamWeight1": { + "id": "RecordWithParamWeight1", + "path": "record-weight-from-cfnparameter/RecordWithParamWeight1", "children": { "Resource": { "id": "Resource", - "path": "record-weight-from-cfnparameter/RecordWeightedFromCfnParameter1/Resource", + "path": "record-weight-from-cfnparameter/RecordWithParamWeight1/Resource", "attributes": { "aws:cdk:cloudformation:type": "AWS::Route53::RecordSet", "aws:cdk:cloudformation:props": { @@ -136,7 +136,7 @@ { "Ref": "RecordWeight1" }, - "_ID_recordweigParameter1EB51A657" + "_ID_recordweightParamWeight1304B1475" ] ] }, @@ -154,17 +154,17 @@ } }, "constructInfo": { - "fqn": "aws-cdk-lib.aws_route53.ARecord", + "fqn": "aws-cdk-lib.Resource", "version": "0.0.0" } }, - "RecordWeightedFromCfnParameter2": { - "id": "RecordWeightedFromCfnParameter2", - "path": "record-weight-from-cfnparameter/RecordWeightedFromCfnParameter2", + "RecordWithParamWeight2": { + "id": "RecordWithParamWeight2", + "path": "record-weight-from-cfnparameter/RecordWithParamWeight2", "children": { "Resource": { "id": "Resource", - "path": "record-weight-from-cfnparameter/RecordWeightedFromCfnParameter2/Resource", + "path": "record-weight-from-cfnparameter/RecordWithParamWeight2/Resource", "attributes": { "aws:cdk:cloudformation:type": "AWS::Route53::RecordSet", "aws:cdk:cloudformation:props": { @@ -183,7 +183,7 @@ { "Ref": "RecordWeight2" }, - "_ID_recordweigParameter208409FED" + "_ID_recordweightParamWeight25B9D18F1" ] ] }, @@ -201,17 +201,17 @@ } }, "constructInfo": { - "fqn": "aws-cdk-lib.aws_route53.ARecord", + "fqn": "aws-cdk-lib.Resource", "version": "0.0.0" } }, - "RecordWeightedFromCfnParameter3": { - "id": "RecordWeightedFromCfnParameter3", - "path": "record-weight-from-cfnparameter/RecordWeightedFromCfnParameter3", + "RecordWithParamWeight3": { + "id": "RecordWithParamWeight3", + "path": "record-weight-from-cfnparameter/RecordWithParamWeight3", "children": { "Resource": { "id": "Resource", - "path": "record-weight-from-cfnparameter/RecordWeightedFromCfnParameter3/Resource", + "path": "record-weight-from-cfnparameter/RecordWithParamWeight3/Resource", "attributes": { "aws:cdk:cloudformation:type": "AWS::Route53::RecordSet", "aws:cdk:cloudformation:props": { @@ -230,7 +230,7 @@ { "Ref": "RecordWeight3" }, - "_ID_recordweigParameter3841525F4" + "_ID_recordweightParamWeight37DA83B23" ] ] }, @@ -248,7 +248,7 @@ } }, "constructInfo": { - "fqn": "aws-cdk-lib.aws_route53.ARecord", + "fqn": "aws-cdk-lib.Resource", "version": "0.0.0" } }, diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.record-weight-from-cfnparameter.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.record-weight-from-cfnparameter.ts index 689b97a64aca5..6d2d2160aa059 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.record-weight-from-cfnparameter.ts +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.record-weight-from-cfnparameter.ts @@ -24,7 +24,7 @@ class TestStack extends Stack { { target: '3.4.5.6', weight: new CfnParameter(this, 'RecordWeight2', weightParameterProps) }, { target: '4.5.6.7', weight: new CfnParameter(this, 'RecordWeight3', weightParameterProps) }, ].forEach((data, index) => { - new route53.ARecord(this, `RecordWeightedFromCfnParameter${index}`, { + new route53.ARecord(this, `RecordWithParamWeight${index}`, { zone: hostedZone, recordName: 'www', weight: data.weight.valueAsNumber, diff --git a/packages/aws-cdk-lib/aws-route53/lib/record-set.ts b/packages/aws-cdk-lib/aws-route53/lib/record-set.ts index 021affdd2b1de..592da5b7ce790 100644 --- a/packages/aws-cdk-lib/aws-route53/lib/record-set.ts +++ b/packages/aws-cdk-lib/aws-route53/lib/record-set.ts @@ -406,7 +406,10 @@ export class RecordSet extends Resource implements IRecordSet { } if (this.weight !== undefined) { - const idPrefix = `WEIGHT_${this.weight}_ID_`; + const idPrefix = `WEIGHT_${Token.isUnresolved(this.weight) + ? Token.asString(this.weight) + : this.weight + }_ID_`; return this.createIdentifier(idPrefix); }