Skip to content

Conversation

@LeeroyHannigan
Copy link
Contributor

Reason for this change

Adding new feature for DynamoDB Contributor Insights Mode: https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-properties-dynamodb-table-contributorinsightsspecification.html#cfn-dynamodb-table-contributorinsightsspecification-mode

Description of changes

Changes to Table and TableV2 to provide CCI Mode

Describe any new or updated permissions being added

Description of how you validated changes

Yes, integ and unit tests.

Checklist


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 August 21, 2025 11:24
@github-actions github-actions bot added p2 valued-contributor [Pilot] contributed between 6-12 PRs to the CDK labels Aug 21, 2025
Copy link
Contributor

@iankhou iankhou left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution! It looks like two similar functions here seem like they can be combined into one shared utility?

}

private validateCCI (props: IContributorInsightsConfigurable): ContributorInsightsSpecification | undefined {
if (props.contributorInsightsSpecification !==undefined && props.contributorInsightsEnabled !== undefined) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks very similar to the validateCCI function in table-v2. Can we combine them in the shared file as a utility? They essentially do the same thing, and you would need to parameterize the old and new names.

Also, looks like code here might not be linted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They are similar, but for TableV2 we also have to check for replicas. I also did not see any other shared utility functions in the shared file, so I created two standalone functions. This passed the internal view already, but I can combine them into a more complex function if you feel its the right direction?

Copy link
Contributor

@alvazjor alvazjor Aug 26, 2025

Choose a reason for hiding this comment

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

I agree with @iankhou, since they are quite similar, you could do, in the shared file, something like:

export function validateContributorInsights(
  contributorInsights: boolean | undefined,
  contributorInsightsSpecification: ContributorInsightsSpecification | undefined,
  deprecatedPropertyName: string,
  construct: Construct
): ContributorInsightsSpecification | undefined {
  if (contributorInsightsSpecification !== undefined && contributorInsights !== undefined) {
    throw new ValidationError(`\`contributorInsightsSpecification\` and \`${deprecatedPropertyName}\` are set. Use \`contributorInsightsSpecification\` only.`, construct);
  }

  return contributorInsightsSpecification ?? 
    (contributorInsights !== undefined ? { enabled: contributorInsights } : undefined);
}

And then on each validation in the table and table-v2:

// Updated table-v2.ts - replace the validateCCI method with:
private validateCCI(props: IContributorInsightsConfigurable): ContributorInsightsSpecification | undefined {
  const contributorInsights = props?.contributorInsights ?? this.tableOptions?.contributorInsights;
  const contributorInsightsSpecification = props?.contributorInsightsSpecification || this.tableOptions?.contributorInsightsSpecification;
  
  return validateContributorInsights(contributorInsights, contributorInsightsSpecification, 'contributorInsights', this);
}


// Updated table.ts - replace the validateCCI method with:
private validateCCI(props: IContributorInsightsConfigurable): ContributorInsightsSpecification | undefined {
  return validateContributorInsights(props.contributorInsightsEnabled, props.contributorInsightsSpecification, 'contributorInsightsEnabled', this);
}

This way you still keep the table v2 specific validation logic where it belongs (table-v2 file) but dont repeat code if not needed.

@iankhou iankhou self-assigned this Aug 21, 2025
@mergify mergify bot dismissed iankhou’s stale review August 26, 2025 13:51

Pull request has been modified.

@alvazjor alvazjor self-assigned this Aug 26, 2025
alvazjor
alvazjor previously approved these changes Aug 26, 2025
@mergify mergify bot dismissed alvazjor’s stale review August 26, 2025 14:25

Pull request has been modified.

alvazjor
alvazjor previously approved these changes Aug 26, 2025
@mergify mergify bot dismissed alvazjor’s stale review August 26, 2025 16:32

Pull request has been modified.

@alvazjor
Copy link
Contributor

@LeeroyHannigan there was an issue with this build, and since I could not push the commit change to your branch, I created a duplicate of this PR and added the fix (completely unrelated to what you did, but still blocking the build). That PR was successfully merged, so I will close this one. The duplicate is this one: #35332

@alvazjor alvazjor closed this Aug 26, 2025
@github-actions
Copy link
Contributor

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 26, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

p2 valued-contributor [Pilot] contributed between 6-12 PRs to the CDK

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants