Skip to content
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

How to rename DynamoDB tables in Gen 2? #2991

Open
AlexThomas90210 opened this issue Oct 29, 2024 · 3 comments
Open

How to rename DynamoDB tables in Gen 2? #2991

AlexThomas90210 opened this issue Oct 29, 2024 · 3 comments
Assignees
Labels

Comments

@AlexThomas90210
Copy link

Amplify CLI Version

Gen 2

Question

I really like Amplify but I find the resource name excruciatingly annoying, specially when deploying multiple branches/sandboxes in one AWS Account.

I am trying to rename core resources, such as userpool, lambda function etc, and I want to do the same with DynamoDB table but I don't seem to be able to get the Cloudformation reference because its in a nested stack, is it possible?

// Rename resources
backend.auth.resources.cfnResources.cfnUserPool.userPoolName = `${namePrefix}-userpool`;
backend.auth.resources.cfnResources.cfnIdentityPool.identityPoolName = `${namePrefix}-identitypool`;

// I want to rename here 
// backend.data.resources.cfnResources.cfnTables["Example"].tableName = `${namePrefix}-example-table`;

backend.data.resources.cfnResources.cfnGraphqlApi.name = `${namePrefix}-gqlapi`;
backend.stripeFunction.resources.cfnResources.cfnFunction.functionName = `${namePrefix}-payments-handler`;
backend.stripeWebhookCustomResource.resources.cfnResources.cfnFunction.functionName = `${namePrefix}-stripe-webhook-handler`;
@AlexThomas90210 AlexThomas90210 added pending-triage question Further information is requested labels Oct 29, 2024
@ykethan
Copy link
Member

ykethan commented Oct 30, 2024

Hey,👋 thanks for raising this! I'm going to transfer this over to our API repository for better assistance 🙂

@ykethan ykethan transferred this issue from aws-amplify/amplify-cli Oct 30, 2024
@dpilch
Copy link
Member

dpilch commented Oct 30, 2024

It is not possible to change the DynamoDB table names currently.

The DynamoDB tables are stored in backend.data.resources.cfnResources.amplifyDynamoDbTables["TableName"]. However you will still run into a couple issues with changing the table name.

  1. The CfnResource property is private on our wrapper class. You can ignore this with // @ts-expect-error but we cannot guarantee that there will be no breaking changes to a private property.
backend.data.resources.cfnResources.amplifyDynamoDbTables.Todo
  // @ts-expect-error
  .resource // private property
  .addPropertyOverride("tableName", "MyCustomTableName");

I don't know why resource is private in this case and it may be a mistake in the implementation. I will need to check with the team on this.

  1. Even with the above workaround you will not be able to set the table name because the policy for our custom resource that creates the table is restricted to a certain naming pattern.

@dpilch dpilch added feature-request New feature or request and removed question Further information is requested pending-triage labels Oct 30, 2024
@AlexThomas90210
Copy link
Author

@dpilch Thanks for the quick response, I appreciate it.

I guess I am making a feature request, to allow us to provide clean, user friendly names to not mess up the UI in the AWS Console and give a predictable outcome for the table names.

For example I have a project with 1 sandbox env, dev and prod with 7 models. The tables in the account look really messy and hard to understand/easy to make a mistake when selecting tables to perform actions on/inspect configuration etc

Other than that keep up the great work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants