

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

# 搭配 ACM 使用條件索引鍵
<a name="acm-conditions"></a>

AWS Certificate Manager 使用 AWS Identity and Access Management (IAM) [條件金鑰](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition.html)來限制對憑證請求的存取。藉由 IAM 政策或服務控制政策 (SCP) 中的條件索引鍵，您可以建立符合組織準則的憑證請求。

**注意**  
結合 ACM 條件金鑰與 AWS [全域條件金鑰](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html)，例如 `aws:PrincipalArn`，以進一步限制特定使用者或角色的動作。

## ACM 的支援條件
<a name="acm-conditions-supported"></a>

使用捲軸查看資料表的其餘部分。


**ACM API 作業與支援條件**  

| 條件索引鍵 | 支援的 ACM API 作業 | Type | 說明 | 
| --- | --- | --- | --- | 
|  `acm:ValidationMethod`  |  [RequestCertificate](https://docs.aws.amazon.com/acm/latest/APIReference/API_RequestCertificate.html)  |  字串 (`DNS`、`EMAIL`、`HTTP`)  |  根據 ACM [驗證方法](https://docs.aws.amazon.com/acm/latest/userguide/domain-ownership-validation.html)篩選請求  | 
|  `acm:DomainNames`  |  [RequestCertificate](https://docs.aws.amazon.com/acm/latest/APIReference/API_RequestCertificate.html)  |  ArrayOfString  |  根據 ACM 請求中的[網域名稱](https://docs.aws.amazon.com/acm/latest/userguide/acm-concepts.html#concept-dn)篩選  | 
|  `acm:KeyAlgorithm`  |  [RequestCertificate](https://docs.aws.amazon.com/acm/latest/APIReference/API_RequestCertificate.html)  |  String  |  根據 ACM [索引鍵演算法和大小](https://docs.aws.amazon.com/acm/latest/userguide/acm-certificate.html#algorithms)篩選請求  | 
|  `acm:CertificateTransparencyLogging`  |  [RequestCertificate](https://docs.aws.amazon.com/acm/latest/APIReference/API_RequestCertificate.html)  |  字串 (`ENABLED`、`DISABLED`)  |  根據 ACM [憑證透明度記錄偏好設定](https://docs.aws.amazon.com/acm/latest/userguide/acm-concepts.html#concept-transparency)篩選請求  | 
|  `acm:CertificateAuthority`  |  [RequestCertificate](https://docs.aws.amazon.com/acm/latest/APIReference/API_RequestCertificate.html)  |  ARN  |  根據 ACM 請求中的[憑證授權機構](https://docs.aws.amazon.com/acm/latest/userguide/acm-concepts.html#concept-ca)篩選請求  | 

## 範例 1：限制驗證方法
<a name="conditions-validation"></a>

除了使用 `arn:aws:iam::123456789012:role/AllowedEmailValidation` 角色發送的請求之外，以下政策會拒絕使用[電子郵件驗證](https://docs.aws.amazon.com/acm/latest/userguide/domain-ownership-validation.html)方法傳送的新憑證請求。

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement":{
        "Effect":"Deny",
        "Action":"acm:RequestCertificate",
        "Resource":"*",
        "Condition":{
            "StringLike" : {
                "acm:ValidationMethod":"EMAIL"
            },
            "ArnNotLike": {
                "aws:PrincipalArn": [ "arn:aws:iam::123456789012:role/AllowedEmailValidation"]
            }
        }
    }
}
```

------

## 範例 2：防範萬用字元網域
<a name="conditions-wildcards"></a>

以下政策會拒絕使用萬用字元網域的所有新 ACM 憑證請求。

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement":{
        "Effect":"Deny",
        "Action":"acm:RequestCertificate",
        "Resource":"*",
        "Condition": {
            "ForAnyValue:StringLike": {
                "acm:DomainNames": [
                    "${*}.*"
                ]
            }
        }
    }
}
```

------

## 範例 3：限制憑證網域
<a name="conditions-restrictdomains"></a>

以下政策會拒絕網域結尾不是 `*.amazonaws.com` 的所有新 ACM 憑證請求。

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement":{
        "Effect":"Deny",
        "Action":"acm:RequestCertificate",
        "Resource":"*",
        "Condition": {
            "ForAnyValue:StringNotLike": {
                "acm:DomainNames": ["*.amazonaws.com"]
            }
        }
    }
}
```

------

政策可以進一步限制為特定的子網域。此政策只會允許每個網域符合至少一個網域名稱條件的請求。

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement":{
        "Effect":"Deny",
        "Action":"acm:RequestCertificate",
        "Resource":"*",
        "Condition": {
            "ForAllValues:StringNotLike": {
                "acm:DomainNames": ["support.amazonaws.com", "developer.amazonaws.com"]
            }
        }
    }
}
```

------

## 範例 4：限制索引鍵演算法
<a name="conditions-keyalgorithm"></a>

以下政策使用條件索引鍵 `StringNotLike`，只允許使用 ECDSA 384 位元 (`EC_secp384r1`) 索引鍵演算法請求取得憑證。

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
        "Statement":{
        "Effect":"Deny",
        "Action":"acm:RequestCertificate",
        "Resource":"*",
        "Condition":{
            "StringNotLike" : {
                "acm:KeyAlgorithm":"EC_secp384r1"
            }
        }
    }
}
```

------

以下政策使用條件索引鍵 `StringLike` 和萬用字元 `*` 比對功能，防範 ACM 中出現使用任何 `RSA` 索引鍵演算法的新憑證請求。

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement":{
        "Effect":"Deny",
        "Action":"acm:RequestCertificate",
        "Resource":"*",
        "Condition":{
            "StringLike" : {
                "acm:KeyAlgorithm":"RSA*"
            }
        }
    }
}
```

------

## 範例 5：限制憑證授權機構
<a name="conditions-publicca"></a>

以下政策只允許使用所提供私有憑證授權機構 (PCA) ARN 的私有憑證請求。

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement":{
        "Effect":"Deny",
        "Action":"acm:RequestCertificate",
        "Resource":"*",
        "Condition":{
            "StringNotLike": {
                "acm:CertificateAuthority":" arn:aws:acm-pca:region:account:certificate-authority/CA_ID"
            }
        }
    }
}
```

------

此政策使用 `acm:CertificateAuthority` 條件：僅允許 Amazon 信任服務發出的公開信任憑證請求。將憑證授權機構 ARN 設定為 `false` 可防範來自 PCA 的私有憑證請求。

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

****  

```
{
"Version":"2012-10-17",		 	 	 
    "Statement":{
        "Effect":"Deny",
        "Action":"acm:RequestCertificate",
        "Resource":"*",
        "Condition":{
            "Null" : {
                "acm:CertificateAuthority":"false"
            }
        }
    }
}
```

------