

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

# 在 Step Functions 中建立標籤型 IAM 政策
<a name="tag-based-policies"></a>

Step Functions 支援以標籤為基礎的政策。例如，您可以限制對所有 Step Functions 資源的存取，其中包含索引鍵為 `environment`且值為 的標籤`production`。

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Deny",
            "Action": [
                "states:TagResource",
                "states:UntagResource",
                "states:DeleteActivity",
                "states:DeleteStateMachine",
                "states:StopExecution"
            ],
            "Resource": "*",
            "Condition": {
                "StringEquals": {"aws:ResourceTag/environment": "production"}
            }
        }
    ]
}
```

此政策會 `Deny` 提供針對已標記為 `environment/production` 所有資源刪除狀態機器或活動、停止執行，以及新增或刪除新標籤的能力。

針對標籤型授權，狀態機器執行資源會繼承與狀態機器相關聯的標籤，如下列範例所示。

```
arn:{{partition}}:states:{{region}}:{{account-id}}:execution:{{<StateMachineName>:<ExecutionId>}}
```

當您呼叫 [DescribeExecution](https://docs.aws.amazon.com/step-functions/latest/apireference/API_DescribeExecution.html) 或指定執行資源 ARN 的其他 APIs 時，Step Functions 會使用與狀態機器相關聯的標籤，在執行標籤型授權時接受或拒絕請求。這可協助您允許或拒絕存取狀態機器層級的狀態機器執行。

如需標記的詳細資訊，請參閱以下內容：
+ [在 Step Functions 中標記狀態機器和活動](sfn-best-practices.md#concepts-tagging)
+ [使用 IAM 標籤控制存取](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_iam-tags.html)