(aws-amplify-alpha): Custom domain with blank prefix causes stack drift
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the bug
After deploying a CDK stack containing an Amplify app with a custom domain that has a blank prefix, the underlying CloudFormation stack is immediately in "drifted" state.
### Regression Issue
- [ ] Select this option if this issue appears to be a regression.
### Last Known Working CDK Library Version
_No response_
### Expected Behavior
The underlying CloudFormation stack should not be drifted.
### Current Behavior
The stack is in drifted state after deployment:
Expected:
```json
{
"SubDomainSettings": [
{
"BranchName": "master",
"Prefix": ""
}
],
"AppId": "xxxyyyzzz",
"AutoSubDomainIAMRole": "arn:aws:iam::xxxyyyzzz",
"DomainName": "mysubdomain.mydomain.com",
"EnableAutoSubDomain": false,
"AutoSubDomainCreationPatterns": [
"*",
"pr*"
]
}
```
Actual:
```json
{
"SubDomainSettings": [
{
"BranchName": "master"
}
],
"AppId": "xxxyyyzzz",
"AutoSubDomainIAMRole": "arn:aws:iam::xxxyyyzzz",
"DomainName": "mysubdomain.mydomain.com",
"EnableAutoSubDomain": false,
"AutoSubDomainCreationPatterns": [
"*",
"pr*"
]
}
```
### Reproduction Steps
Add a custom domain with a blank prefix like so:
```python
amplify_app.add_domain('AppDomain',
domain_name = 'mysubdomain.mydomain.com',
sub_domains = [amplify.SubDomain(prefix = '', branch = 'master')]
)
```
As specified by the documentation for `amplify.SubDomain`, we: `Use '' to map to the root of the domain`.
### Possible Solution
_No response_
### Additional Information/Context
_No response_
### AWS CDK Library version (aws-cdk-lib)
2.222.0-alpha.0
### AWS CDK CLI version
2.1031.1
### Node.js Version
v24.11.0
### OS
macOS 15.7.1
### Language
Python
### Language Version
3.14.0
### Other information
_No response_
Contributor guide
Research direction
Start from the Amplify app add_domain API and the SubDomain input shown in the reproduction, then reproduce the deployment with an empty prefix and inspect the generated CloudFormation properties. Confirm the fix by verifying that the deployed stack preserves the blank Prefix and no longer reports drift.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, python, typescript
- Domain
- cloud, infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100