Medplum CLI not able to find stack for list, descr...
# support
d
Hello, we have a Medplum deployment hosted on AWS. The environment name is
dev
. We have been attempting to update to the newest version, but we're getting an error "Stack not found: dev". When running the
describe-stacks
command with the aws cli, we are able to see the stack, and the tag is present as expected. Sample outputs below:
Copy code
npx medplum aws describe dev
Stack not found: dev

AWS Region:         us-east-1
AWS Account ID:     600000000006
AWS Account ARN:    arn:aws:sts::600000000006:assumed-role/AWSReservedSSO_AdministratorAccess_0be77xxxxxxxxxxc/pdamra
AWS User ID:        ARXXXXXXXXXXXXXXXXXXX:pdamra
Error: Stack not found: dev
Copy code
aws cloudformation describe-stacks --stack-name medplum-dev | jq '.Stacks[0].Tags'
[
  {
    "Key": "medplum:environment",
    "Value": "dev"
  }
]
d
I'm a coworker of @djheru and have some additional info that may be helpful. It looks like the
ListStacksCommand
is paginated and stops at 100 results by default without a
StackStatusFilter
param in the command. https://github.com/medplum/medplum/blob/main/packages/cli/src/aws/utils.ts#L46 In our AWS account, we have a lot of stacks with
StackStatus
of
DELETE_COMPLETE
(it's a shared dev AWS account) and are well over that 100. It appears that the stack we're looking for is after this pagination and never gets retuned. I was curious if it would be possible for y'all to edit your cli code to have a filter that would explicitly exclude
'DELETED_COMPLETE'
in the initial set of results (I do see you're filtering it out later but at that point we're at 100 results returned), so others don't run into the same issue we did?
Copy code
const listResult = await cloudFormationClient.send(
    new ListStacksCommand({
      StackStatusFilter: [
        'CREATE_COMPLETE',
        'UPDATE_COMPLETE',
        'ROLLBACK_COMPLETE',
        'ROLLBACK_FAILED',
        'UPDATE_ROLLBACK_COMPLETE',
        'UPDATE_ROLLBACK_FAILED',
      ],
    })
  );

  return (
    (listResult.StackSummaries?.filter((s) => s.StackName) as (StackSummary & {
      StackName: string;
    })[]) || []
  );
I'm happy to PR this as well if that is easier and we're in agreement on the problem and solution. Open to thoughts + feedback on this. Thanks for creating such a great platform for us and any help/insight is highly appreciated.
r
Have not encountered this one before! This is insightful. If you wouldn't mind filing a task for it, that would be appreciated.
By tasks I mean Github issue 🙂 https://github.com/medplum/medplum/issues
d
r
Thank you so much for the PR @deeheber ! https://github.com/medplum/medplum/pull/4970/files
188 Views