aws-certificatemanager: Missing simple validation for domainName in the Certificate construct
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the bug
The Certificate construct in AWS CDK does not perform validation on the domainName property at synthesis time. If the user provides an invalid domain name (e.g., a domain that is not a valid wildcard or fully qualified domain), the error only occurs at deployment time. This results in wasted time and failed deployments. The underlying error returned by AWS Certificate Manager is:
```
1 validation error detected: Value of the input at 'domainValidationOptions.1.member.validationDomain' failed to satisfy constraint: Member must satisfy regular expression pattern: (\*\.)?(((?!-)[A-Za-z0-9-]{0,62}[A-Za-z0-9])\.)+((?!-)[A-Za-z0-9-]{1,62}[A-Za-z0-9])
(Service: AWSCertificateManager; Status Code: 400; Error Code: ValidationException)
```
### Regression Issue
- [ ] Select this option if this issue appears to be a regression.
### Last Known Working CDK Library Version
_No response_
### Expected Behavior
The Certificate construct should validate the domainName property during synthesis. If the domain name is invalid or missing a required wildcard for subdomain coverage, CDK should raise a synthesis-time error. This prevents failed deployments and saves developer time.
### Current Behavior
Currently, CDK allows invalid domain names to pass through synthesis. The errors are only caught during deployment, which leads to wasted time and failed stacks. Example:
```
const cert = new Certificate(this, 'InternalCert', {
domainName: zone.zoneName, // This will fail at deployment
});
```
The fix that works is adding a wildcard to the domain name:
```
const cert = new Certificate(this, 'InternalCert', {
domainName: `*.${zone.zoneName}`, // Passes validation
});
```
### Reproduction Steps
N/A - every aws_cdk version
### Possible Solution
Add the validation
### Additional Information/Context
_No response_
### AWS CDK Library version (aws-cdk-lib)
2.207.0
### AWS CDK CLI version
2.1022.0
### Node.js Version
18.20.2
### OS
MacOS
### Language
TypeScript
### Language Version
_No response_
### Other information
_No response_
Contributor guide
Research direction
No file or test is named in the issue; start by locating the AWS CDK Certificate construct and its domainName handling. Add synthesis-time validation for invalid domain names and verify that invalid inputs fail during synthesis while valid wildcard and fully qualified domains remain accepted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cloud
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100