

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

# AWS Billing Conductor 如何使用 IAM
<a name="security_iam_service-with-iam"></a>

在您使用 IAM 管理 Billing Conductor 的存取權之前，您應該了解哪些 IAM 功能可與 Billing Conductor 搭配使用。若要全面了解 Billing Conductor 和其他 AWS 服務如何與 IAM 搭配使用，請參閱《IAM *使用者指南*》中的與 IAM [AWS 搭配使用的 服務](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_aws-services-that-work-with-iam.html)。

**Topics**
+ [Billing Conductor 身分型政策](#security_iam_service-with-iam-id-based-policies)
+ [Billing Conductor 資源型政策](#security_iam_service-with-iam-resource-based-policies)
+ [存取控制清單 (ACL)](#security_iam_service-with-iam-acls)
+ [以 Billing Conductor 標籤為基礎的授權](#security_iam_service-with-iam-tags)
+ [Billing Conductor IAM 角色](#security_iam_service-with-iam-roles)

## Billing Conductor 身分型政策
<a name="security_iam_service-with-iam-id-based-policies"></a>

使用 IAM 身分型政策，您可以指定允許或拒絕的動作和資源，以及在何種條件下允許或拒絕動作。Billing Conductor 支援特定動作、資源和條件索引鍵。若要了解您在 JSON 政策中使用的所有元素，請參閱 *IAM 使用者指南*中的 [JSON 政策元素參考](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements.html)。

### 動作
<a name="security_iam_service-with-iam-id-based-policies-actions"></a>

管理員可以使用 AWS JSON 政策來指定誰可以存取內容。也就是說，哪個**主體**在什麼**條件**下可以對什麼**資源**執行哪些**動作**。

JSON 政策的 `Action` 元素描述您可以用來允許或拒絕政策中存取的動作。政策會使用動作來授予執行相關聯動作的許可。

Billing Conductor 中的政策動作在動作之前使用下列字首：`Billing Conductor:`。例如，若要授予某人使用 Amazon EC2 `RunInstances` API 作業來執行 Amazon EC2 執行個體的許可，請在其政策中加入 `ec2:RunInstances` 動作。政策陳述式必須包含 `Action` 或 `NotAction` 元素。Billing Conductor 會定義自己的一組動作，描述您可以使用此服務執行的任務。

若要在單一陳述式中指定多個動作，請用逗號分隔，如下所示：

```
"Action": [
      "ec2:action1",
      "ec2:action2"
```

您也可以使用萬用字元 (\$1) 來指定多個動作。例如，若要指定開頭是 `Describe` 文字的所有動作，請包含以下動作：

```
"Action": "ec2:Describe*"
```



若要查看 Billing Conductor 動作清單，請參閱《*IAM 使用者指南*》中的 [AWS Billing Conductor 定義的動作](https://docs.aws.amazon.com/IAM/latest/UserGuide/list_awsbillingconductor.html#awsbillingconductor-actions-as-permissions)。

### Resources
<a name="security_iam_service-with-iam-id-based-policies-resources"></a>

管理員可以使用 AWS JSON 政策來指定誰可以存取內容。也就是說，哪個**主體**在什麼**條件**下可以對什麼**資源**執行哪些**動作**。

`Resource` JSON 政策元素可指定要套用動作的物件。最佳實務是使用其 [Amazon Resource Name (ARN)](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference-arns.html) 來指定資源。若動作不支援資源層級許可，使用萬用字元 (\$1) 表示該陳述式適用於所有資源。

```
"Resource": "*"
```



Amazon EC2 執行個體資源具有下列 ARN：

```
arn:${Partition}:ec2:${Region}:${Account}:instance/${InstanceId}
```

如需 ARNs 格式的詳細資訊，請參閱 [Amazon Resource Name (ARNs AWS 和服務命名空間](https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html)。

例如，若要在陳述式中指定 `i-1234567890abcdef0` 執行個體，請使用以下 ARN：

```
"Resource": "arn:aws:ec2:us-east-1:123456789012:instance/i-1234567890abcdef0"
```

若要指定屬於特定帳戶的所有執行個體，請使用萬用字元 (\$1)：

```
"Resource": "arn:aws:ec2:us-east-1:123456789012:instance/*"
```

有些 Billing Conductor 動作無法在特定資源上執行，例如用於建立資源的動作。在這些情況下，您必須使用萬用字元 (\$1)。

```
"Resource": "*"
```

許多 Amazon EC2 API 動作都涉及多個資源。例如，`AttachVolume` 會將 Amazon EBS 磁碟區連接至執行個體，所以 IAM 使用者必須具備該磁碟區與執行個體的使用許可。若要在單一陳述式中指定多項資源，請使用逗號分隔 ARN。

```
"Resource": [
      "resource1",
      "resource2"
```

若要查看 Billing Conductor 資源類型及其 ARNs 的清單，請參閱《*IAM 使用者指南*》中的 [AWS Billing Conductor 定義的資源](https://docs.aws.amazon.com/IAM/latest/UserGuide/list_awsbillingconductor.html#awsbillingconductor-resources-for-iam-policies)。若要了解您可以使用哪些動作指定每個資源的 ARN，請參閱 [AWS Billing Conductor 定義的動作](https://docs.aws.amazon.com/IAM/latest/UserGuide/list_awsbillingconductor.html#awsbillingconductor-actions-as-permissions)。

### 條件索引鍵
<a name="security_iam_service-with-iam-id-based-policies-conditionkeys"></a>

管理員可以使用 AWS JSON 政策來指定誰可以存取內容。也就是說，哪個**主體**在什麼**條件**下可以對什麼**資源**執行哪些**動作**。

`Condition` 元素會根據定義的條件，指定陳述式的執行時機。您可以建立使用[條件運算子](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html)的條件運算式 (例如等於或小於)，來比對政策中的條件和請求中的值。若要查看所有 AWS 全域條件索引鍵，請參閱《*IAM 使用者指南*》中的[AWS 全域條件內容索引鍵](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html)。

Billing Conductor 定義自己的一組條件索引鍵，也支援使用一些全域條件索引鍵。若要查看所有 AWS 全域條件金鑰，請參閱《*IAM 使用者指南*》中的[AWS 全域條件內容金鑰](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html)。



 所有 Amazon EC2 操作都支援 `aws:RequestedRegion` 和 `ec2:Region` 條件索引鍵。如需詳細資訊，請參閱[範例：將存取限制在特定區域](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ExamplePolicies_EC2.html#iam-example-region)。

若要查看 Billing Conductor 條件索引鍵的清單，請參閱《*IAM 使用者指南*》中的 [AWS Billing Conductor 的條件索引鍵](https://docs.aws.amazon.com/IAM/latest/UserGuide/list_awsbillingconductor.html#awsbillingconductor-policy-keys)。若要了解您可以使用條件金鑰的動作和資源，請參閱 [AWS Billing Conductor 定義的動作](https://docs.aws.amazon.com/IAM/latest/UserGuide/list_awsbillingconductor.html#awsbillingconductor-actions-as-permissions)。

### 範例
<a name="security_iam_service-with-iam-id-based-policies-examples"></a>



若要檢視 Billing Conductor 身分型政策的範例，請參閱 [AWS Billing Conductor 身分型政策範例](security_iam_id-based-policy-examples.md)。

## Billing Conductor 資源型政策
<a name="security_iam_service-with-iam-resource-based-policies"></a>

資源型政策是 JSON 政策文件，指定指定委託人可以在 Billing Conductor 資源上執行的動作，以及在哪些條件下執行的動作。Amazon S3 支援 Amazon S3 *儲存貯體*的資源型許可政策。資源型政策可讓您依資源將使用許可授予至其他帳戶。您也可以使用資源型政策，允許 AWS 服務存取您的 Amazon S3 *儲存貯體*。

若要啟用跨帳戶存取，您可以指定在其他帳戶內的所有帳戶或 IAM 實體，作為[資源型政策的委託人](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_principal.html)。新增跨帳戶主體至資源型政策，只是建立信任關係的一半。當委託人和資源位於不同的 AWS 帳戶中時，您還必須授予委託人實體存取資源的許可。透過將身分型政策連接到實體來授予許可。不過，如果資源型政策會為相同帳戶中的委託人授予存取，這時就不需要額外的身分型政策。如需詳細資訊，請參閱《*IAM 使用者指南*》中的 [IAM 角色與以資源為基礎的原則有何差異](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_compare-resource-policies.html)。

Amazon S3 服務僅支援一種資源型政策，稱為儲存**貯*體政策*，連接到儲存*貯體*。此政策定義哪些主體實體 （帳戶、使用者、角色和聯合身分使用者） 可以在 *Billing Conductor* 上執行動作。

### 範例
<a name="security_iam_service-with-iam-resource-based-policies-examples"></a>



若要檢視 Billing Conductor 資源型政策的範例，請參閱 [AWS Billing Conductor 資源型政策範例](security_iam_resource-based-policy-examples.md)，

## 存取控制清單 (ACL)
<a name="security_iam_service-with-iam-acls"></a>

存取控制清單 (ACLs) 是您可以附加資源的授權清單。他們授與帳戶和要附加這些政策的資源的存取許可。您可以將 ACLs 連接至 Amazon S3 儲存*貯體*資源。

透過 Amazon S3 存取控制清單 (ACLs存取。 **每個*儲存貯體*都會有一個與其連接的 ACL 作為子資源。它定義了哪些 AWS 帳戶、IAM 使用者或使用者群組，或 IAM 角色被授予存取和存取類型。收到資源的請求時， 會 AWS 檢查對應的 ACL，以確認請求者具有必要的存取許可。

當您建立儲存*貯*體資源時，Amazon S3 會建立預設 ACL，授予資源擁有者對資源的完整控制權。在下列範例*儲存貯體* ACL 中，John Doe 會列為*儲存貯體*的擁有者，並獲授與對該*儲存貯體*的完整控制。一個 ACL 最多可以有 100 個被授與者。

```
<?xml version="1.0" encoding="UTF-8"?>
<AccessControlPolicy xmlns="http://Billing Conductor.amazonaws.com/doc/2006-03-01/">
  <Owner>
    <ID>c1daexampleaaf850ea79cf0430f33d72579fd1611c97f7ded193374c0b163b6</ID>
    <DisplayName>john-doe</DisplayName>
  </Owner>
  <AccessControlList>
    <Grant>
      <Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
               xsi:type="Canonical User">
        <ID>c1daexampleaaf850ea79cf0430f33d72579fd1611c97f7ded193374c0b163b6</ID>
        <DisplayName>john-doe</DisplayName>
      </Grantee>
      <Permission>FULL_CONTROL</Permission>
    </Grant>
  </AccessControlList>
</AccessControlPolicy>
```

ACL 中的 ID 欄位是 AWS 帳戶正式使用者 ID。若要了解如何在您擁有的帳戶中檢視此 ID，請參閱[尋找 AWS 帳戶正式使用者 ID](https://docs.aws.amazon.com/general/latest/gr/acct-identifiers.html#FindingCanonicalId)。

## 以 Billing Conductor 標籤為基礎的授權
<a name="security_iam_service-with-iam-tags"></a>

您可以將標籤連接至 Billing Conductor 資源，或在請求中將標籤傳遞給 Billing Conductor。如需根據標籤控制存取，請使用 `Billing Conductor:ResourceTag/key-name`、`aws:RequestTag/key-name` 或 `aws:TagKeys` 條件索引鍵，在政策的[條件元素](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition.html)中，提供標籤資訊。

## Billing Conductor IAM 角色
<a name="security_iam_service-with-iam-roles"></a>

[IAM 角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html)是您 AWS 帳戶中具有特定許可的實體。

### 搭配 Billing Conductor 使用臨時登入資料
<a name="security_iam_service-with-iam-roles-tempcreds"></a>

您可以搭配聯合使用暫時憑證、擔任 IAM 角色，或是擔任跨帳戶角色。您可以透過呼叫 [AssumeRole](https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRole.html) 或 [GetFederationToken](https://docs.aws.amazon.com/STS/latest/APIReference/API_GetFederationToken.html) 等 AWS STS API 操作來取得臨時安全登入資料。

Billing Conductor 支援使用臨時登入資料。

### 服務連結角色
<a name="security_iam_service-with-iam-roles-service-linked"></a>

[服務連結角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_terms-and-concepts.html#iam-term-service-linked-role)可讓 AWS 服務存取其他服務中的資源，以代表您完成 動作。服務連結角色會顯示在您的 IAM 帳戶中，並由該服務所擁有。IAM 管理員可以檢視，但不能編輯服務連結角色的許可。

### 服務角色
<a name="security_iam_service-with-iam-roles-service"></a>

此功能可讓服務代表您擔任[服務角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_terms-and-concepts.html#iam-term-service-role)。此角色可讓服務存取其他服務中的資源，以代表您完成動作。服務角色會出現在您的 IAM 帳戶中，且由該帳戶所擁有。這表示 IAM 管理員可以變更此角色的許可。不過，這樣可能會破壞此服務的功能。

Billing Conductor 支援服務角色。

### 在 Billing Conductor 中選擇 IAM 角色
<a name="security_iam_service-with-iam-roles-choose"></a>

當您在 Billing Conductor 中建立資源時，您必須選擇角色，以允許 Billing Conductor 代表您存取 Amazon EC2。如果您先前已建立服務角色或服務連結角色，則 Billing Conductor 會為您提供可供選擇的角色清單。請務必選擇允許存取啟動和停止 Amazon EC2 執行個體的角色。