Skip to content

Commit

Permalink
fix(backup): validation for vault name fails when parameters are refe…
Browse files Browse the repository at this point in the history
…rred in the name (#25943)

Validation for Backup vault name fails when parameters are referred in the name now. Current implementation simply validates vault name with regular expression described in [CFn reference](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-backup-backupvault.html#cfn-backup-backupvault-backupvaultname), so it does not consider the special characters for parameters. This PR solves the issue by checking props.backupVaultName is resolved.

Closes #21735

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
tam0ri authored Aug 18, 2023
1 parent 94e48c6 commit 00a7f03
Show file tree
Hide file tree
Showing 8 changed files with 165 additions and 56 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"version": "32.0.0",
"files": {
"cf2d89a4eac2c90005b9a1e142f1cac80cf9cd29d1b8f98f002b9f3a1849454c": {
"0c52c355c71ac95690274d7987110017ff9cd1a1bc79fa4206fda2f55d6b62d5": {
"source": {
"path": "cdk-backup.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "cf2d89a4eac2c90005b9a1e142f1cac80cf9cd29d1b8f98f002b9f3a1849454c.json",
"objectKey": "0c52c355c71ac95690274d7987110017ff9cd1a1bc79fa4206fda2f55d6b62d5.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
"TableCD117FA1": {
"Type": "AWS::DynamoDB::Table",
"Properties": {
"KeySchema": [
"AttributeDefinitions": [
{
"AttributeName": "id",
"KeyType": "HASH"
"AttributeType": "S"
}
],
"AttributeDefinitions": [
"KeySchema": [
{
"AttributeName": "id",
"AttributeType": "S"
"KeyType": "HASH"
}
],
"ProvisionedThroughput": {
Expand Down Expand Up @@ -50,6 +50,27 @@
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete"
},
"ThirdVault3441C01E": {
"Type": "AWS::Backup::BackupVault",
"Properties": {
"BackupVaultName": {
"Fn::Join": [
"",
[
"backupVault-",
{
"Ref": "Env"
}
]
]
},
"LockConfiguration": {
"MinRetentionDays": 5
}
},
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete"
},
"PlanDAF4E53A": {
"Type": "AWS::Backup::BackupPlan",
"Properties": {
Expand Down Expand Up @@ -234,6 +255,11 @@
}
},
"Parameters": {
"Env": {
"Type": "String",
"Default": "test",
"Description": "Env"
},
"BootstrapVersion": {
"Type": "AWS::SSM::Parameter::Value<String>",
"Default": "/cdk-bootstrap/hnb659fds/version",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "32.0.0",
"version": "33.0.0",
"testCases": {
"integ.backup": {
"stacks": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "32.0.0",
"version": "33.0.0",
"artifacts": {
"cdk-backup.assets": {
"type": "cdk:asset-manifest",
Expand All @@ -17,7 +17,7 @@
"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}/cf2d89a4eac2c90005b9a1e142f1cac80cf9cd29d1b8f98f002b9f3a1849454c.json",
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/0c52c355c71ac95690274d7987110017ff9cd1a1bc79fa4206fda2f55d6b62d5.json",
"requiresBootstrapStackVersion": 6,
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
"additionalDependencies": [
Expand Down Expand Up @@ -57,6 +57,18 @@
"data": "SecondaryVault67665B5E"
}
],
"/cdk-backup/Env": [
{
"type": "aws:cdk:logicalId",
"data": "Env"
}
],
"/cdk-backup/ThirdVault/Resource": [
{
"type": "aws:cdk:logicalId",
"data": "ThirdVault3441C01E"
}
],
"/cdk-backup/Plan/Resource": [
{
"type": "aws:cdk:logicalId",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
"attributes": {
"aws:cdk:cloudformation:type": "AWS::DynamoDB::Table",
"aws:cdk:cloudformation:props": {
"keySchema": [
"attributeDefinitions": [
{
"attributeName": "id",
"keyType": "HASH"
"attributeType": "S"
}
],
"attributeDefinitions": [
"keySchema": [
{
"attributeName": "id",
"attributeType": "S"
"keyType": "HASH"
}
],
"provisionedThroughput": {
Expand All @@ -37,22 +37,22 @@
}
},
"constructInfo": {
"fqn": "aws-cdk-lib.aws_dynamodb.CfnTable",
"version": "0.0.0"
"fqn": "constructs.Construct",
"version": "10.2.69"
}
},
"ScalingRole": {
"id": "ScalingRole",
"path": "cdk-backup/Table/ScalingRole",
"constructInfo": {
"fqn": "aws-cdk-lib.Resource",
"version": "0.0.0"
"fqn": "constructs.Construct",
"version": "10.2.69"
}
}
},
"constructInfo": {
"fqn": "aws-cdk-lib.aws_dynamodb.Table",
"version": "0.0.0"
"fqn": "constructs.Construct",
"version": "10.2.69"
}
},
"FileSystem": {
Expand All @@ -63,8 +63,8 @@
"aws:cdk:cloudformation:props": {}
},
"constructInfo": {
"fqn": "aws-cdk-lib.aws_efs.CfnFileSystem",
"version": "0.0.0"
"fqn": "constructs.Construct",
"version": "10.2.69"
}
},
"Vault": {
Expand All @@ -84,14 +84,14 @@
}
},
"constructInfo": {
"fqn": "aws-cdk-lib.aws_backup.CfnBackupVault",
"version": "0.0.0"
"fqn": "constructs.Construct",
"version": "10.2.69"
}
}
},
"constructInfo": {
"fqn": "aws-cdk-lib.aws_backup.BackupVault",
"version": "0.0.0"
"fqn": "constructs.Construct",
"version": "10.2.69"
}
},
"SecondaryVault": {
Expand All @@ -111,14 +111,59 @@
}
},
"constructInfo": {
"fqn": "aws-cdk-lib.aws_backup.CfnBackupVault",
"version": "0.0.0"
"fqn": "constructs.Construct",
"version": "10.2.69"
}
}
},
"constructInfo": {
"fqn": "aws-cdk-lib.aws_backup.BackupVault",
"version": "0.0.0"
"fqn": "constructs.Construct",
"version": "10.2.69"
}
},
"Env": {
"id": "Env",
"path": "cdk-backup/Env",
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.2.69"
}
},
"ThirdVault": {
"id": "ThirdVault",
"path": "cdk-backup/ThirdVault",
"children": {
"Resource": {
"id": "Resource",
"path": "cdk-backup/ThirdVault/Resource",
"attributes": {
"aws:cdk:cloudformation:type": "AWS::Backup::BackupVault",
"aws:cdk:cloudformation:props": {
"backupVaultName": {
"Fn::Join": [
"",
[
"backupVault-",
{
"Ref": "Env"
}
]
]
},
"lockConfiguration": {
"minRetentionDays": 5
}
}
},
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.2.69"
}
}
},
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.2.69"
}
},
"Plan": {
Expand Down Expand Up @@ -205,8 +250,8 @@
}
},
"constructInfo": {
"fqn": "aws-cdk-lib.aws_backup.CfnBackupPlan",
"version": "0.0.0"
"fqn": "constructs.Construct",
"version": "10.2.69"
}
},
"Selection": {
Expand All @@ -221,8 +266,8 @@
"id": "ImportRole",
"path": "cdk-backup/Plan/Selection/Role/ImportRole",
"constructInfo": {
"fqn": "aws-cdk-lib.Resource",
"version": "0.0.0"
"fqn": "constructs.Construct",
"version": "10.2.69"
}
},
"Resource": {
Expand Down Expand Up @@ -260,14 +305,14 @@
}
},
"constructInfo": {
"fqn": "aws-cdk-lib.aws_iam.CfnRole",
"version": "0.0.0"
"fqn": "constructs.Construct",
"version": "10.2.69"
}
}
},
"constructInfo": {
"fqn": "aws-cdk-lib.aws_iam.Role",
"version": "0.0.0"
"fqn": "constructs.Construct",
"version": "10.2.69"
}
},
"Resource": {
Expand Down Expand Up @@ -349,56 +394,56 @@
}
},
"constructInfo": {
"fqn": "aws-cdk-lib.aws_backup.CfnBackupSelection",
"version": "0.0.0"
"fqn": "constructs.Construct",
"version": "10.2.69"
}
}
},
"constructInfo": {
"fqn": "aws-cdk-lib.aws_backup.BackupSelection",
"version": "0.0.0"
"fqn": "constructs.Construct",
"version": "10.2.69"
}
}
},
"constructInfo": {
"fqn": "aws-cdk-lib.aws_backup.BackupPlan",
"version": "0.0.0"
"fqn": "constructs.Construct",
"version": "10.2.69"
}
},
"BootstrapVersion": {
"id": "BootstrapVersion",
"path": "cdk-backup/BootstrapVersion",
"constructInfo": {
"fqn": "aws-cdk-lib.CfnParameter",
"version": "0.0.0"
"fqn": "constructs.Construct",
"version": "10.2.69"
}
},
"CheckBootstrapVersion": {
"id": "CheckBootstrapVersion",
"path": "cdk-backup/CheckBootstrapVersion",
"constructInfo": {
"fqn": "aws-cdk-lib.CfnRule",
"version": "0.0.0"
"fqn": "constructs.Construct",
"version": "10.2.69"
}
}
},
"constructInfo": {
"fqn": "aws-cdk-lib.Stack",
"version": "0.0.0"
"fqn": "constructs.Construct",
"version": "10.2.69"
}
},
"Tree": {
"id": "Tree",
"path": "Tree",
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.2.26"
"version": "10.2.69"
}
}
},
"constructInfo": {
"fqn": "aws-cdk-lib.App",
"version": "0.0.0"
"fqn": "constructs.Construct",
"version": "10.2.69"
}
}
}
Loading

0 comments on commit 00a7f03

Please sign in to comment.