

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

# 建立資源總管資源 CloudFormation

AWS 資源總管已整合AWS CloudFormation，這項服務可協助您建AWS資源的模型和設定。這項整合可協助您建資的資源和基礎設施的時間。您可以建立一個範本，描述所有您想要的 AWS 資源，CloudFormation 就會為您佈建和設定那些資源。資源的範例包括索引、檢視表或預設檢視表的指定AWS 區域。

當您使用時CloudFormation，您可以重複使用您的範本，以便重複且一致地設定您的資源資源。只需描述一次您的資源，即可在多個和區域內反復佈建相同AWS 帳戶的資源。

**使用CloudFormation將資源總管部署到 AWS Organizations**  
您可以使CloudFormationStackSets用將資源總管部署到組織中的所有帳號。當您在組織中新增或建立成員帳戶時，StackSets可以自動為每個新成員帳戶設定每個AWS 區域成員帳戶中的索引，包括您在其中指定的彙總索引。如需相關指示，請參閱[將資源總管部署到組織中的帳號](manage-service-all-org-with-stacksets.md)。

## 資源總管和CloudFormation範本
<a name="working-with-templates"></a>

若要佈建和設定資源總管與相關服務的資源，您必須了解[CloudFormation範本](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-guide.html)。範本是以 JSON 或 YAML 格式化的文本檔案。而您亦可以透過這些範本的說明，了解欲在 CloudFormation 堆疊中佈建的資源。如果您不熟悉 JSON 或 YAML，您可以使用 CloudFormation Designer 協助您開始使用 CloudFormation 範本。如需詳細資訊，請參閱 *AWS CloudFormation 使用者指南*中的[什麼是 CloudFormation Designer？](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/working-with-templates-cfn-designer.html)。

資源總管支援在中建以下資源類型CloudFormation：
+ **[索引](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-resourceexplorer2-index.html)** — 在區域中建立索引，並開啟該區域中的資源總管。您可以指定索引是本機索引，也可以是的彙總索引AWS 帳戶。如需詳細資訊，請參閱 [在中打開資源瀏覽器 AWS 區域 以索引您的資源](manage-service-turn-on-region.md) 及 [透過建立彙總器索引開啟跨區域搜尋](manage-aggregator-region.md)。
+ **[檢視](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-resourceexplorer2-view.html)** — 建立可決定使用者執行搜尋時可顯示哪些結果的檢視。每個搜索操作都必須指定一個視圖。您必須授予使用者使用您希望他們存取的資源。如需詳細資訊，請參閱[管理資源總管檢視以提供搜尋存取權](manage-views.md)。
**注意**  
您必須先在 [區域] 中建立索引，然後才能在同一個 [區域] 中建立檢視表。如果您建立索引和檢視做為相同堆疊的一部分，請使用檢視表上的`DependsOn`屬性 (如下列範例範本所示)，以確保首先建立索引。
+ **[DefaultViewAssociation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-resourceexplorer2-defaultviewassociation.html)**— 將指定的檢視指定為其 [區域] 中的預設檢視。當使用者沒有明確指定要用於搜尋作業的檢視時，Resource Explorer 會嘗試使用與使用者執行搜尋的區域相關聯的預設檢視。如需詳細資訊，請參閱 [在中設定預設檢視AWS 區域](manage-views-set-default.md)

下列範例說明如何在同一個 [區域] 中建立一個索引和檢視表，並將檢視設定為 [區域] 的預設值。

**YAML**

```
Description: >-
  Sample CFN Stack setting up Resource Explorer with an aggregator index and a default view 
Resources:
  SampleIndex:
    Type: 'AWS::ResourceExplorer2::Index'
    Properties:
      Type: AGGREGATOR
      Tags:
        Purpose: ResourceExplorer Sample CFN Stack
  SampleView:
    Type: 'AWS::ResourceExplorer2::View'
    Properties:
      ViewName: mySampleView
      IncludedProperties:
        - Name: tags
      Tags:
        Purpose: ResourceExplorer Sample CFN Stack
    DependsOn: SampleIndex
  SampleDefaultViewAssociation:
    Type: 'AWS::ResourceExplorer2::DefaultViewAssociation'
    Properties:
      ViewArn: !Ref SampleView
```

**JSON**

```
{
    "Description": "Sample CFN Stack setting up Resource Explorer with an aggregator index and a default view ",
    "Resources": {
        "SampleIndex": {
            "Type": "AWS::ResourceExplorer2::Index",
            "Properties": {
                "Type": "AGGREGATOR",
                "Tags": {
                    "Purpose": "ResourceExplorer Sample Stack"
                }
            }
        },
        "SampleView": {
            "Type": "AWS::ResourceExplorer2::View",
            "Properties": {
                "ViewName": "mySampleView",
                "IncludedProperties": [
                    {
                        "Name": "tags"
                    }
                ],
                "Tags": {
                    "Purpose": "ResourceExplorer Sample CFN Stack"
                }
            },
            "DependsOn": "SampleIndex"
        },
        "SampleDefaultViewAssociation": {
            "Type": "AWS::ResourceExplorer2::DefaultViewAssociation",
            "Properties": {
                "ViewArn": {
                    "Ref": "SampleView"
                }
            }
        }
    }
}
```

如需詳細資訊，包括資源總管索引和檢視的 JSON 和 YAML 範本範例，請參閱*《AWS CloudFormation使用者指南》*中的 [ResourceExplorer2 個資源類型參考](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/AWS_ResourceExplorer2.html)。

## 進一步了解 CloudFormation
<a name="learn-more-cloudformation"></a>

若要進一步了解 CloudFormation，請參閱下列資源：
+ [AWS CloudFormation](https://aws.amazon.com/cloudformation/)
+ 《AWS CloudFormation 使用者指南》[https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Welcome.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Welcome.html)
+ 《AWS CloudFormation 命令列介面使用者指南》[https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/what-is-cloudformation-cli.html](https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/what-is-cloudformation-cli.html)