設定以身分為基礎的政策範例 - AWS Systems Manager

• 2026 年 4 月 30 日之後, AWS Systems Manager CloudWatch Dashboard 將不再可用。客戶可以繼續使用 Amazon CloudWatch 主控台來檢視、建立和管理其 Amazon CloudWatch 儀表板,就像現在一樣。如需詳細資訊,請參閱 Amazon CloudWatch Dashboard 文件

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

設定以身分為基礎的政策範例

下列各節提供 AWS Systems Manager 自動化服務的範例 IAM 身分型政策。如需如何使用這些範例 JSON 政策文件建立 IAM 身分型政策的詳細資訊,請參閱《IAM 使用者指南》中的建立 IAM 政策

注意

所有範例都包含虛構的帳戶 IDs。不應在 Amazon Resource Name (ARN) 中為 AWS 擁有的公有文件指定帳戶 ID。

範例

範例 1:允許使用者執行自動化文件並檢視自動化執行

以下範例 IAM 政策允許使用者執行以下作業:

  • 執行政策中指定的自動化文件。文件的名稱取決於以下項目。

    arn:aws:ssm:*:111122223333:document/{{DocumentName}}
  • 停止並傳送訊號至自動化執行。

  • 檢視自動化執行啟動後的詳細資訊。

JSON
{ "Version":"2012-10-17", "Statement": [ { "Action": "ssm:StartAutomationExecution", "Effect": "Allow", "Resource": [ "arn:aws:ssm:*:111122223333:document/{{DocumentName}}", "arn:aws:ssm:*:111122223333:automation-execution/*" ] }, { "Action": [ "ssm:StopAutomationExecution", "ssm:GetAutomationExecution", "ssm:DescribeAutomationExecutions", "ssm:DescribeAutomationStepExecutions", "ssm:SendAutomationSignal" ], "Resource": [ "arn:aws:ssm:*:111122223333:automation-execution/*" ], "Effect": "Allow" } ] }

範例 2:允許使用者執行特定版本的自動化文件

下列範例 IAM 政策允許使用者執行特定版本的自動化文件:

  • 自動化文件的名稱由以下項目決定。

    arn:aws:ssm:*:111122223333:document/{{DocumentName}}
  • 自動化文件的版本由以下項目決定。

    "ssm:DocumentVersion": "5"
JSON
{ "Version":"2012-10-17", "Statement": [ { "Action": "ssm:StartAutomationExecution", "Effect": "Allow", "Resource": [ "arn:aws:ssm:*:111122223333:document/{{DocumentName}}" ], "Condition": { "ForAnyValue:StringEquals": { "ssm:DocumentVersion": ["5"] } } }, { "Action": [ "ssm:StartAutomationExecution" ], "Resource": [ "arn:aws:ssm:*:111122223333:automation-execution/*" ], "Effect": "Allow" }, { "Action": [ "ssm:StopAutomationExecution", "ssm:GetAutomationExecution", "ssm:DescribeAutomationExecutions", "ssm:DescribeAutomationStepExecutions", "ssm:SendAutomationSignal" ], "Resource": [ "arn:aws:ssm:*:111122223333:automation-execution/*" ], "Effect": "Allow" } ] }

範例 3:允許使用者執行具有特定標籤的自動化文件

下列範例 IAM 政策允許使用者執行具有特定標籤的任何自動化文件:

  • 自動化文件的名稱由以下項目決定。

    arn:aws:ssm:*:111122223333:document/{{DocumentName}}
  • 自動化文件的標籤由以下項目決定。

    "ssm:DocumentVersion": "5"
JSON
{ "Version":"2012-10-17", "Statement": [ { "Action": "ssm:StartAutomationExecution", "Effect": "Allow", "Resource": [ "arn:aws:ssm:*:111122223333:document/*" ], "Condition": { "StringEquals": { "aws:ResourceTag/stage": "production" } } }, { "Action": [ "ssm:StartAutomationExecution" ], "Resource": [ "arn:aws:ssm:*:111122223333:automation-execution/*" ], "Effect": "Allow" }, { "Action": [ "ssm:StopAutomationExecution", "ssm:GetAutomationExecution", "ssm:DescribeAutomationExecutions", "ssm:DescribeAutomationStepExecutions", "ssm:SendAutomationSignal" ], "Resource": [ "arn:aws:ssm:*:111122223333:automation-execution/*" ], "Effect": "Allow" } ] }

範例 4:提供自動化執行的特定標籤參數時,允許使用者執行自動化文件

以下範例 IAM 政策授予許可給使用者,在為自動化執行提供特定標籤參數時執行自動化文件:

  • 執行政策中指定的自動化文件。文件的名稱取決於以下項目。

    arn:aws:ssm:*:111122223333:document/{{DocumentName}}
  • 必須提供自動化執行的特定標籤參數。自動化執行資源的標籤參數由下列項目決定。

    "aws:ResourceTag/stage": "production"
  • 停止並傳送訊號至具有指定標籤的自動化執行。

  • 檢視具有指定標籤之自動化執行的詳細資訊。

  • 將指定的標籤新增至 SSM 資源。

JSON
{ "Version":"2012-10-17", "Statement": [ { "Action": "ssm:StartAutomationExecution", "Effect": "Allow", "Resource": [ "arn:aws:ssm:*:111122223333:document/{{DocumentName}}" ] }, { "Action": [ "ssm:StartAutomationExecution", "ssm:StopAutomationExecution", "ssm:GetAutomationExecution", "ssm:DescribeAutomationExecutions", "ssm:DescribeAutomationStepExecutions", "ssm:SendAutomationSignal" ], "Resource": [ "arn:aws:ssm:*:111122223333:automation-execution/*" ], "Effect": "Allow", "Condition": { "StringEquals": { "aws:ResourceTag/environment": "beta" } } }, { "Action": "ssm:AddTagsToResource", "Effect": "Allow", "Resource": [ "arn:aws:ssm:*:111122223333:automation-execution/*" ] } ] }