

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

# 資源：當任何條件索引鍵符合字串時拒絕動作
<a name="iam-example-job-def-deny-any-image-logdriver"></a>

當 `batch:Image`（容器映像 ID) 條件金鑰為 "*string1*" 或 `batch:LogDriver`（容器日誌驅動程式） 條件金鑰為 "*string2*" 時，下列政策會拒絕存取 [https://docs.aws.amazon.com/batch/latest/APIReference/API_RegisterJobDefinition.html](https://docs.aws.amazon.com/batch/latest/APIReference/API_RegisterJobDefinition.html) API 操作。當任務跨越多個容器時，例如多節點平行任務，容器可能會有不同的組態。如果在一個陳述式中評估多個條件索引鍵，則會使用`AND`邏輯合併。因此，如果多個條件索引鍵中的任何一個不符合容器，則不會套用該容器`Deny`的效果。反之，同一任務中的不同容器可能會遭到拒絕。

如需 的條件金鑰清單 AWS Batch，請參閱*《服務授權參考*》中的 [的條件金鑰 AWS Batch](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsbatch.html#awsbatch-policy-keys)。除了 之外`batch:ShareIdentifier`，所有`batch`條件索引鍵都可以以此方式使用。(`batch:ShareIdentifier`條件索引鍵是為任務定義，而非任務定義。)

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

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "batch:RegisterJobDefinition"
      ],
      "Resource": [
        "*"
      ]
    },
    {
      "Effect": "Deny",
      "Action": [
        "batch:RegisterJobDefinition"
      ],
      "Resource": [
        "*"
      ],
      "Condition": {
        "StringEquals": {
          "batch:Image": [
            "string1"
          ]
        }
      }
    },
    {
      "Effect": "Deny",
      "Action": [
        "batch:RegisterJobDefinition"
      ],
      "Resource": [
        "*"
      ],
      "Condition": {
        "StringEquals": {
          "batch:LogDriver": [
            "string2"
          ]
        }
      }
    }
  ]
}
```

------