(spec2cdk): Alpha module directory naming convention prevents grants.json processing for aws-bedrock-agentcore-alpha
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the feature
When an alpha module's directory name doesn't match the CloudFormation namespace naming convention, `spec2cdk` cannot locate the `grants.json` file, preventing the generation of `*-grants.generated.ts` files.
**Current behavior in spec2cdk:**
```typescript
// tools/@aws-cdk/spec2cdk/lib/generate.ts
function grantsConfigForModule(moduleName, modulePath, isStable) {
const grantsFileLocation = isStable
? path.join(modulePath, moduleName)
: path.join(modulePath, '..', `${moduleName}-alpha`);
// ...
}
```
For `AWS::BedrockAgentCore`:
- `moduleName` derived from CF namespace: `aws-bedrockagentcore`
- Expected directory: `aws-bedrockagentcore-alpha`
- Actual directory: `aws-bedrock-agentcore-alpha`
This mismatch causes `grants.json` to not be found.
### Use Case
I want to implement the recommended grant pattern using `grants.json` for `@aws-cdk/aws-bedrock-agentcore-alpha` module to generate type-safe grant methods (e.g., `grantInvokeRuntime()`).
Currently, `aws-elasticache-alpha` works correctly because:
- CF namespace: `AWS::ElastiCache` → `aws-elasticache`
- Directory: `aws-elasticache-alpha` ✓ (matches)
But `aws-bedrock-agentcore-alpha` fails because:
- CF namespace: `AWS::BedrockAgentCore` → `aws-bedrockagentcore`
- Directory: `aws-bedrock-agentcore-alpha` ✗ (hyphen mismatch)
### Proposed Solution
**Option 1:** Rename the directory to `aws-bedrockagentcore-alpha`
- Pros: Follows the convention
- Cons: Breaking change for existing users
**Option 2:** Add a mapping/alias mechanism in spec2cdk
- Allow `grants.json` lookup to handle directory name variations
- Could use package.json metadata or a separate mapping file
### Acknowledgements
- [x] I may be able to implement this feature request
- [x] This feature might incur a breaking change
### AWS CDK Library version (aws-cdk-lib)
`2.238.0`
### AWS CDK CLI version
N/A
### Environment details
N/A
Contributor guide
Research direction
Start in tools/@aws-cdk/spec2cdk/lib/generate.ts, especially grantsConfigForModule, and trace how the module path and grants.json location are derived. Compare the aws-bedrockagentcore namespace with the aws-bedrock-agentcore-alpha directory, then determine whether a directory rename or mapping mechanism fits the existing package layout. Done means spec2cdk locates grants.json and generates the module's *-grants.generated.ts file.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- build-system, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100