

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

# 將資源總管部署到組織中的帳號
<a name="manage-service-all-org-with-stacksets"></a>

透過使用 AWS CloudFormation StackSets，您可以定義並部署至組織中管理的所有帳戶 AWS Organizations。當您定義堆疊集時，您可以指定您要在所指定的所有目標帳戶 AWS 區域 和跨越所有目標帳戶建立的 AWS 資源。當所有帳戶都屬於同一組織時，您可以利用與組 Organizations CloudFormation 整合的優勢，並讓這些服務處理跨帳戶角色的建立。您可以在組織中啟用自動部署，這會自動將堆疊執行個體部署到 future 可能新增至目標組織或組織單位 (OU) 的新帳戶。如果您從組織中移除帳號，則 CloudFormation 會自動刪除任何部署為組織堆疊執行個體一部分的資源。若要取得有關的更多資訊 StackSets，請參閱[使用](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/what-is-cfnstacksets.html)*指南 AWS CloudFormation StackSets中的〈AWS CloudFormation 使用*〉。

您可 CloudFormation StackSets 以使用在組織中的所有帳戶 AWS 資源總管 中開啟和設定、在每個已啟用的區域中建立索引，以及在需要的位置建立檢視表。

**重要**  
如果您嘗試在區域中設定彙總器索引，則必須確定該帳戶在任何其他區域中都沒有現有的彙總器索引。將彙總器索引降級為本機索引之後，您必須等待 24 小時，才能將另一個索引升級為帳戶的新彙總索引。

## 必要條件
<a name="stacksets-prereqs"></a>

若要用 CloudFormation StackSets 來將 Resource Explorer 部署到組織中的帳號，您或組織的管理員必須先執行下列步驟，才能啟用具有服務管理權限的堆疊：

1. 組織必須啟用[所有功能](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_org_support-all-features.html)。如果組織僅啟用合併帳單功能，您就無法建立具有服務管理權限的堆疊集。

1. [開啟 CloudFormation 和 Organizations 之間的信任存取](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/stacksets-orgs-enable-trusted-access.html)。這會 CloudFormation 授與建立組織管理帳戶中所需角色的權限，且成員帳號 CloudFormation 將部署 Resource Explorer 索引和檢視。

現在您可以建立具有服務管理權限的堆疊集。

**重要**  
您必須在組織的管理帳戶中建立堆疊集。 CloudFormation 是一項地區服務，因此您只能從原先建立的區域中檢視和管理您建立的堆疊集。

## 建立資源總管的堆疊集
<a name="stacksets-create"></a>

完全部署資源總管，您必須部署兩個堆疊集。
+ 第一個堆疊集會建立彙總器索引和預設檢視，讓使用者搜尋帳戶中所有區域的資源。

  ***只***將此堆疊集部署到您要在其中建立彙總索引的單一區域。
+ 第二個堆棧集創建一個本地索引和默認視圖。本機索引會將其內容複寫至彙總索引。

  將此堆疊集部署到帳戶中每個已啟用的區域 (包含彙總器索引的區域***除外***)。請勿選擇您部署堆疊的帳戶中未啟用的任何區域。如果這樣做，部署就會失敗。

下一節介紹了每個範本的範例。如需如何使用這些範本建立堆疊集的指 step-by-step示，請參閱使用*指南*中的[建立具有服務管理權限的AWS CloudFormation 堆疊集](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/stacksets-getting-started-create.html#stacksets-orgs-associate-stackset-with-org)。

將這些堆疊集部署到您的組織之後，您所選範圍內的每個帳戶 (組織或組織單位) 都會在指定的區域中具有彙總索引，而且每個其他區域都有本機索引。

## CloudFormation 範例範本
<a name="stacksets-sample-templates"></a>

下列範例範本會建立帳戶的彙總索引和預設檢視，以便在您部署索引的帳戶中，跨所有區域搜尋資源。

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

```
Description: >-
  CFN Stack setting up ResourceExplorer with an Aggregator Index, and a new Default View.
Resources:
  Index:
    Type: 'AWS::ResourceExplorer2::Index'
    Properties:
      Type: AGGREGATOR
      Tags:
        Purpose: ResourceExplorer CFN Stack
  View:
    Type: 'AWS::ResourceExplorer2::View'
    Properties:
      ViewName: DefaultView
      IncludedProperties:
        - Name: tags
      Tags:
        Purpose: ResourceExplorer CFN Stack
    DependsOn: Index
  DefaultViewAssociation:
    Type: 'AWS::ResourceExplorer2::DefaultViewAssociation'
    Properties:
      ViewArn: !Ref View
```

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

```
{
    "Description": "CFN Stack setting up ResourceExplorer with an Aggregator Index, and a new Default View.",
    "Resources": {
        "Index": {
            "Type": "AWS::ResourceExplorer2::Index",
            "Properties": {
                "Type": "AGGREGATOR",
                "Tags": {
                    "Purpose": "ResourceExplorer CFN Stack"
                }
            }
        },
        "View": {
            "Type": "AWS::ResourceExplorer2::View",
            "Properties": {
                "ViewName": "DefaultView",
                "IncludedProperties": [{
                    "Name": "tags"
                }],
                "Tags": {
                    "Purpose": "ResourceExplorer CFN Stack"
                }
            },
            "DependsOn": "Index"
        },
        "DefaultViewAssociation": {
            "Type": "AWS::ResourceExplorer2::DefaultViewAssociation",
            "Properties": {
                "ViewArn": {
                    "Ref": "View"
                }
            }
        }
    }
}
```

------

下列範例範本會在除彙總器索引以外的所有帳戶中，在每個已啟用的區域中建立本機索引。它也會建立預設檢視，讓使用者只能搜尋該區域中的資源。使用者必須在彙總器「區域」中使用檢視進行搜尋，才能在所有區域中搜尋資源。

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

```
Description: >-
  CFN Stack setting up ResourceExplorer with a Local Index, and a new Default View.
Resources:
  Index:
    Type: 'AWS::ResourceExplorer2::Index'
    Properties:
      Type: LOCAL
      Tags:
        Purpose: ResourceExplorer CFN Stack
  View:
    Type: 'AWS::ResourceExplorer2::View'
    Properties:
      ViewName: DefaultView
      IncludedProperties:
        - Name: tags
      Tags:
        Purpose: ResourceExplorer CFN Stack
    DependsOn: Index
  DefaultViewAssociation:
    Type: 'AWS::ResourceExplorer2::DefaultViewAssociation'
    Properties:
      ViewArn: !Ref View
```

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

```
{
    "Description": "CFN Stack setting up ResourceExplorer with a Local Index, and a new Default View.",
    "Resources": {
        "Index": {
            "Type": "AWS::ResourceExplorer2::Index",
            "Properties": {
                "Type": "LOCAL",
                "Tags": {
                    "Purpose": "ResourceExplorer CFN Stack"
                }
            }
        },
        "View": {
            "Type": "AWS::ResourceExplorer2::View",
            "Properties": {
                "ViewName": "DefaultView",
                "IncludedProperties": [{
                    "Name": "tags"
                }],
                "Tags": {
                    "Purpose": "ResourceExplorer CFN Stack"
                }
            },
            "DependsOn": "Index"
        },
        "DefaultViewAssociation": {
            "Type": "AWS::ResourceExplorer2::DefaultViewAssociation",
            "Properties": {
                "ViewArn": {
                    "Ref": "View"
                }
            }
        }
    }
}
```

------