

文件 AWS 開發套件範例 GitHub 儲存庫中有更多可用的 [AWS SDK 範例](https://github.com/awsdocs/aws-doc-sdk-examples)。

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

# AWS Outposts 使用 的範例 AWS CLI
<a name="cli_2_outposts_code_examples"></a>

下列程式碼範例示範如何使用 AWS Command Line Interface 搭配 來執行動作和實作常見案例 AWS Outposts。

*Actions* 是大型程式的程式碼摘錄，必須在內容中執行。雖然動作會告訴您如何呼叫個別服務函數，但您可以在其相關情境中查看內容中的動作。

每個範例均包含完整原始碼的連結，您可在連結中找到如何設定和執行內容中程式碼的相關指示。

**Topics**
+ [動作](#actions)

## 動作
<a name="actions"></a>

### `get-outpost-instance-types`
<a name="outposts_GetOutpostInstanceTypes_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `get-outpost-instance-types`。

**AWS CLI**  
**取得 Outpost 上的執行個體類型**  
下列 `get-outpost-instance-types` 範例會取得指定 Outpost 的執行個體類型。  

```
aws outposts get-outpost-instance-types \
    --outpost-id op-0ab23c4567EXAMPLE
```
輸出：  

```
{
    "InstanceTypes": [
        {
            "InstanceType": "c5d.large"
        },
        {
            "InstanceType": "i3en.24xlarge"
        },
        {
            "InstanceType": "m5d.large"
        },
        {
            "InstanceType": "r5d.large"
        }
    ],
    "OutpostId": "op-0ab23c4567EXAMPLE",
    "OutpostArn": "arn:aws:outposts:us-west-2:123456789012:outpost/op-0ab23c4567EXAMPLE"
}
```
如需詳細資訊，請參閱《AWS Outposts 使用者指南》**中的[在 Outpost 上啟動執行個體](https://docs.aws.amazon.com/outposts/latest/userguide/launch-instance.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetOutpostInstanceTypes](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/outposts/get-outpost-instance-types.html)。

### `get-outpost`
<a name="outposts_GetOutpost_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `get-outpost`。

**AWS CLI**  
**取得 Outpost 詳細資訊**  
下列 `get-outpost` 範例顯示指定 Outpost 的詳細資訊。  

```
aws outposts get-outpost \
    --outpost-id op-0ab23c4567EXAMPLE
```
輸出：  

```
{
    "Outpost": {
        "OutpostId": "op-0ab23c4567EXAMPLE",
        "OwnerId": "123456789012",
        "OutpostArn": "arn:aws:outposts:us-west-2:123456789012:outpost/op-0ab23c4567EXAMPLE",
        "SiteId": "os-0ab12c3456EXAMPLE",
        "Name": "EXAMPLE",
        "LifeCycleStatus": "ACTIVE",
        "AvailabilityZone": "us-west-2a",
        "AvailabilityZoneId": "usw2-az1",
        "Tags": {}
    }
}
```
如需詳細資訊，請參閱《AWS Outposts 使用者指南》**中的[使用 Outpost](https://docs.aws.amazon.com/outposts/latest/userguide/work-with-outposts.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetOutpost](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/outposts/get-outpost.html)。

### `list-outposts`
<a name="outposts_ListOutposts_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `list-outposts`。

**AWS CLI**  
**列出 Outpost**  
下列`list-outposts`範例列出您 AWS 帳戶中的 Outpost。  

```
aws outposts list-outposts
```
輸出：  

```
{
    "Outposts": [
        {
            "OutpostId": "op-0ab23c4567EXAMPLE",
            "OwnerId": "123456789012",
            "OutpostArn": "arn:aws:outposts:us-west-2:123456789012:outpost/op-0ab23c4567EXAMPLE",
            "SiteId": "os-0ab12c3456EXAMPLE",
            "Name": "EXAMPLE",
            "Description": "example",
            "LifeCycleStatus": "ACTIVE",
            "AvailabilityZone": "us-west-2a",
            "AvailabilityZoneId": "usw2-az1",
            "Tags": {
                "Name": "EXAMPLE"
            }
        },
        {
            "OutpostId": "op-4fe3dc21baEXAMPLE",
            "OwnerId": "123456789012",
            "OutpostArn": "arn:aws:outposts:us-west-2:123456789012:outpost/op-4fe3dc21baEXAMPLE",
            "SiteId": "os-0ab12c3456EXAMPLE",
            "Name": "EXAMPLE2",
            "LifeCycleStatus": "ACTIVE",
            "AvailabilityZone": "us-west-2a",
            "AvailabilityZoneId": "usw2-az1",
            "Tags": {}
        }
    ]
}
```
如需詳細資訊，請參閱《AWS Outposts 使用者指南》**中的[使用 Outpost](https://docs.aws.amazon.com/outposts/latest/userguide/work-with-outposts.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [ListOutposts](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/outposts/list-outposts.html)。

### `list-sites`
<a name="outposts_ListSites_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `list-sites`。

**AWS CLI**  
**列出網站**  
下列`list-sites`範例列出您 AWS 帳戶中可用的 Outpost 網站。  

```
aws outposts list-sites
```
輸出：  

```
{
    "Sites": [
        {
            "SiteId": "os-0ab12c3456EXAMPLE",
            "AccountId": "123456789012",
            "Name": "EXAMPLE",
            "Description": "example",
            "Tags": {}
        }
    ]
}
```
如需詳細資訊，請參閱《AWS Outposts 使用者指南》**中的[使用 Outpost](https://docs.aws.amazon.com/outposts/latest/userguide/work-with-outposts.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [ListSites](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/outposts/list-sites.html)。