# Upgrade Code Ocean

## Overview

Upgrading a Code Ocean VPC deployment to a new version is performed by simply updating the CloudFormation stack with a new CloudFormation template.

## Prerequisites

1. If you have a backup stack configured, please follow the upgrade procedure for the backup stack using the [latest CloudFormation backup stack template version](https://docs.codeocean.com/admin-guide/v3.2/the-admin-dashboard/backup-and-restore#disaster-recovery) prior to upgrading the linked primary deployment.
2. If you are using a least privileged IAM role to update your CloudFormation stack, make sure to first update your least privileged IAM role. [Learn more](https://docs.codeocean.com/admin-guide/v3.2/deployment-guide/deployment-iam-role).

## Enable Maintenance Mode

Before you start the CloudFormation update of your Code Ocean VPC stack, it's required that all active sessions are saved and there are no ongoing computations.

Putting the system in maintenance mode restricts user access to the system, while performing essential tasks prior to a system update, including stopping running computations, stopping system and AWS Batch jobs, and terminating worker instances.

{% hint style="info" %}
To minimize disruption, notify users in advance, and consider using the user banner message to communicate this effectively. [Learn more](https://docs.codeocean.com/admin-guide/v3.2/the-admin-dashboard/adding-removing-a-user-banner-message).
{% endhint %}

1. From the Code Ocean VPC Admin Panel, click **System Maintenance**
2. Click on **Enable Maintenance Mode**

![](https://840299913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTaG6HFiQu5rIqquykFII%2Fuploads%2Fgit-blob-5bc34cb42e0f421f555bab0bf8c6628784846c27%2Fmain1.png?alt=media)

The system will provide progress information on the maintenance mode steps.\
When the steps are complete, the system is ready and you can then proceed with the CloudFormation upgrade. Once the upgrade is complete, the system will automatically disable maintenance mode. Alternatively, you can manually disable maintenance mode at any time by clicking **Disable Maintenance Mode**.

<figure><img src="https://840299913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTaG6HFiQu5rIqquykFII%2Fuploads%2Fgit-blob-83bc468f7cffe88a27766ce576a78d503c3ef8c3%2Fmaint2.png?alt=media" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
The maintenance mode is introduced in v3.1, so if you are upgrading from version < 3.1, please follow [this guide](https://docs.codeocean.com/admin-guide/v3.0/deployment-guide/upgrade-code-ocean) to manually stop the activity on AWS before updating the CFN Stack.
{% endhint %}

## Update the CloudFormation Stack

Upgrading Code Ocean is done by updating the CloudFormation stack you've [created upon deployment](https://docs.codeocean.com/admin-guide/v3.2/cloudformation-deployment#create-cloudformation-stack) :

![](https://840299913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTaG6HFiQu5rIqquykFII%2Fuploads%2Fgit-blob-ed12d965eaeeb393726d23d33eef4e93f77599d8%2FScreenshot%202021-08-17%20at%2010.49.52.png?alt=media)

On the next screen, select **Replace current template**, then **Amazon S3 URL,** and specify the CloudFormation template URL. You can find the URL in [Step 1 - Specify the template](https://docs.codeocean.com/admin-guide/v3.2/cloudformation-deployment#step-1-specify-the-template) section, or use a URL you've received from our support team:

![](https://840299913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTaG6HFiQu5rIqquykFII%2Fuploads%2Fgit-blob-eb4a43e05dc4d6d1648a82795aa689376a6450b8%2Fimage%20\(72\).png?alt=media)

Click **Next** when you are done.

### Specify Stack Details

The *Analytics RDS Instance Allocated Storage* parameter must be verified during upgrades, as the RDS instance storage can scale up automatically. The parameter should be adjusted accordingly to prevent upgrade failures.

{% hint style="warning" %}
**Stack's Parameters** will be set to the values that have been set upon the latest upgrade/deployment, or to their recommended defaults. Please visit the [Deployment Parameters](https://docs.codeocean.com/admin-guide/v3.2/deployment-guide/deployment-parameters) page for the full list of parameters and their purpose. Please contact our support or email <support@codeocean.com> if you have any questions or you need help regarding parameters values.
{% endhint %}

Click **Next**.

### Configure Stack Options (Optional)

You can specify tags (key-value pairs) for resources in your stack and set advanced options.

Click **Next** when you are done.

### Review

1. Review and assure that all the details are correct.
2. Check the box to acknowledge that CloudFormation might create IAM resources.
3. Click **Update stack** to start the deployment.

After you click on Update stack, you will be redirected to the stack screen where you can follow the progress of your stack update under the **Events** tab.

### Upgrade Completion

When the stack update is finished, the state of the CloudFormation stack will turn into `UPDATE_COMPLETE` .
