Skip to content

14. Update terminateInstance API endpoint to call UserTerminateEC2 Step Function #29

@JYC-L

Description

@JYC-L

Project: ControlPanel
Summary:

Task Description:

  • Currently, the POST /terminateInstance API endpoint directly invokes the terminateInstanceFunction Lambda, which returns a simple placeholder response.
  • This task involves updating the terminateInstance API endpoint to invoke the UserTerminateEC2Workflow Step Function instead of the Lambda directly.
  • The Step Function orchestrates the EC2 termination workflow (terminating EC2 instances, cleaning up resources, updating session state) and returns its execution status to the client.
  • This decouples the API layer from the termination logic and enables complex multi-step workflows to be managed by Step Functions.

Acceptance Criteria:

  • The POST /terminateInstance API endpoint now accepts userId and instanceId in the request body.
  • The endpoint invokes the UserTerminateEC2Workflow Step Function with the request parameters.
  • The API returns a success/failure status to the client without exposing internal execution details.
  • Input validation is performed before invoking the Step Function (e.g., validate userId, instanceId).
  • Error handling is implemented for Step Function invocation failures.
  • The terminateInstanceFunction Lambda is still available for Step Function tasks but is no longer directly invoked by the API.
  • Step Function execution ARN is stored internally (DynamoDB) but NOT returned to the client for security reasons.

Ticket Progress

  • Documentation Walk-through and Research
  • Code base review
  • High level system design for the API data flow
  • Implementation Plan
  • Code Change: TerminateInstance Step Function Definiation Update
  • Code Change: API gateway endpoint creation
  • Code Change: DynamoDB table Schema
  • Code change: Lambda functions

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions