

# Managing AWS Systems Manager Cloud Extensions updates

Control how extensions in AWS Systems Manager Cloud Extensions move to new versions, and update the runtime. Each extension has versions. You control which versions each profile uses by setting a version policy on each profile entry.

**Topics**
+ [How extension versions work](#cloud-extensions-updates-how-extension-versions-work)
+ [Version policies](#cloud-extensions-updates-version-policies)
+ [Updating an extension on the console](#cloud-extensions-updates-updating-an-extension-on-the-console)
+ [Finding available versions](#cloud-extensions-updates-finding-available-versions)
+ [Upgrading to a new major version](#cloud-extensions-updates-upgrading-to-a-new-major-version)
+ [Pinning a version and rolling back](#cloud-extensions-updates-pinning-a-version-and-rolling-back)
+ [Testing updates before production](#cloud-extensions-updates-testing-updates-before-production)
+ [Updating the runtime](#cloud-extensions-updates-updating-the-runtime)
+ [Best practices](#cloud-extensions-updates-best-practices)
+ [Troubleshooting](#cloud-extensions-updates-troubleshooting)
+ [Next steps](#cloud-extensions-updates-next-steps)

## How extension versions work
<a name="cloud-extensions-updates-how-extension-versions-work"></a>

AWS publishes each extension release as an immutable package. After AWS publishes a release, the release doesn't change. Each release has the following properties:
+ **version** – A semantic version in the form major.minor.patch, such as `1.2.3`.
+ **releaseNotes** – Notes from the extension author that describe what changed in the release.
+ **documentationLink** – A link to documentation for the extension.
+ **releasedAt** – The time when AWS published the release.

AWS can recall a release. A recalled release has the state `RECALLED`. AWS releases new versions to Regions gradually, so a new version doesn't appear in every Region at the same time.

Extensions follow semantic versioning:
+ **Patch versions** contain bug fixes and no breaking changes. For example, 1.0.0 to 1.0.1 is a patch release.
+ **Minor versions** add features and contain no breaking changes. For example, 1.0.0 to 1.1.0 is a minor release.
+ **Major versions** can contain breaking changes. For example, 1.0.0 to 2.0.0 is a major release.

## Version policies
<a name="cloud-extensions-updates-version-policies"></a>

A profile entry has a version policy with two fields:
+ **updateStrategy** – How the entry adopts new releases. The value is `AUTOMATIC` or `MANUAL`.
+ **versionSelector** – Limits the versions that the entry can use.

### Update strategies
<a name="cloud-extensions-updates-update-strategies"></a>

**AUTOMATIC**

The runtime updates the extension to newer releases that match the version selector. Use the selector to limit how far the runtime can move. For example, the selector `1.2.x` limits updates to patches within minor version 1.2. The selector must leave the minor or patch version open, such as `1.x.x` or `1.2.x`. If you don't give a selector, Cloud Extensions uses `{{major}}.x.x` for the latest major version at that time. The entry never moves to a new major version on its own. A profile entry that you create with no version policy gets the `AUTOMATIC` strategy in this way.

**MANUAL**

The runtime doesn't apply automatic updates. The version selector must identify one specific version, such as `1.2.3`. To move to a different version, you change the selector yourself.

### Version selectors
<a name="cloud-extensions-updates-version-selectors"></a>

A version selector identifies a set of versions. You can use `x`, `X`, or `*` as a wildcard in the minor or patch position. The major version is always a number. The following table shows examples:


| Selector | Matches | 
| --- | --- | 
| `1` | Versions with major version 1 | 
| `1.x` | Versions with major version 1 | 
| `1.x.x` | Versions with major version 1 | 
| `1.2` | Versions with major version 1 and minor version 2 | 
| `1.2.x` | Versions with major version 1 and minor version 2 | 
| `1.2.3` | Version 1.2.3 only | 

A selector doesn't accept values such as `latest`.

### Setting the version policy
<a name="cloud-extensions-updates-setting-the-version-policy"></a>

To set the version policy when you add an extension to a profile, use the `--version-policy` option of the `create-profile-entry` command:

```bash
aws cloudextensions create-profile-entry \
  --profile-identifier my-application \
  --extension-identifier aws:parameterstore \
  --version-policy updateStrategy=AUTOMATIC,versionSelector=1.x.x
```

To change the version policy of an existing profile entry, use the `update-profile-entry` command:

```bash
aws cloudextensions update-profile-entry \
  --profile-identifier my-application \
  --identifier {{profile-entry-id}} \
  --version-policy updateStrategy=MANUAL,versionSelector=1.2.3
```

The runtime detects the change during its next poll. By default, the runtime polls every 45 seconds.

## Updating an extension on the console
<a name="cloud-extensions-updates-updating-an-extension-on-the-console"></a>

The console shows the version and the update method of each extension in a profile. The console offers two update methods:
+ **Latest (recommended)** – The extension gets new minor versions and patches as AWS releases them, but not a new major version.
+ **Specific version** – The extension stays on the version that you choose.

The console doesn't let you enter a version selector such as `1.x.x`. To use a version selector, use the AWS CLI. For more information, see [Version policies](#cloud-extensions-updates-version-policies).

**To check whether a newer version exists**

1. Open the Systems Manager console at [https://console.aws.amazon.com/systems-manager/](https://console.aws.amazon.com/systems-manager/).

1. In the navigation pane, choose **Cloud Extensions**.

1. Choose the **Profiles** tab, and then choose the name of the profile.

1. On the **Extensions** tab, review the **Version** and **Update method** columns.

If you chose a specific version and a newer version exists, the **Version** column shows **Update available** with the newer version number. For example, the column shows **Update available: 1.2.0**. Choose the link to see the message "Version 1.2.0 is available." An extension that uses the latest version shows **(latest)** after the version number.

To see all versions of an extension, open the page of the extension in the **Extension catalog**, and then choose the **Versions** tab. The tab lists each version with its release time and release notes, and it marks the latest version.

**To change the update method or the version**

1. On the **Extensions** tab of the profile, select the extension, and then choose **Edit**. You can also choose the **Update available** link, and then choose **Edit extension**.

1. Under **Update method**, choose **Latest (recommended)** or **Specific version**.

1. If you choose **Specific version**, choose the version.

1. Choose **Save changes**. Changing the version resets the settings on the page to the values that the profile stores.

Resources that use the profile get the change the next time that they start or receive an invocation.

## Finding available versions
<a name="cloud-extensions-updates-finding-available-versions"></a>

To list the released versions of an extension, run the following command:

```bash
aws cloudextensions list-extension-versions --identifier aws:parameterstore
```

To list only the versions that match a version selector, use the `--version-selector` option:

```bash
aws cloudextensions list-extension-versions \
  --identifier aws:parameterstore \
  --version-selector 1.2.x
```

To view the details of one version, including its settings, capabilities, and interfaces, run the following command:

```bash
aws cloudextensions get-extension \
  --identifier aws:parameterstore \
  --extension-version 1.2.3
```

Without the `--extension-version` option, the `get-extension` command returns the latest version.

Before you move a profile entry to a new version, read the release notes. Compare the settings and capabilities of the new version with the current version. A new version can declare new capabilities. An extension can use a capability only after you approve the capability.

## Upgrading to a new major version
<a name="cloud-extensions-updates-upgrading-to-a-new-major-version"></a>

A selector such as `1.x.x` keeps the profile entry within major version 1, so the runtime never moves to major version 2 on its own. To upgrade, change the selector:

```bash
aws cloudextensions update-profile-entry \
  --profile-identifier my-application \
  --identifier {{profile-entry-id}} \
  --version-policy updateStrategy=AUTOMATIC,versionSelector=2.x.x
```

## Pinning a version and rolling back
<a name="cloud-extensions-updates-pinning-a-version-and-rolling-back"></a>

Releases are immutable, so a profile entry that uses the `MANUAL` strategy with an exact version runs the same package every time. Pin a version for workloads that require change control.

To roll back to an earlier release, set the version policy to the `MANUAL` strategy with the exact version that you want:

```bash
aws cloudextensions update-profile-entry \
  --profile-identifier my-application \
  --identifier {{profile-entry-id}} \
  --version-policy updateStrategy=MANUAL,versionSelector=1.2.2
```

## Testing updates before production
<a name="cloud-extensions-updates-testing-updates-before-production"></a>

Profiles are separate configuration contexts, so you can test a new version in one profile before you move another profile to the version. Keep the production profile entry on the `MANUAL` strategy with an exact version until you finish testing. To test an update:

1. Create a profile for testing, such as `my-application-staging`, and add the extension with the `AUTOMATIC` strategy and a broad selector such as `1.x.x`.

1. Run your test workloads with the staging profile.

1. When the new version passes your tests, update the production profile entry to the same version.

## Updating the runtime
<a name="cloud-extensions-updates-updating-the-runtime"></a>

The version policy applies to extensions. The runtime has its own update process, which depends on how you installed the runtime.
+ **Lambda** – A Lambda layer ARN includes a version number. To update the runtime, get the latest ARN from the public parameter and update the layers of your function:

  ```bash
  aws ssm get-parameter \
    --name /aws/service/aws-cloudextensions/lambda-extension/amd64/latest \
    --query 'Parameter.Value' \
    --output text
  aws lambda update-function-configuration \
    --function-name my-function \
    --layers {{layer-arn}}
  ```
+ **Containers** – Pull the updated image from Amazon ECR, and then restart your containers:

  ```bash
  docker pull public.ecr.aws/aws-cloudextensions/cloudextensions-runtime:latest
  ```

## Best practices
<a name="cloud-extensions-updates-best-practices"></a>

1. **Use AUTOMATIC with a major version selector** – A selector such as `1.x.x` moves the entry to minor and patch versions within major version 1.

1. **Use the MANUAL strategy for change control** – Pin an exact version in production, and move the version when you finish testing.

1. **Test in a separate profile** – Validate new versions in a non-production profile first.

1. **Read the release notes** – Check the release notes and the declared capabilities before you move to a new version.

1. **Record the version that you run** – Use the `get-profile-entry` command to confirm the version policy of each entry.

1. **Keep the runtime current** – Update the Lambda layer or container image regularly.

## Troubleshooting
<a name="cloud-extensions-updates-troubleshooting"></a>

### A new version doesn't apply
<a name="cloud-extensions-updates-a-new-version-doesnt-apply"></a>

**Symptom:** A new extension version exists, but the profile entry doesn't use the version.

Check the following causes:

1. **The strategy is MANUAL** – A profile entry with the `MANUAL` strategy never moves to a new version on its own. Change the version selector.

1. **The selector excludes the version** – A selector such as `1.2.x` doesn't match version `1.3.0`. List the versions that match the selector:

   ```bash
   aws cloudextensions list-extension-versions \
     --identifier aws:parameterstore \
     --version-selector 1.2.x
   ```

1. **The runtime hasn't polled yet** – Wait for at least one poll interval, which is 45 seconds by default.

### The runtime logs a hash mismatch
<a name="cloud-extensions-updates-the-runtime-logs-a-hash-mismatch"></a>

**Symptom:** The runtime logs a warning that the cached copy of an extension doesn't match the release.

The runtime found that its cached copy of the extension doesn't match the release. The runtime fetches the correct package from the service and loads the package. If the hash still doesn't match after the runtime downloads the extension again, the runtime doesn't load that version. If an earlier version of the extension is already running, that version keeps running. If not, the extension stays unloaded, and calls to the extension fail. The runtime tries again at its later profile checks. If the warning repeats, contact Support.

## Next steps
<a name="cloud-extensions-updates-next-steps"></a>
+ [Working with AWS Systems Manager Cloud Extensions profiles](cloud-extensions-profiles.md)
+ [Security in AWS Systems Manager Cloud Extensions](cloud-extensions-security.md)
+ [Monitoring AWS Systems Manager Cloud Extensions](cloud-extensions-monitoring.md)
+ [Troubleshooting AWS Systems Manager Cloud Extensions](cloud-extensions-troubleshooting.md)