-
Notifications
You must be signed in to change notification settings - Fork 820
fix(api): add null placeholder for nested stack during api rebuild #11460
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
caa8468
fix(api): add null placeholder for nested stack during api rebuild
AaronZyLee 120c2f9
fix: rebuild api for searchable
AaronZyLee a648291
test: add e2e tests for rebuild api
AaronZyLee 0436ce6
fix: e2e tests
AaronZyLee 57bd7f1
fix: keep search engine during rebuild
AaronZyLee 6581475
fix: add common test helper
AaronZyLee 8dc5c03
address CRs
AaronZyLee 91e4588
fix git bot alert
AaronZyLee 3dc60c4
fix: lint error
AaronZyLee 7ba5a84
fix lint error
AaronZyLee ca82b51
fix prettier
AaronZyLee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
packages/amplify-e2e-tests/schemas/relational_models_v2.graphql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
input AMPLIFY { | ||
globalAuthRule: AuthRule = { allow: public } | ||
} | ||
type Todo @model { | ||
id: ID! | ||
name: String | ||
description: String | ||
tasks: [Task] @hasMany | ||
assignee: Worker @hasOne | ||
} | ||
type Task @model { | ||
id: ID! | ||
todo: Todo @belongsTo | ||
} | ||
type Worker @model { | ||
id: ID! | ||
todo: Todo @belongsTo | ||
} |
8 changes: 8 additions & 0 deletions
8
packages/amplify-e2e-tests/schemas/searchable_model_v2.graphql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
input AMPLIFY { | ||
globalAuthRule: AuthRule = { allow: public } | ||
} | ||
type Todo @model @searchable { | ||
id: ID! | ||
name: String | ||
description: String | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { | ||
createNewProjectDir, | ||
initJSProjectWithProfile, | ||
addApiWithoutSchema, | ||
amplifyPush, | ||
deleteProjectDir, | ||
rebuildApi, | ||
getProjectMeta, | ||
updateApiSchema, | ||
deleteProject, | ||
} from '@aws-amplify/amplify-e2e-core'; | ||
import { testTableAfterRebuildApi, testTableBeforeRebuildApi } from '../rebuild-test-helpers'; | ||
|
||
const projName = 'apitest'; | ||
|
||
let projRoot; | ||
beforeEach(async () => { | ||
projRoot = await createNewProjectDir(projName); | ||
}); | ||
afterEach(async () => { | ||
await deleteProject(projRoot, undefined, false, 1000 * 60 * 30); | ||
deleteProjectDir(projRoot); | ||
}); | ||
|
||
describe('amplify rebuild api', () => { | ||
it('recreates tables for searchable models', async () => { | ||
await initJSProjectWithProfile(projRoot, { name: projName }); | ||
await addApiWithoutSchema(projRoot, { transformerVersion: 2 }); | ||
await updateApiSchema(projRoot, projName, 'searchable_model_v2.graphql'); | ||
await amplifyPush(projRoot); | ||
const projMeta = getProjectMeta(projRoot); | ||
const apiId = projMeta?.api?.[projName]?.output?.GraphQLAPIIdOutput; | ||
const region = projMeta?.providers?.awscloudformation?.Region; | ||
expect(apiId).toBeDefined(); | ||
expect(region).toBeDefined(); | ||
await testTableBeforeRebuildApi(apiId, region, 'Todo'); | ||
await rebuildApi(projRoot, projName); | ||
await testTableAfterRebuildApi(apiId, region, 'Todo'); | ||
}); | ||
}); |
14 changes: 14 additions & 0 deletions
14
packages/amplify-e2e-tests/src/rebuild-test-helpers/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { putItemInTable, scanTable } from '@aws-amplify/amplify-e2e-core'; | ||
|
||
export const testTableBeforeRebuildApi = async (apiId: string, region: string, modelName: string) => { | ||
const tableName = `${modelName}-${apiId}-integtest`; | ||
await putItemInTable(tableName, region, { id: 'this is a test value' }); | ||
const scanResultBefore = await scanTable(tableName, region); | ||
expect(scanResultBefore.Items.length).toBe(1); | ||
}; | ||
|
||
export const testTableAfterRebuildApi = async (apiId: string, region: string, modelName: string) => { | ||
const tableName = `${modelName}-${apiId}-integtest`; | ||
const scanResultAfter = await scanTable(tableName, region); | ||
expect(scanResultAfter.Items.length).toBe(0); | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't fully understand the fix here. Can you post a screenshot of before and after state of a nested child stack parameters? How are we ensuring that these defaults will not show up in the final templates deployed via
push
?Instead of adding a default can we just remove these parameters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameters cannot be removed but faking a placeholder value. These parameter values are defined in api root stack (
cloudformation-template.json
=>Resources.[nestedStack].Properties.Parameters
). I update a example in the PR description.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like we are looking for a very specific CFN template string. Could this break if there is a change in the way we pass this parameter value in the future?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The phrase it looks for is the
Fn:GetAtt:[Outputs.*, ]
which is an intrinsic function and reserved word in the Cloudformation. The words should be unlikely to change unless the breaking change occurs in CFN.Currently it is constructed by the CDK sync operation. If it changes its form, this will be a breaking change for CDK users and the CDK should convey this message to us.