Skip to content

feat: new resource reference interfaces #35032

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

otaviomacedo
Copy link
Contributor

@otaviomacedo otaviomacedo commented Jul 22, 2025

For every L1, generate a new interface called ICfn[ResourceName] and make them implement this interface. For example:

export interface ICfnAlias extends constructs.IConstruct {
  /**
   * The Amazon Resource Name (ARN) of the alias.
   *
   * @cloudformationAttribute AliasArn
   */
  readonly attrAliasArn: string;
}


export class CfnAlias extends cdk.CfnResource implements cdk.IInspectable, ICfnAlias {
...
}

Each individual part of a composite attribute is exposed individually:

export interface ICfnDataCellsFilter extends constructs.IConstruct {
  /**
   * Catalog id string, not less than 1 or more than 255 bytes long, matching the [single-line string pattern](https://docs.aws.amazon.com/lake-formation/latest/dg/aws-lake-formation-api-aws-lake-formation-api-common.html) .
   * This property gets determined after the resource is created.
   *
   * @cloudformationAttribute Ref
   */
  readonly attrTableCatalogId: string;

  /**
   * UTF-8 string, not less than 1 or more than 255 bytes long, matching the [single-line string pattern](https://docs.aws.amazon.com/lake-formation/latest/dg/aws-lake-formation-api-aws-lake-formation-api-common.html) .
   * This property gets determined after the resource is created.
   *
   * @cloudformationAttribute Ref
   */
  readonly attrDatabaseName: string;

  /**
   * UTF-8 string, not less than 1 or more than 255 bytes long, matching the [single-line string pattern](https://docs.aws.amazon.com/lake-formation/latest/dg/aws-lake-formation-api-aws-lake-formation-api-common.html) .
   * This property gets determined after the resource is created.
   *
   * @cloudformationAttribute Ref
   */
  readonly attrTableName: string;

  /**
   * UTF-8 string, not less than 1 or more than 255 bytes long, matching the [single-line string pattern](https://docs.aws.amazon.com/lake-formation/latest/dg/aws-lake-formation-api-aws-lake-formation-api-common.html) .
   * This property gets determined after the resource is created.
   *
   * @cloudformationAttribute Ref
   */
  readonly attrName: string;
}

In a synthesized template, each of these attributes will be rendered as a "Fn::Select": [n, "Fn::Split": ["|", {"Ref": "ResourceName"}]], where n corresponds to the position of that particular identifier in the overall string.

Basically adapted from #28189.


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 July 22, 2025 16:05
@github-actions github-actions bot added the p2 label Jul 22, 2025
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Jul 22, 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)

if (!c.name.startsWith('Cfn')) {
return false;
}

return true;
return c.name.startsWith('Cfn');
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

@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 Jul 23, 2025
@aws-cdk-automation aws-cdk-automation dismissed their stale review July 23, 2025 09:03

✅ 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 Jul 23, 2025
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: b00f7bc
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

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/needs-maintainer-review This PR needs a review from a Core Team Member 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