

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

# 搭配 使用 Amazon S3 Storage Lens AWS Organizations
<a name="storage_lens_with_organizations"></a>

Amazon S3 Storage Lens 是一種雲端儲存體分析功能，您可以用來了解整個組織使用物件儲存體的情況及其活動情形。您可以使用 S3 Storage Lens 指標產生摘要洞見，例如了解您在整個組織中擁有多少儲存體，或是成長速度最快的儲存貯體和字首有哪些。您也可以使用 Amazon S3 Storage Lens 來收集 AWS Organizations 階層 AWS 帳戶 中所有 的儲存指標和用量資料。若要這樣做，您必須使用 AWS Organizations，而且您必須使用 AWS Organizations 管理帳戶啟用 S3 Storage Lens 受信任存取。

啟用受信任存取之後，請為組織中的帳戶新增委派的管理員存取權。委派的管理員帳戶會用來建立 S3 Storage Lens 組態和儀表板，以收集整個組織的儲存指標和使用者資料。如需有關啟用受信任存取權的詳細資訊，請參閱《AWS Organizations 使用者指南》**中的 [Amazon S3 Storage Lens 和 AWS Organizations](https://docs.aws.amazon.com/organizations/latest/userguide/services-that-can-integrate-s3lens.html)。

**Topics**
+ [啟用 S3 Storage Lens 的受信任存取權](storage_lens_with_organizations_enabling_trusted_access.md)
+ [停用 S3 Storage Lens 的受信任存取權](storage_lens_with_organizations_disabling_trusted_access.md)
+ [註冊 S3 Storage Lens 的委派管理員](storage_lens_with_organizations_registering_delegated_admins.md)
+ [取消註冊 S3 Storage Lens 的委派管理員](storage_lens_with_organizations_deregistering_delegated_admins.md)

# 啟用 S3 Storage Lens 的受信任存取權
<a name="storage_lens_with_organizations_enabling_trusted_access"></a>

透過啟用受信任存取，您可以允許 Amazon S3 Storage Lens 透過 AWS Organizations API 操作存取您的 AWS Organizations 階層、成員資格和結構。然後，S3 Storage Lens 成為整個組織結構的受信任服務。

每當建立儀表板組態時，S3 Storage Lens 會在您組織的管理或委派管理員帳戶中建立服務連結角色。服務連結角色授予 S3 Storage Lens 執行下列動作的許可：
+ 描述組織
+ 列出帳戶
+ 驗證組織的 AWS 服務 存取清單
+ 取得組織的委派管理員



然後，S3 Storage Lens 可以確保其擁有存取權，以收集組織中帳戶的跨帳戶指標。如需詳細資訊，請參閱[在 Amazon S3 Storage Lens 使用服務連結角色](https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-service-linked-roles.html)。

啟用受信任存取權之後，您就可以將委派管理員存取權指派給組織中的帳戶。將帳戶標示為服務的委派管理員時，帳戶會收到所有唯讀組織 API 操作的存取授權。此存取權會提供組織成員和結構的委派管理員可見性，讓他們也可以建立 S3 Storage Lens 儀表板。

**注意**  
受信任存取權只能由[管理帳戶](https://docs.aws.amazon.com/managedservices/latest/userguide/management-account.html)啟用。
 只有管理帳戶和委派的管理員可以為您的組織建立 S3 Storage Lens 儀表板或組態。

# 使用 S3 主控台
<a name="storage_lens_console_organizations_enabling_trusted_access"></a>

**讓 S3 Storage Lens 擁有 AWS Organizations 受信任的存取權**

1. 登入 AWS 管理主控台 ，並在 [https://console.aws.amazon.com/s3/](https://console.aws.amazon.com/s3/)：// 開啟 Amazon S3 主控台。

1. 在左側導覽窗格上，導覽至 **Storage Lens**。

1. 選擇 **AWS Organizations 設定**。**Storage Lens 的AWS Organizations 存取**頁面隨即顯示。

1. 在 **AWS Organizations 受信任存取**下，選擇**編輯**。

   **AWS Organizations 存取**頁面隨即顯示。

1. 選擇**啟用**以啟用 S3 Storage Lens 儀表板的受信任存取。

1. 選擇**儲存變更**。

# 使用 AWS CLI
<a name="OrganizationsEnableTrustedAccessS3LensCLI"></a>

**Example**  
下列範例說明如何啟用 S3 Storage Lens 的 AWS Organizations 受信任存取 AWS CLI。  

```
aws organizations enable-aws-service-access --service-principal storage-lens.s3.amazonaws.com
```

# 使用適用於 Java 的 AWS 開發套件
<a name="OrganizationsEnableTrustedAccessS3LensJava"></a>

**Example – 使用適用於 Java 的 SDK 啟用 S3 Storage Lens 的 AWS Organizations 受信任存取**  
下列範例示範如何在適用於 Java 的 SDK 中啟用 S3 Storage Lens 的受信任存取。若要使用此範例，請以您自己的資訊取代 `user input placeholders`。  

```
import com.amazonaws.AmazonServiceException;
import com.amazonaws.SdkClientException;
import com.amazonaws.auth.profile.ProfileCredentialsProvider;
import com.amazonaws.regions.Regions;
import com.amazonaws.services.organizations.AWSOrganizations;
import com.amazonaws.services.organizations.AWSOrganizationsClient;
import com.amazonaws.services.organizations.model.EnableAWSServiceAccessRequest;

public class EnableOrganizationsTrustedAccess {
	private static final String S3_STORAGE_LENS_SERVICE_PRINCIPAL = "storage-lens.s3.amazonaws.com";

	public static void main(String[] args) {
		try {
            AWSOrganizations organizationsClient = AWSOrganizationsClient.builder()
                .withCredentials(new ProfileCredentialsProvider())
                .withRegion(Regions.US_EAST_1)
                .build();

            organizationsClient.enableAWSServiceAccess(new EnableAWSServiceAccessRequest()
                .withServicePrincipal(S3_STORAGE_LENS_SERVICE_PRINCIPAL));
        } catch (AmazonServiceException e) {
            // The call was transmitted successfully, but AWS Organizations couldn't process
            // it and returned an error response.
            e.printStackTrace();
        } catch (SdkClientException e) {
            // AWS Organizations couldn't be contacted for a response, or the client
            // couldn't parse the response from AWS Organizations.
            e.printStackTrace();
        }
	}
}
```

# 停用 S3 Storage Lens 的受信任存取權
<a name="storage_lens_with_organizations_disabling_trusted_access"></a>

以委派的管理員身分移除帳戶或停用受信任存取，會限制帳戶擁有者的 S3 Storage Lens 儀表板指標只能在帳戶層級上運作。然後，每個帳戶持有人只能在其帳戶的有限範圍內 (而非整個組織) 看到 S3 Storage Lens 的好處。

當您在 S3 Storage Lens 中停用受信任存取時，任何需要受信任存取的儀表板都不會再更新。建立的任何組織儀表板也不會再更新。反之，您只能在 [S3 Storage Lens 儀表板的歷史資料](https://docs.aws.amazon.com/AmazonS3/latest/userguide/storage_lens_basics_metrics_recommendations.html#storage_lens_basics_data_queries)仍然可用時進行查詢。

**注意**  
停用 S3 Storage Lens 的受信任存取權也會使所有組織層級儀表板自動停止收集和彙總儲存空間指標。這是因為 S3 Storage Lens 無法再以信任方式存取組織帳戶。
您的管理和委派管理員帳戶仍然可以查看任何已停用儀表板的歷史資料，也可以在此歷史資料仍然可用時進行查詢。

# 使用 S3 主控台
<a name="storage_lens_console_organizations_disabling_trusted_access"></a>

**停用 S3 Storage Lens 的受信任存取權**

1. 登入 AWS 管理主控台 ，並在 [https://console.aws.amazon.com/s3/](https://console.aws.amazon.com/s3/)：// 開啟 Amazon S3 主控台。

1. 在左側導覽窗格上，導覽至 **Storage Lens**。

1. 選擇 **AWS Organizations 設定**。**Storage Lens 的AWS Organizations 存取**頁面隨即顯示。

1. 在 **AWS Organizations 受信任存取**下，選擇**編輯**。

   **AWS Organizations 存取**頁面隨即顯示。

1. 選擇**停用**以停用 S3 Storage Lens 儀表板的受信任存取。

1. 選擇**儲存變更**。

# 使用 AWS CLI
<a name="OrganizationsDisableTrustedAccessS3LensCLI"></a>

**Example**  
下列範例使用 AWS CLI停用 S3 Storage Lens 的受信任存取。  

```
aws organizations disable-aws-service-access --service-principal storage-lens.s3.amazonaws.com
```

# 使用適用於 Java 的 AWS 開發套件
<a name="OrganizationsDisableTrustedAccessS3LensJava"></a>

**Example – 停用 S3 Storage Lens 的 AWS Organizations 受信任存取**  
下列範例說明如何在適用於 Java 的 SDK 中停用 S3 Storage Lens 的 AWS Organizations 受信任存取。若要使用此範例，請以您自己的資訊取代 `user input placeholders`。  

```
import com.amazonaws.AmazonServiceException;
import com.amazonaws.SdkClientException;
import com.amazonaws.auth.profile.ProfileCredentialsProvider;
import com.amazonaws.regions.Regions;
import com.amazonaws.services.organizations.AWSOrganizations;
import com.amazonaws.services.organizations.AWSOrganizationsClient;
import com.amazonaws.services.organizations.model.DisableAWSServiceAccessRequest;

public class DisableOrganizationsTrustedAccess {
	private static final String S3_STORAGE_LENS_SERVICE_PRINCIPAL = "storage-lens.s3.amazonaws.com";

	public static void main(String[] args) {
		try {
            AWSOrganizations organizationsClient = AWSOrganizationsClient.builder()
                .withCredentials(new ProfileCredentialsProvider())
                .withRegion(Regions.US_EAST_1)
                .build();

            // Make sure to remove any existing delegated administrator for S3 Storage Lens 
            // before disabling access; otherwise, the request will fail.
            organizationsClient.disableAWSServiceAccess(new DisableAWSServiceAccessRequest()
                .withServicePrincipal(S3_STORAGE_LENS_SERVICE_PRINCIPAL));
        } catch (AmazonServiceException e) {
            // The call was transmitted successfully, but AWS Organizations couldn't process
            // it and returned an error response.
            e.printStackTrace();
        } catch (SdkClientException e) {
            // AWS Organizations couldn't be contacted for a response, or the client
            // couldn't parse the response from AWS Organizations.
            e.printStackTrace();
        }
	}
}
```

# 註冊 S3 Storage Lens 的委派管理員
<a name="storage_lens_with_organizations_registering_delegated_admins"></a>

您可以使用組織的管理帳戶或委派管理員帳戶，來建立組織層級儀表板。委派管理員帳戶允許管理帳戶以外的其他帳戶建立組織層級儀表板。僅組織的管理帳戶可以將其他帳戶註冊為組織的委派管理員，以及取消註冊委派管理員。

啟用受信任存取後，您可以使用 AWS Organizations REST API 或管理帳戶中SDKs AWS CLI來註冊組織中[帳戶的](https://docs.aws.amazon.com/managedservices/latest/userguide/management-account.html)委派管理員存取。(如需詳細資訊，請參閱AWS Organizations API 參考**中的[https://docs.aws.amazon.com/organizations/latest/APIReference/API_RegisterDelegatedAdministrator.html](https://docs.aws.amazon.com/organizations/latest/APIReference/API_RegisterDelegatedAdministrator.html))。當帳戶註冊為委派管理員時，帳戶會收到存取所有唯讀 AWS Organizations API 操作的授權。此授權會提供組織成員和結構的可見性，讓他們可以代表您建立 S3 Storage Lens 儀表板。

**注意**  
您必須先呼叫 [https://docs.aws.amazon.com/organizations/latest/APIReference/API_EnableAWSServiceAccess.html](https://docs.aws.amazon.com/organizations/latest/APIReference/API_EnableAWSServiceAccess.html)操作 AWS CLI，才能使用 AWS Organizations REST API 或 SDKs 指定委派管理員。

# 使用 S3 主控台
<a name="storage_lens_console_organizations_registering_delegated_admins"></a>

**註冊 S3 Storage Lens 的委派管理員**

1. 登入 AWS 管理主控台 並開啟位於 https：//[https://console.aws.amazon.com/s3/](https://console.aws.amazon.com/s3/) 的 Amazon S3 主控台。

1. 在左側導覽窗格上，導覽至 **Storage Lens**。

1.  選擇 **AWS Organizations 設定**。

1. 在**委派的管理員**下，選擇**註冊帳戶**。

1. 新增 AWS 帳戶 ID 以將帳戶註冊為委派管理員。委派的管理員能夠為組織中的所有帳戶和儲存體建立組織層級儀表板。

1. 選擇**註冊帳戶**。

# 使用 AWS CLI
<a name="OrganizationsRegisterDelegatedAdministratorS3LensCLI"></a>

**Example**  
下列範例示範如何使用 AWS CLI註冊 S3 Storage Lens 的 Organizations 委派管理員。若要使用此範例，請以您自己的資訊取代 `user input placeholders`。  

```
aws organizations register-delegated-administrator --service-principal storage-lens.s3.amazonaws.com --account-id 111122223333
```

# 使用適用於 Java 的 AWS 開發套件
<a name="OrganizationsRegisterDelegatedAdministratorS3LensJava"></a>

**Example – 註冊 S3 Storage Lens 的 Organizations 委派管理員**  
下列範例說明如何在適用於 Java 的 SDK 中註冊 S3 Storage Lens 的 AWS Organizations 委派管理員。若要使用此範例，請以您自己的資訊取代 `user input placeholders`。  

```
import com.amazonaws.AmazonServiceException;
import com.amazonaws.SdkClientException;
import com.amazonaws.auth.profile.ProfileCredentialsProvider;
import com.amazonaws.regions.Regions;
import com.amazonaws.services.organizations.AWSOrganizations;
import com.amazonaws.services.organizations.AWSOrganizationsClient;
import com.amazonaws.services.organizations.model.RegisterDelegatedAdministratorRequest;

public class RegisterOrganizationsDelegatedAdministrator {
	private static final String S3_STORAGE_LENS_SERVICE_PRINCIPAL = "storage-lens.s3.amazonaws.com";

	public static void main(String[] args) {
		try {
            String delegatedAdminAccountId = "111122223333"; // Account Id for the delegated administrator.
            AWSOrganizations organizationsClient = AWSOrganizationsClient.builder()
                .withCredentials(new ProfileCredentialsProvider())
                .withRegion(Regions.US_EAST_1)
                .build();

            organizationsClient.registerDelegatedAdministrator(new RegisterDelegatedAdministratorRequest()
                .withAccountId(delegatedAdminAccountId)
                .withServicePrincipal(S3_STORAGE_LENS_SERVICE_PRINCIPAL));
        } catch (AmazonServiceException e) {
            // The call was transmitted successfully, but AWS Organizations couldn't process
            // it and returned an error response.
            e.printStackTrace();
        } catch (SdkClientException e) {
            // AWS Organizations couldn't be contacted for a response, or the client
            // couldn't parse the response from AWS Organizations.
            e.printStackTrace();
        }
	}
}
```

# 取消註冊 S3 Storage Lens 的委派管理員
<a name="storage_lens_with_organizations_deregistering_delegated_admins"></a>

啟用受信任存取之後，您還可以註冊委派管理員，以便存取組織中的帳戶。委派的管理員帳戶允許您[管理帳戶](https://docs.aws.amazon.com/managedservices/latest/userguide/management-account.html)以外的其他帳戶建立組織層級儀表板。只有組織的管理帳戶可以透過組織委派管理員的身分取消註冊帳戶。

您可以使用 AWS Organizations AWS 管理主控台、REST API AWS CLI、 或 AWS SDKS 從管理帳戶取消註冊委派管理員。如需詳細資訊，請參閱 *AWS Organizations API 參考*中的 [https://docs.aws.amazon.com/organizations/latest/APIReference/API_DeregisterDelegatedAdministrator.html](https://docs.aws.amazon.com/organizations/latest/APIReference/API_DeregisterDelegatedAdministrator.html)。

當帳戶取消委派管理員註冊時，帳戶會失去對下列各項的存取權：
+ 提供組織成員和結構可見性的所有唯讀 AWS Organizations API 操作。
+ 委派管理員建立的所有組織層級儀表板。取消註冊委派管理員也會自動防止透過該委派管理員建立的所有組織層級儀表板彙總新的儲存指標。
**注意**  
已取消註冊的委派管理員帳戶仍然可以查看其所建立但已停用的儀表板歷史資料 (若該資料仍然可供查詢)。

# 使用 S3 主控台
<a name="storage_lens_console_organizations_deregistering_delegated_admins"></a>

**取消註冊 S3 Storage Lens 的委派管理員**

1. 登入 AWS 管理主控台 ，並在 https：//[https://console.aws.amazon.com/s3/](https://console.aws.amazon.com/s3/) 開啟 Amazon S3 主控台。

1. 在左側導覽窗格上，導覽至 **Storage Lens**。

1.  選擇 **AWS Organizations 設定**。

1. 在**委派的管理員**下，選擇您要取消註冊的帳戶。

1. 選擇**取消註冊帳戶**。已取消註冊的帳戶不再是委派的管理員，而且現在無法為組織中的所有帳戶和儲存體建立組織層級儀表板。

1. 選擇**註冊帳戶**。

# 使用 AWS CLI
<a name="OrganizationsDeregisterDelegatedAdministratorS3LensCLI"></a>

**Example**  
下列範例示範如何使用 AWS CLI取消註冊 S3 Storage Lens 的 Organizations 委派管理員。若要使用此範例，請以您自己的 AWS 帳戶 ID 取代 `111122223333`。  

```
aws organizations deregister-delegated-administrator --service-principal storage-lens.s3.amazonaws.com --account-id 111122223333
```

# 使用適用於 Java 的 AWS 開發套件
<a name="OrganizationsDeregisterDelegatedAdministratorS3LensJava"></a>

**Example – 取消註冊 S3 Storage Lens 的 Organizations 委派管理員**  
下列範例示範如何使用適用於 Java 的 SDK 取消註冊 S3 Storage Lens 的 Organizations 委派管理員。若要使用此範例，請以您自己的資訊取代 `user input placeholders`。  

```
import com.amazonaws.AmazonServiceException;
import com.amazonaws.SdkClientException;
import com.amazonaws.auth.profile.ProfileCredentialsProvider;
import com.amazonaws.regions.Regions;
import com.amazonaws.services.organizations.AWSOrganizations;
import com.amazonaws.services.organizations.AWSOrganizationsClient;
import com.amazonaws.services.organizations.model.DeregisterDelegatedAdministratorRequest;

public class DeregisterOrganizationsDelegatedAdministrator {
	private static final String S3_STORAGE_LENS_SERVICE_PRINCIPAL = "storage-lens.s3.amazonaws.com";

	public static void main(String[] args) {
		try {
            String delegatedAdminAccountId = "111122223333"; // Account Id for the delegated administrator.
            AWSOrganizations organizationsClient = AWSOrganizationsClient.builder()
                .withCredentials(new ProfileCredentialsProvider())
                .withRegion(Regions.US_EAST_1)
                .build();

            organizationsClient.deregisterDelegatedAdministrator(new DeregisterDelegatedAdministratorRequest()
                .withAccountId(delegatedAdminAccountId)
                .withServicePrincipal(S3_STORAGE_LENS_SERVICE_PRINCIPAL));
        } catch (AmazonServiceException e) {
            // The call was transmitted successfully, but AWS Organizations couldn't process
            // it and returned an error response.
            e.printStackTrace();
        } catch (SdkClientException e) {
            // AWS Organizations couldn't be contacted for a response, or the client
            // couldn't parse the response from AWS Organizations.
            e.printStackTrace();
        }
	}
}
```