

• 2026 年 4 月 30 日之後將不再提供 AWS Systems Manager CloudWatch Dashboard。客戶可以繼續使用 Amazon CloudWatch 主控台來檢視、建立和管理其 Amazon CloudWatch 儀表板，就像現在一樣。如需詳細資訊，請參閱 [Amazon CloudWatch Dashboard 文件](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Dashboards.html)。

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 在Parameter Store中使用參數版本
<a name="sysman-paramstore-versions"></a>

每次編輯參數的值時， 中的工具Parameter Store都會 AWS Systems Manager 建立新的參數*版本*，並保留先前的版本。當您最初建立參數時，Parameter Store 會將該參數指派為版本 `1`。當您變更參數值時，Parameter Store 會自動將版本號增加 1。您可以在參數歷程記錄中檢視所有版本的詳細資訊，包括值。

您也可以指定要在 API 命令和 SSM 文件中使用的參數版本，例如：`ssm:MyParameter:3`。您可以在 API 呼叫與 SSM 文件中指定參數名稱和特定版本號碼。如果您不指定版本編號，系統會自動使用最新的版本。如果您指定不存在的版本編號，系統會傳回錯誤，而不是返回使用參數的最新或預設版本。

您可以使用參數版本來查看參數在一段時間內變更的次數。參數版本也提供一層保護，以防不小心變更參數值。

一個參數最多可以建立最多 100 個版本。建立 100 個參數版本後，每次建立新版本時，會從歷史記錄中移除最舊版本的參數，以騰出空間供新版本使用。

例外狀況是歷史記錄中已有 100 個參數版本，並將參數標籤指派給最舊版本的參數。在這種情況下，不會從歷史記錄中移除該版本，而建立新參數版本的請求會失敗。此防護措施是為了避免刪除具有指定任務關鍵型標籤的參數版本。若要繼續建立新參數，請先將標籤從最舊版本的參數移至較新的參數，以便在操作中使用。如需有關移動參數標籤的相關資訊，請參閱 [使用主控台移動參數標籤](sysman-paramstore-labels.md#sysman-paramstore-labels-console-move) 和 [使用 移動參數標籤 AWS CLI](sysman-paramstore-labels.md#sysman-paramstore-labels-cli-move)。

以下程序說明如何編輯參數，然後確認新版本已經建立。您可以使用 `get-parameter` 和 `get-parameters` 命令來檢視參數版本。如需有關使用這些命令的範例，請參閱《*AWS Systems Manager API 參考*》中的 [GetParameter](https://docs.aws.amazon.com/systems-manager/latest/APIReference/API_GetParameter.html#API_GetParameter_Examples) 和 [GetParameters](https://docs.aws.amazon.com/systems-manager/latest/APIReference/API_GetParameters.html#API_GetParameters_Examples) 

**Topics**
+ [使用主控台建立新的參數版本](#sysman-paramstore-version-console)
+ [參考參數版本](#reference-parameter-version)

## 使用主控台建立新的參數版本
<a name="sysman-paramstore-version-console"></a>

您可以使用 Systems Manager 主控台建立參數的新版本，並檢視參數的版本歷程記錄。

**建立參數的新版本**

1. 在 https：//[https://console.aws.amazon.com/systems-manager/](https://console.aws.amazon.com/systems-manager/) 開啟 AWS Systems Manager 主控台。

1. 在導覽窗格中，選擇 **Parameter Store**。

1. 選擇您先前建立之參數的名稱。如需有關建立新參數的資訊，請參閱[在 Systems Manager 中建立 Parameter Store 參數](sysman-paramstore-su-create.md)。

1. 選擇**編輯**。

1. 在 **Value** (值) 方塊中輸入新的值，然後選擇 **Save changes** (儲存變更)。

1. 選擇剛才更新的參數名稱。請在 **Overview (概觀)** 索引標籤上確認版本編號增加 1，然後確認新的值。

1. 若要檢視參數所有版本的歷程記錄，請選擇 **History (歷程記錄)** 索引標籤。

## 參考參數版本
<a name="reference-parameter-version"></a>

您可以在命令、API 呼叫和 SSM 文件中，使用下列格式來參考特定參數版本：ssm: `{{parameter-name}}:{{version-number}}`。

在下列範例中，Amazon Elastic Compute Cloud (Amazon EC2) `run-instances command` 使用參數 `golden-ami` 的第 3 版。

------
#### [ Linux & macOS ]

```
aws ec2 run-instances \
    --image-id resolve:ssm:/golden-ami:3 \
    --count 1 \
    --instance-type t2.micro \
    --key-name {{my-key-pair}} \
    --security-groups {{my-security-group}}
```

------
#### [ Windows ]

```
aws ec2 run-instances ^
    --image-id resolve:ssm:/golden-ami:3 ^
    --count 1 ^
    --instance-type t2.micro ^
    --key-name {{my-key-pair}} ^
    --security-groups {{my-security-group}}
```

------

**注意**  
使用 `resolve` 和參數值僅適用於 `--image-id` 選項和包含 Amazon Machine Image (AMI) 做為其數值的參數。如需詳細資訊，請參閱[使用 Parameter Store 中 Amazon Machine Image ID 的原生參數支援](parameter-store-ec2-aliases.md)。

以下是在 SSM 文件中指定 `MyRunCommandParameter` 參數第 2 版的範例。

------
#### [ YAML ]

```
---
schemaVersion: '2.2'
description: Run a shell script or specify the commands to run.
parameters:
  commands:
    type: String
    description: "(Required) Specify a shell script or a command to run."
    displayType: textarea
    default: "{{ssm:MyRunCommandParameter:2}}"
mainSteps:
- action: aws:runShellScript
  name: RunScript
  inputs:
    runCommand:
    - "{{commands}}"
```

------
#### [ JSON ]

```
{
    "schemaVersion": "2.2",
    "description": "Run a shell script or specify the commands to run.",
    "parameters": {
        "commands": {
            "type": "String",
            "description": "(Required) Specify a shell script or a command to run.",
            "displayType": "textarea",
            "default": "{{ssm:MyRunCommandParameter:2}}"
        }
    },
    "mainSteps": [
        {
            "action": "aws:runShellScript",
            "name": "RunScript",
            "inputs": {
                "runCommand": [
                    "{{commands}}"
                ]
            }
        }
    ]
}
```

------