

# SEC03-BP08 安全地共用資源
<a name="sec_permissions_share_securely"></a>

 管控跨帳戶或 AWS Organizations 內共用資源的使用量。監控共用資源並審查共用資源的存取。 

 **常見的反模式：** 
+  在授予第三方跨帳戶存取權時使用預設 IAM 信任政策。 

 **若未建立此最佳實務，暴露的風險等級：** 低 

## 實作指引
<a name="implementation-guidance"></a>

 在使用多個 AWS 帳戶管理工作負載時，您可能需要在帳戶之間共用資源。這可能通常會是 AWS Organizations 中的跨帳戶共用。數種 AWS 服務，例如 [AWS Security Hub CSPM](https://docs.aws.amazon.com/organizations/latest/userguide/services-that-can-integrate-securityhub.html)、[Amazon GuardDuty](https://docs.aws.amazon.com/guardduty/latest/ug/guardduty_organizations.html)和 [AWS Backup](https://docs.aws.amazon.com/organizations/latest/userguide/services-that-can-integrate-backup.html) 都有與 Organizations 整合的跨帳戶功能。您可以使用 [AWS Resource Access Manager](https://aws.amazon.com/ram/) 來共用其他常見的資源，例如 [VPC 子網路或傳輸閘道連接](https://docs.aws.amazon.com/ram/latest/userguide/shareable.html#shareable-vpc)，[AWS Network Firewall](https://docs.aws.amazon.com/ram/latest/userguide/shareable.html#shareable-network-firewall)，或 [Amazon SageMaker Runtime 管道](https://docs.aws.amazon.com/ram/latest/userguide/shareable.html#shareable-sagemaker)。如果您想要確保帳戶的資源共用範圍僅限於 Organizations，我們建議使用 [服務控制政策 (SCP)](https://docs.aws.amazon.com/ram/latest/userguide/scp.html) 來避免對外部主體的存取。

 共用資源時，您應採取措施來防止意外的存取。我們建議結合以身分為基礎的控制項和網路控制項， [來為貴組織建立資料周邊](https://docs.aws.amazon.com/whitepapers/latest/building-a-data-perimeter-on-aws/building-a-data-perimeter-on-aws.html)。這些控制項應嚴格限制可以共用哪些資源，並防止共用或公開遭禁止的資源。例如，在資料周邊中，您可以使用 VPC 端點政策和 `aws:PrincipalOrgId` 條件，來確保 Amazon S3 儲存貯體的存取身分是貴組織的一員。

 在某些案例中，您可能想要允許共用 Organizations 外部的資源或授予第三方存取帳戶。例如，合作夥伴可能會提供監控解決方案，該解決方案需要存取您帳戶中的資源。在那些案例中，您應僅使用第三方需要的權限，來建立 IAM 跨帳戶角色。您也應使用外部 ID 條件 [來建立信任政策](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-user_externalid.html)。使用外部 ID 時，您應為每個第三方產生唯一的 ID。唯一 ID 的提供者或控制者不得是第三方。如果第三方不再需要存取您的環境，您應將角色移除。在所有案例中，您也應避免為第三方提供長期的 IAM 憑證。掌握對其他原生支援共用的 AWS 服務的狀態。例如，AWS Well-Architected Tool 允許 [在其他 AWS 帳戶中](https://docs.aws.amazon.com/wellarchitected/latest/userguide/workloads-sharing.html) 共用工作負載。

 使用 Amazon S3 之類的服務時，建議您 [停用 Amazon S3 儲存貯體的 ACL，](https://docs.aws.amazon.com/AmazonS3/latest/userguide/about-object-ownership.html) 並使用 IAM 政策來定義存取控制。[如需限制](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-restricting-access-to-s3.html) 從 [Amazon CloudFront](https://aws.amazon.com/cloudfront/)對 Amazon S3 原點的存取，請從原始存取身分 (OAI) 遷移至原始存取控制 (OAC)，後者支援額外的功能，包含使用下列項目的伺服器端加密功能： [AWS KMS](https://aws.amazon.com/kms/)。

## 資源
<a name="resources"></a>

 **相關文件：** 
+ [儲存貯體擁有者將跨帳戶許可授予非其擁有的物件](https://docs.aws.amazon.com/AmazonS3/latest/userguide/example-walkthroughs-managing-access-example4.html)
+ [如何使用信任政策搭配 IAM](https://aws.amazon.com/blogs/security/how-to-use-trust-policies-with-iam-roles/)
+ [在 AWS 上建置資料周邊](https://docs.aws.amazon.com/whitepapers/latest/building-a-data-perimeter-on-aws/building-a-data-perimeter-on-aws.html)
+ [向第三方授予對 AWS 資源的存取權限時如何使用外部 ID](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-user_externalid.html)

 **相關影片：** 
+ [使用 AWS Resource Access Manager 進行精密的存取](https://www.youtube.com/watch?v=X3HskbPqR2s)
+ [使用 VPC 端點確保資料周邊的安全](https://www.youtube.com/watch?v=iu0-o6hiPpI)
+ [ 在 AWS 上建立資料周邊 ](https://www.youtube.com/watch?v=SMi5OBjp1fI)