Pause and resume environments with CI/CD jobs

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

  • Close this issue

Problem to solve

GitLab tracks environments and deployments, typically defined via CI/CD pipelines. Environments can be started or stopped, which correspond to CI/CD jobs with an environment:action value of start or stop.

As a developer, I sometimes have environments that are expensive to deploy and run. To save on costs, I want to pause them during off hours. I have CI/CD pipelines to start and stop the environment. But, the stop job removes all the deployed resources. I would like to have pause and resume states that fit in between start and stop in the environment lifecycle, to easily pause but not fully stop an environment.

Intended users

  • Sasha (Software Developer)
  • Devon (DevOps Engineer)
  • Sidney (Systems Administrator)

User experience goal

Within a GitLab CI/CD YAML file, I can define jobs for starting and stopping environments. For example, suppose there is a pair of jobs for creating and deleting AWS Redshift clusters.

create_cluster:
  stage: deploy
  script:
    - aws redshift create-cluster
  environment:
    name: review/$CI_COMMIT_REF_NAME
    action: start    
    on_stop: stop_cluster

delete_cluster:
  stage: deploy
  script:
    - aws redshift delete-cluster
  environment:
    name: review/$CI_COMMIT_REF_NAME
    action: stop

The Redshift cluster might be large and expensive. During off-hours, I want to pause the cluster. Using GitLab environments, my only option is to stop the environment, which will delete the cluster, causing me to lose unfinished work. While I can pause the cluster outside of GitLab, I would like to include that as part of my CI/CD pipeline and use GitLab to manage the extra state.

create_cluster:
  stage: deploy
  script:
    - aws redshift create-cluster …
  environment:
    name: review/$CI_COMMIT_REF_NAME
    action: start    
    on_stop: stop_cluster
    on_pause: pause_cluster
    on_resume: resume_cluster

pause_cluster:
  stage: deploy
  script:
    - aws redshift pause-cluster …
  environment:
    name: review/$CI_COMMIT_REF_NAME
    action: pause

resume_cluster:
  stage: deploy
  script:
    - aws redshift resume-cluster …
  environment:
    name: review/$CI_COMMIT_REF_NAME
    action: resume

delete_cluster:
  stage: deploy
  script:
    - aws redshift delete-cluster …
  environment:
    name: review/$CI_COMMIT_REF_NAME
    action: stop

Given pause and resume jobs, I should able to use the GitLab Environments API or a project's Environments page to pause and resume an environment. GitLab should run the associated CI/CD jobs.

Proposal

Add the ability to specify pause and resume jobs for an environment.

The pause and resume jobs are available after an environment is started and before it's stopped. Pause and resume jobs should be runnable multiple times while an environment is not stopped.

Further details

My immediate want is to use this with AWS RDS and Redshift databases. I want to make it easy for developers to temporarily pause databases they are not actively using, but don't want to completely remove. This can also apply for things like deployed Docker services, where pausing can mean scaling to 0 replicas so they're not actively consuming resources.

Permissions and Security

Existing environment permissions and security should apply.

Documentation

Availability & Testing

What does success look like, and how can we measure that?

Users can use the GitLab environments feature to temporarily pause environments, manually or by a schedule.

What is the type of buyer?

GitLab environments and deployments are part of core.

Is this a cross-stage feature?

Links / references

Edited Sep 22, 2025 by 🤖 GitLab Bot 🤖
Assignee Loading
Time tracking Loading