Skip to content

Conversation

@otaviomacedo
Copy link
Contributor

@otaviomacedo otaviomacedo commented Nov 26, 2025

Grants classes are only generated in the aws-cdk-lib module (if a grants.json file is present). However, for alpha modules, we want the auto-generated files to be treated as alpha.

This PR adds support for generating Grants classes in alpha modules, if a grants.json file is present.

Also added a new grants.json in aws-elasticache-alpha to demonstrate that the change works.

Main changes:

  • generateAll() now takes an additional output directory: the root of the alpha modules.
  • A new GrantsProps struct is being passed around, that contains the config itself plus a flag indicating whether the module is stable.
  • The location where the module should be written now depends on whether the module is stable.
  • In the grants module, the import for the corresponding stable module is either
    • import * as <service> from "./<service>.generated";, for stable modules, or
    • import * as <service> from "aws-cdk-lib/aws-<service>";, for unstable modules.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@aws-cdk-automation aws-cdk-automation requested a review from a team November 26, 2025 09:49
@github-actions github-actions bot added the p2 label Nov 26, 2025
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Nov 26, 2025
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(This review is outdated)

@otaviomacedo otaviomacedo added pr-linter/exempt-readme The PR linter will not require README changes pr-linter/exempt-integ-test The PR linter will not require integ test changes labels Nov 26, 2025
@aws-cdk-automation aws-cdk-automation dismissed stale reviews from themself November 26, 2025 10:02

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Nov 26, 2025
import writeCloudFormationIncludeMapping from './submodules/cloudformation-include';

const awsCdkLibDir = path.join(__dirname, '..');
const atAwsCdkDir = path.join(__dirname, '../../@aws-cdk');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this tool, which lives in aws-cdk-lib, going to search outside its own directory for things to generate?

I don't like that very much.

I think we can't get around making the generator a standalone tool, perhaps move all this code into tools/@aws-cdk/spec2cdk, or perhaps one next to it... and then it gets invoked as part of yarn gen in each package separately and confines its search and generation to that package.

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Nov 26, 2025
'elasticache:DescribeServerlessCaches',
],
Resource: { 'Fn::GetAtt': ['Cache18F6EE16', 'ARN'] },
Resource: {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've confirmed that this is the correct ARN format for a serverless cache.

public write(module: Module, filePath: string): string {
log.debug(module.name, filePath, 'render');
const fullPath = path.join(this.rootDir, filePath);
public write(module: Module, fullPath: string): string {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The behavior here has changed: the second parameter is an absolute path, instead of relative to some root directory passed to the constructor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contribution/core This is a PR that came from AWS. p2 pr-linter/exempt-integ-test The PR linter will not require integ test changes pr-linter/exempt-readme The PR linter will not require README changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants