-
Notifications
You must be signed in to change notification settings - Fork 819
Open
Labels
Description
How did you install the Amplify CLI?
npm install --no-save @aws-amplify/cli-internal-gen2-migration-experimental-alpha
If applicable, what version of Node.js are you using?
No response
Amplify CLI Version
0.6.0
What operating system are you using?
Mac
Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.
No
Describe the bug
When a model is named in a non pascal case fashion, i.e:
type randomItem @model {...}And a function is configured to have access to this model table, the generated (snippet) code is incorrect:
backend.quotegenerator.addEnvironment("API_BACKENDONLY_RANDOMITEMTABLE_NAME", backend.data.resources.tables["Randomitem"].tableName);
backend.data.resources.tables["randomItem"].grant(backend.quotegenerator.resources.lambda, "dynamodb:Put*", "dynamodb:Create*", "dynamodb:BatchWriteItem", "dynamodb:PartiQLInsert", "dynamodb:Get*", "dynamodb:BatchGetItem", "dynamodb:List*", "dynamodb:Describe*", "dynamodb:Scan", "dynamodb:Query", "dynamodb:PartiQLSelect", "dynamodb:Update*", "dynamodb:RestoreTable*", "dynamodb:PartiQLUpdate", "dynamodb:Delete*", "dynamodb:PartiQLDelete");Notice the value of the env variable is backend.data.resources.tables["Randomitem"].tableName, but our model is named randomitem. Also notice that the next line does actually use the correct casing:
backend.data.resources.tables["randomItem"].grant(...)Deploying this code results in:
2026-01-28T22:48:01.995Z [INFO]: [BackendBuildError] Unable to deploy due to CDK Assembly Error
∟ Caused by: [AssemblyError] Assembly builder failed
∟ Caused by: [TypeError] Cannot read properties of undefined (reading 'tableArn')Expected behavior
backend.quotegenerator.addEnvironment("API_BACKENDONLY_RANDOMITEMTABLE_NAME", backend.data.resources.tables["randomitem"].tableName);
backend.data.resources.tables["randomItem"].grant(backend.quotegenerator.resources.lambda, "dynamodb:Put*", "dynamodb:Create*", "dynamodb:BatchWriteItem", "dynamodb:PartiQLInsert", "dynamodb:Get*", "dynamodb:BatchGetItem", "dynamodb:List*", "dynamodb:Describe*", "dynamodb:Scan", "dynamodb:Query", "dynamodb:PartiQLSelect", "dynamodb:Update*", "dynamodb:RestoreTable*", "dynamodb:PartiQLUpdate", "dynamodb:Delete*", "dynamodb:PartiQLDelete");Reproduction steps
- Add a non pascal named model name to your GraphQL schema:
type randomItem @model @auth(rules: [
{ allow: public, operations: [read] },
{ allow: owner, operations: [create, read, update, delete] }
]) {
id: ID!
name: String!
description: String
images: [String]
projectID: ID
}- Configure a function to have access to this model:
- Run
gen2-migration generate - Deploy the generated code.
Project Identifier
No response
Log output
Details
# Put your logs below this line
Additional information
No response
Before submitting, please confirm:
- I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
- I have removed any sensitive information from my code snippets and submission.
Reactions are currently unavailable