Skip to content

Commit

Permalink
add new test to logical id suite
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwin300 committed Jul 5, 2023
1 parent 251df25 commit 1b35bfd
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 82 deletions.
2 changes: 1 addition & 1 deletion packages/aws-cdk-lib/core/lib/private/logical-id.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class LogicalIDs {
}
}

const VALID_LOGICALID_REGEX = /^[A-Za-z0-9]{1,254}$/;
const VALID_LOGICALID_REGEX = /^[A-Za-z0-9]{1,255}$/;

/**
* Validate logical ID is valid for CloudFormation
Expand Down
27 changes: 26 additions & 1 deletion packages/aws-cdk-lib/core/test/logical-id.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,25 @@ describe('logical id', () => {
expect(() => toCloudFormation(stack)).toThrow(/Logical ID must adhere to the regular expression/);
});

test('any alphaneumeric logical id is allowed', () => {
// GIVEN
const stack = new Stack();

// WHEN
const validLogicalIdAlpha = generateString(200);
const validLogicalIdNumber = generateNumberString(200);
new CfnResource(stack, validLogicalIdAlpha, { type: 'R' });
new CfnResource(stack, validLogicalIdNumber, { type: 'R' } );

// THEN
expect(toCloudFormation(stack)).toEqual({
Resources: {
[validLogicalIdAlpha]: { Type: 'R' },
[validLogicalIdNumber]: { Type: 'R' },
},
});
});

test('too large identifiers are truncated yet still remain unique', () => {
// GIVEN
const stack = new Stack();
Expand Down Expand Up @@ -253,7 +272,13 @@ describe('logical id', () => {
}).toThrow(/section 'Resources' already contains 'C'/);
});
});

function generateNumberString(chars: number) {
let s = '';
for (let i = 0; i < chars; ++i) {
s += Math.floor(Math.random() * 9);
}
return s;
}
function generateString(chars: number) {
let s = '';
for (let i = 0; i < chars; ++i) {
Expand Down
80 changes: 0 additions & 80 deletions packages/aws-cdk-lib/cx-api/FEATURE_FLAGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ Flags come in three types:

| Flag | Summary | Since | Type |
| ----- | ----- | ----- | ----- |
| [@aws-cdk/aws-apigateway:requestValidatorUniqueId](#aws-cdkaws-apigatewayrequestvalidatoruniqueid) | Generate a unique id for each RequestValidator added to a method | V2·NEXT | (fix) |
| [@aws-cdk/aws-ec2:restrictDefaultSecurityGroup](#aws-cdkaws-ec2restrictdefaultsecuritygroup) | Restrict access to the VPC default security group | V2·NEXT | (default) |
| [@aws-cdk/aws-kms:aliasNameRef](#aws-cdkaws-kmsaliasnameref) | KMS Alias name and keyArn will have implicit reference to KMS Key | V2·NEXT | (fix) |
| [@aws-cdk/aws-route53-patters:useCertificate](#aws-cdkaws-route53-pattersusecertificate) | Use the official `Certificate` resource instead of `DnsValidatedCertificate` | V2·NEXT | (default) |
| [@aws-cdk/core:newStyleStackSynthesis](#aws-cdkcorenewstylestacksynthesis) | Switch to new stack synthesis method which enables CI/CD | 2.0.0 | (fix) |
| [@aws-cdk/core:stackRelativeExports](#aws-cdkcorestackrelativeexports) | Name exports based on the construct paths relative to the stack, rather than the global construct path | 2.0.0 | (fix) |
| [@aws-cdk/aws-rds:lowercaseDbIdentifier](#aws-cdkaws-rdslowercasedbidentifier) | Force lowercasing of RDS Cluster names in CDK | 2.0.0 | (fix) |
Expand Down Expand Up @@ -332,82 +328,6 @@ Encryption can also be configured explicitly using the `encrypted` property.
**Compatibility with old behavior:** Pass the `encrypted: false` property to the `FileSystem` construct to disable encryption.


### @aws-cdk/aws-apigateway:requestValidatorUniqueId

*Generate a unique id for each RequestValidator added to a method* (fix)

This flag allows multiple RequestValidators to be added to a RestApi when
providing the `RequestValidatorOptions` in the `addMethod()` method.

If the flag is not set then only a single RequestValidator can be added in this way.
Any additional RequestValidators have to be created directly with `new RequestValidator`.


| Since | Default | Recommended |
| ----- | ----- | ----- |
| (not in v1) | | |
| V2·NEXT | `false` | `true` |


### @aws-cdk/aws-ec2:restrictDefaultSecurityGroup

*Restrict access to the VPC default security group* (default)

Enable this feature flag to remove the default ingress/egress rules from the
VPC default security group.

When a VPC is created, a default security group is created as well and this cannot
be deleted. The default security group is created with ingress/egress rules that allow
_all_ traffic. [AWS Security best practices recommend](https://docs.aws.amazon.com/securityhub/latest/userguide/ec2-controls.html#ec2-2)
removing these ingress/egress rules in order to restrict access to the default security group.


| Since | Default | Recommended |
| ----- | ----- | ----- |
| (not in v1) | | |
| V2·NEXT | `false` | `true` |

**Compatibility with old behavior:**
To allow all ingress/egress traffic to the VPC default security group you
can set the `restrictDefaultSecurityGroup: false`.



### @aws-cdk/aws-kms:aliasNameRef

*KMS Alias name and keyArn will have implicit reference to KMS Key* (fix)

This flag allows an implicit dependency to be created between KMS Alias and KMS Key
when referencing key.aliasName or key.keyArn.

If the flag is not set then a raw string is passed as the Alias name and no
implicit dependencies will be set.


| Since | Default | Recommended |
| ----- | ----- | ----- |
| (not in v1) | | |
| V2·NEXT | `false` | `true` |


### @aws-cdk/aws-route53-patters:useCertificate

*Use the official `Certificate` resource instead of `DnsValidatedCertificate`* (default)

Enable this feature flag to use the official CloudFormation supported `Certificate` resource instead
of the deprecated `DnsValidatedCertificate` construct. If this flag is enabled and you are creating
the stack in a region other than us-east-1 then you must also set `crossRegionReferences=true` on the
stack.


| Since | Default | Recommended |
| ----- | ----- | ----- |
| (not in v1) | | |
| V2·NEXT | `false` | `true` |

**Compatibility with old behavior:** Define a `DnsValidatedCertificate` explicitly and pass in the `certificate` property


### @aws-cdk/core:newStyleStackSynthesis

*Switch to new stack synthesis method which enables CI/CD* (fix)
Expand Down

0 comments on commit 1b35bfd

Please sign in to comment.