-
Notifications
You must be signed in to change notification settings - Fork 73
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
fix: detect deploymentType from Stack Tags #2116
Conversation
🦋 Changeset detectedLatest commit: eb32eb4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
const stackDescription = await this.cfnClient.send( | ||
new DescribeStacksCommand({ StackName: stackSummary.StackName }) | ||
); | ||
|
||
try { | ||
const backendOutput: BackendOutput = | ||
await this.backendOutputClient.getOutput(backendIdentifier); | ||
|
||
return backendOutput[platformOutputKey].payload | ||
.deploymentType as DeploymentType; | ||
} catch (error) { | ||
if ( | ||
(error as BackendOutputClientError).code === | ||
BackendOutputClientErrorType.METADATA_RETRIEVAL_ERROR | ||
) { | ||
// Ignore stacks where metadata cannot be retrieved. These are not Amplify stacks, or not compatible with this library. | ||
return; | ||
} | ||
throw error; | ||
} | ||
return stackDescription.Stacks?.[0].Tags?.find( | ||
(tag) => tag.Key === 'amplify:deployment-type' | ||
)?.Value as DeploymentType; |
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.
This is the only functional change, rest are all test changes.
@@ -171,98 +149,4 @@ void describe('Deployed Backend Client list delete failed stacks', () => { | |||
|
|||
assert.equal(listStacksMockFn.mock.callCount(), 2); | |||
}); | |||
|
|||
void it('paginates listBackends when one page contains stacks, but it gets filtered due to not deleted failed status', async () => { |
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.
This test was duplicate of the one above.
assert.equal(listStacksMockFn.mock.callCount(), 2); | ||
}); | ||
|
||
void it('paginates listBackends when one page contains stacks, but it gets filtered due to sandbox deploymentType', async () => { |
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.
Same, this test was duplicate of the one above.
Problem
listBackends
callstryGetDeploymentType
to load the entire stack metadata and then infer deployment type from it.This creates issue if the stack is being created or deleted and the metadata is not available causing the
fetchBackendOutput
to throw causing thelistBackends
call to fail.Issue number, if available:
Changes
Infer
deploymentType
from stack tags instead. If we can't we don't include that stack/backend in the result.Corresponding docs PR, if applicable:
Validation
Checklist
run-e2e
label set.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.