

• 2026 年 4 月 30 日之後， AWS Systems Manager CloudWatch Dashboard 將不再可用。客戶可以繼續使用 Amazon CloudWatch 主控台來檢視、建立和管理其 Amazon CloudWatch 儀表板，就像現在一樣。如需詳細資訊，請參閱 [Amazon CloudWatch Dashboard 文件](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Dashboards.html)。

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

# 使用 Systems Manager just-in-time存取
<a name="systems-manager-just-in-time-node-access-setting-up"></a>

使用 Systems Manager 設定即時節點存取需要多個步驟。首先，您需要選擇要設定即時節點存取的*目標*。目標由 AWS Organizations 組織單位 (OUs和 組成 AWS 區域。根據預設，系統會選取您在設定統一 Systems Manager 主控台時所選擇的相同目標，以進行just-in-time節點存取。您可以選擇為所有相同的目標或您在設定統一 Systems Manager 主控台時指定的目標子集設定just-in-time節點存取。不支援新增設定統一 Systems Manager 主控台時未選取的新目標。

然後，您需要建立*核准政策*，決定節點連線何時需要手動核准並自動得到核准。組織中的每個帳戶管理各自的核准政策。您也可以共用委派管理員帳戶的政策，以明確拒絕自動核准與特定節點的連線。

**注意**  
設定即時節點存取不會影響您為 Session Manager 設定的現有 IAM 政策或偏好設定。您必須從 IAM 政策中移除 `StartSession` API 動作的許可，確保當使用者嘗試連線至節點時，只會使用即時節點存取。設定即時節點存取後，建議您利用使用者和節點子集測試核准政策，以驗證政策是否如需要般運作，然後再移除 Session Manager 的許可。

**身分驗證支援**  
請注意下列有關即時節點存取所用身分驗證支援的詳細資訊：
+ 使用遠端桌面連線至 Windows Server 執行個體時，即時節點存取不支援單一登入身分驗證類型。
+ 僅支援 AWS Security Token Service (AWS STS) `AssumeRole`臨時安全登入資料。如需詳細資訊，請參閱*《IAM 使用者指南》*中的以下主題：
+ 
  + [IAM 中的臨時安全登入資料](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp.html)
  + [比較 AWS STS 登入資料](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_sts-comparison.html)
  + [請求暫時性安全憑證](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_request.html)

下列 IAM 政策概述了使用 Systems Manager 管理並允許使用者建立節點即時節點存取請求所需的許可。確認您擁有在 Systems Manager 中使用即時節點存取的所需許可後，您可以繼續設定程序。將每個*範例資源預留位置*取代為您自己的資訊。

## 用於啟用即時節點存取的 IAM 政策
<a name="just-in-time-administrator-policy"></a>

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "QuickSetupConfigurationManagers",
            "Effect": "Allow",
            "Action": [
                "ssm-quicksetup:CreateConfigurationManager",
                "ssm-quicksetup:DeleteConfigurationManager",
                "ssm-quicksetup:GetConfiguration",
                "ssm-quicksetup:GetConfigurationManager",
                "ssm-quicksetup:GetServiceSettings",
                "ssm-quicksetup:ListConfigurationManagers",
                "ssm-quicksetup:ListConfigurations",
                "ssm-quicksetup:ListQuickSetupTypes",
                "ssm-quicksetup:ListTagsForResource",
                "ssm-quicksetup:TagResource",
                "ssm-quicksetup:UntagResource",
                "ssm-quicksetup:UpdateConfigurationDefinition",
                "ssm-quicksetup:UpdateConfigurationManager",
                "ssm-quicksetup:UpdateServiceSettings"
            ],
            "Resource": "*"
        },
        {
            "Sid": "QuickSetupDeployments",
            "Effect": "Allow",
            "Action": [
                "cloudformation:DescribeStackSetOperation",
                "cloudformation:ListStacks",
                "cloudformation:DescribeStacks",
                "cloudformation:DescribeStackResources",
                "cloudformation:ListStackSetOperations",
                "cloudformation:ListStackInstances",
                "cloudformation:DescribeStackSet",
                "cloudformation:ListStackSets",
                "cloudformation:DescribeStackInstance",
                "cloudformation:DescribeOrganizationsAccess",
                "cloudformation:ActivateOrganizationsAccess",
                "cloudformation:GetTemplate",
                "cloudformation:ListStackSetOperationResults",
                "cloudformation:DescribeStackEvents",
                "cloudformation:UntagResource",
                "ssm:DescribeAutomationExecutions",
                "ssm:GetAutomationExecution",
                "ssm:ListAssociations",
                "ssm:DescribeAssociation",
                "ssm:GetDocument",
                "ssm:ListDocuments",
                "ssm:DescribeDocument",
                "ssm:GetOpsSummary",
                "organizations:DeregisterDelegatedAdministrator",
                "organizations:DescribeAccount",
                "organizations:DescribeOrganization",
                "organizations:ListDelegatedAdministrators",
                "organizations:ListRoots",
                "organizations:ListParents",
                "organizations:ListOrganizationalUnitsForParent",
                "organizations:DescribeOrganizationalUnit",
                "organizations:ListAWSServiceAccessForOrganization",
                "iam:ListRoles",
                "iam:ListRolePolicies",
                "iam:GetRole",
                "iam:CreatePolicy",
                "cloudformation:TagResource"
            ],
            "Resource": "*"
        },
        {
            "Effect": "Allow",
            "Action": [
                "cloudformation:RollbackStack",
                "cloudformation:CreateStack",
                "cloudformation:UpdateStack",
                "cloudformation:DeleteStack"
            ],
            "Resource": [
                "arn:aws:cloudformation:*:*:stack/StackSet-AWS-QuickSetup-JITNA*",
                "arn:aws:cloudformation:*:*:stack/AWS-QuickSetup-*",
                "arn:aws:cloudformation:*:*:type/resource/*",
                "arn:aws:cloudformation:*:*:stack/StackSet-SSMQuickSetup"
            ]
        },
        {
            "Sid": "StackSetOperations",
            "Effect": "Allow",
            "Action": [
                "cloudformation:CreateStackSet",
                "cloudformation:UpdateStackSet",
                "cloudformation:DeleteStackSet",
                "cloudformation:DeleteStackInstances",
                "cloudformation:CreateStackInstances",
                "cloudformation:StopStackSetOperation"
            ],
            "Resource": [
                "arn:aws:cloudformation:*:*:stackset/AWS-QuickSetup-JITNA*",
                "arn:aws:cloudformation:*:*:type/resource/*",
                "arn:aws:cloudformation:*:*:stackset-target/AWS-QuickSetup-JITNA*:*"
            ]
        },
        {
            "Sid": "IamRolesMgmt",
            "Effect": "Allow",
            "Action": [
                "iam:CreateRole",
                "iam:DeleteRole",
                "iam:GetRole",
                "iam:AttachRolePolicy",
                "iam:PutRolePolicy",
                "iam:DetachRolePolicy",
                "iam:GetRolePolicy",
                "iam:ListRolePolicies"
            ],
            "Resource": [
                "arn:aws:iam::*:role/AWS-QuickSetup-JITNA*",
                "arn:aws:iam::*:role/service-role/AWS-QuickSetup-JITNA*"
            ]
        },
        {
            "Sid": "IamPassRole",
            "Effect": "Allow",
            "Action": [
                "iam:PassRole"
            ],
            "Resource": [
                "arn:aws:iam::*:role/AWS-QuickSetup-JITNA*",
                "arn:aws:iam::*:role/service-role/AWS-QuickSetup-JITNA*"
            ],
            "Condition": {
                "StringEquals": {
                    "iam:PassedToService": [
                        "ssm.amazonaws.com",
                        "ssm-quicksetup.amazonaws.com",
                        "cloudformation.amazonaws.com"
                    ]
                }
            }
        },
        {
            "Sid": "SSMAutomationExecution",
            "Effect": "Allow",
            "Action": "ssm:StartAutomationExecution",
            "Resource": [
                "arn:aws:ssm:us-east-1:111122223333:document/AWS-EnableExplorer",
                "arn:aws:ssm:us-east-1:111122223333:automation-execution/*"
            ]
        },
        {
            "Sid": "SSMAssociationPermissions",
            "Effect": "Allow",
            "Action": [
                "ssm:DeleteAssociation",
                "ssm:CreateAssociation",
                "ssm:StartAssociationsOnce"
            ],
            "Resource": "arn:aws:ssm:us-east-1:111122223333:association/*"
        },
        {
            "Sid": "SSMResourceDataSync",
            "Effect": "Allow",
            "Action": [
                "ssm:CreateResourceDataSync",
                "ssm:UpdateResourceDataSync"
            ],
            "Resource": "arn:aws:ssm:us-east-1:111122223333:resource-data-sync/AWS-QuickSetup-*"
        },
        {
            "Sid": "ListResourceDataSync",
            "Effect": "Allow",
            "Action": [
                "ssm:ListResourceDataSync"
            ],
            "Resource": "*"
        },
        {
            "Sid": "CreateServiceLinkedRoles",
            "Effect": "Allow",
            "Action": [
                "iam:CreateServiceLinkedRole"
            ],
            "Condition": {
                "StringEquals": {
                    "iam:AWSServiceName": [
                        "accountdiscovery.ssm.amazonaws.com",
                        "ssm.amazonaws.com",
                        "ssm-quicksetup.amazonaws.com",
                        "stacksets.cloudformation.amazonaws.com"
                    ]
                }
            },
            "Resource": "*"
        },
        {
            "Sid": "CreateStackSetsServiceLinkedRole",
            "Effect": "Allow",
            "Action": [
                "iam:CreateServiceLinkedRole"
            ],
            "Resource": "arn:aws:iam::*:role/aws-service-role/stacksets.cloudformation.amazonaws.com/AWSServiceRoleForCloudFormationStackSetsOrgAdmin"
        },
        {
            "Sid": "AllowSsmJitnaPoliciesCrudOperations",
            "Effect": "Allow",
            "Action": [
                "ssm:CreateDocument",
                "ssm:UpdateDocument",
                "ssm:UpdateDocumentDefaultVersion",
                "ssm:GetDocument",
                "ssm:DescribeDocument",
                "ssm:DeleteDocument"
            ],
            "Resource": [
                "arn:aws:ssm:us-east-1:111122223333:document/SSM-JustInTimeAccessDenyAccessOrgPolicy"
            ],
            "Condition": {
                "StringEquals": {
                    "ssm:DocumentType": [
                        "AutoApprovalPolicy"
                    ]
                }
            }
        },
        {
            "Sid": "AllowAccessRequestOpsItemOperations",
            "Effect": "Allow",
            "Action": [
                "ssm:GetOpsItem",
                "ssm:DescribeOpsItems",
                "ssm:GetOpsSummary",
                "ssm:DeleteOpsItem",
                "ssm:ListOpsItemEvents"
            ],
            "Resource": "*"
        },
        {
            "Sid": "IdentityCenterPermissions",
            "Effect": "Allow",
            "Action": [
                "sso:DescribeRegisteredRegions",
                "sso:ListDirectoryAssociations",
                "identitystore:GetUserId",
                "identitystore:DescribeUser",
                "identitystore:DescribeGroup",
                "identitystore:ListGroupMembershipsForMember"
            ],
            "Resource": "*"
        }
    ]
}
```

------

## 用於設定即時節點存取的 IAM 政策
<a name="just-in-time-member-administrator-policy"></a>

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "AllowSsmJitnaPoliciesCrudOperations",
            "Effect": "Allow",
            "Action": [
                "ssm:CreateDocument",
                "ssm:UpdateDocument",
                "ssm:UpdateDocumentDefaultVersion",
                "ssm:GetDocument",
                "ssm:DescribeDocument",
                "ssm:DeleteDocument"
            ],
            "Resource": [
                "arn:aws:ssm:us-east-1:111122223333:document/*"
            ],
            "Condition": {
                "StringEquals": {
                    "ssm:DocumentType": [
                        "ManualApprovalPolicy",
                        "AutoApprovalPolicy"
                    ]
                }
            }
        },
        {
            "Sid": "AllowSsmJitnaPoliciesListOperations",
            "Effect": "Allow",
            "Action": [
                "ssm:ListDocuments",
                "ssm:ListDocumentVersions"
            ],
            "Resource": "*"
        },
        {
            "Effect": "Allow",
            "Action": "iam:PassRole",
            "Resource": "arn:aws:iam::111122223333:role/SSM-JustInTimeAccessTokenRole",
            "Condition": {
                "StringEquals": {
                    "iam:PassedToService": [
                        "justintimeaccess.ssm.amazonaws.com"
                    ]
                }
            }
        },
        {
            "Sid": "AllowAccessRequestOpsItemOperations",
            "Effect": "Allow",
            "Action": [
                "ssm:GetOpsItem",
                "ssm:DescribeOpsItems",
                "ssm:GetOpsSummary",
                "ssm:DeleteOpsItem",
                "ssm:ListOpsItemEvents"
            ],
            "Resource": "*"
        },
        {
            "Sid": "AllowSessionManagerPreferencesOperation",
            "Effect": "Allow",
            "Action": [
                "ssm:CreateDocument",
                "ssm:GetDocument",
                "ssm:DescribeDocument",
                "ssm:UpdateDocument",
                "ssm:DeleteDocument"
            ],
            "Resource": "arn:aws:ssm:us-east-1:111122223333:document/SSM-SessionManagerRunShell",
            "Condition": {
                "StringEquals": {
                    "ssm:DocumentType": "Session"
                }
            }
        },
        {
            "Sid": "AllowSessionManagerOperations",
            "Effect": "Allow",
            "Action": [
                "ssm:DescribeSessions",
                "ssm:GetConnectionStatus",
                "ssm:TerminateSession"
            ],
            "Resource": "*"
        },
        {
            "Sid": "AllowRDPConnectionRecordingOperations",
            "Effect": "Allow",
            "Action": [
                "ssm-guiconnect:UpdateConnectionRecordingPreferences",
                "ssm-guiconnect:GetConnectionRecordingPreferences",
                "ssm-guiconnect:DeleteConnectionRecordingPreferences"
            ],
            "Resource": "*"
        },
        {
            "Sid": "AllowRDPConnectionRecordingKmsOperation",
            "Effect": "Allow",
            "Action": [
                "kms:CreateGrant"
            ],
            "Resource": "arn:aws:kms:us-east-1:111122223333:key/*",
            "Condition": {
                "StringEquals": {
                    "aws:ResourceTag/SystemsManagerJustInTimeNodeAccessManaged": "true"
                },
                "StringLike": {
                    "kms:ViaService": "ssm-guiconnect.*.amazonaws.com"
                },
                "Bool": {
                    "aws:ViaAWSService": "true"
                }
            }
        },
        {
            "Sid": "AllowFleetManagerOperations",
            "Effect": "Allow",
            "Action": [
                "ssm-guiconnect:GetConnection",
                "ssm-guiconnect:ListConnections"
            ],
            "Resource": "*"
        },
        {
            "Sid": "SNSTopicManagement",
            "Effect": "Allow",
            "Action": [
                "sns:CreateTopic",
                "sns:SetTopicAttributes"
            ],
            "Resource": [
                "arn:aws:sns:us-east-1:111122223333:SSM-JITNA*"
            ]
        },
        {
            "Sid": "SNSListTopics",
            "Effect": "Allow",
            "Action": [
                "sns:ListTopics"
            ],
            "Resource": "*"
        },
        {
            "Sid": "EventBridgeRuleManagement",
            "Effect": "Allow",
            "Action": [
                "events:PutRule",
                "events:PutTargets"
            ],
            "Resource": [
                "arn:aws:events:us-east-1::rule/SSM-JITNA*"
            ]
        },
        {
            "Sid": "ChatbotSlackManagement",
            "Effect": "Allow",
            "Action": [
                "chatbot:CreateSlackChannelConfiguration",
                "chatbot:UpdateSlackChannelConfiguration",
                "chatbot:DescribeSlackChannelConfigurations",
                "chatbot:DescribeSlackWorkspaces",
                "chatbot:DeleteSlackChannelConfiguration",
                "chatbot:RedeemSlackOauthCode",
                "chatbot:DeleteSlackWorkspaceAuthorization",
                "chatbot:GetSlackOauthParameters"
            ],
            "Resource": "*"
        },
        {
            "Sid": "ChatbotTeamsManagement",
            "Effect": "Allow",
            "Action": [
                "chatbot:ListMicrosoftTeamsChannelConfigurations",
                "chatbot:CreateMicrosoftTeamsChannelConfiguration",
                "chatbot:UpdateMicrosoftTeamsChannelConfiguration",
                "chatbot:ListMicrosoftTeamsConfiguredTeams",
                "chatbot:DeleteMicrosoftTeamsChannelConfiguration",
                "chatbot:RedeemMicrosoftTeamsOauthCode",
                "chatbot:DeleteMicrosoftTeamsConfiguredTeam",
                "chatbot:GetMicrosoftTeamsOauthParameters",
                "chatbot:TagResource"
            ],
            "Resource": "*"
        },
        {
            "Sid": "SSMEmailSettings",
            "Effect": "Allow",
            "Action": [
                "ssm:UpdateServiceSetting",
                "ssm:GetServiceSetting"
            ],
            "Resource": [
                "arn:aws:ssm:us-east-1:111122223333:servicesetting/ssm/access-request/email-role-mapping",
                "arn:aws:ssm:us-east-1:111122223333:servicesetting/ssm/access-request/enabled-email-notifications"
            ]
        },
        {
            "Sid": "AllowViewingJitnaCloudWatchMetrics",
            "Effect": "Allow",
            "Action": [
                "cloudwatch:GetMetricData",
                "cloudwatch:GetMetricStatistics",
                "cloudwatch:ListMetrics"
            ],
            "Resource": "*",
            "Condition": {
                "StringEquals": {
                    "cloudwatch:namespace": "AWS/SSM/JustInTimeAccess"
                }
            }
        },
        {
            "Sid": "QuickSetupConfigurationManagers",
            "Effect": "Allow",
            "Action": [
                "ssm-quicksetup:ListConfigurationManagers",
                "ssm-quicksetup:ListConfigurations",
                "ssm-quicksetup:ListQuickSetupTypes",
                "ssm-quicksetup:GetConfiguration",
                "ssm-quicksetup:GetConfigurationManager"
            ],
            "Resource": "*"
        },
        {
            "Sid": "QuickSetupDeployments",
            "Effect": "Allow",
            "Action": [
                "cloudformation:ListStacks",
                "cloudformation:DescribeStacks",
                "organizations:DescribeOrganization",
                "organizations:ListDelegatedAdministrators"
            ],
            "Resource": "*"
        },
        {
            "Sid": "ManualPolicy",
            "Effect": "Allow",
            "Action": [
                "sso:DescribeRegisteredRegions",
                "ssm:GetServiceSetting",
                "iam:ListRoles"
            ],
            "Resource": "*"
        },
        {
            "Sid": "SessionPreference",
            "Effect": "Allow",
            "Action": [
                "s3:ListAllMyBuckets"
            ],
            "Resource": "*"
        },
        {
            "Sid": "AllowIamListForKMS",
            "Effect": "Allow",
            "Action": [
                "iam:ListUsers"
            ],
            "Resource": "arn:aws:iam::111122223333:user/*"
        },
        {
            "Sid": "KMSPermission",
            "Effect": "Allow",
            "Action": [
                "kms:TagResource",
                "kms:ListAliases",
                "kms:CreateAlias"
            ],
            "Resource": "*"
        },
        {
            "Sid": "KMSCreateKey",
            "Effect": "Allow",
            "Action": [
                "kms:CreateKey"
            ],
            "Resource": "*",
            "Condition": {
                "StringEquals": {
                    "aws:RequestTag/SystemsManagerJustInTimeNodeAccessManaged": "true"
                },
                "ForAllValues:StringEquals": {
                    "aws:TagKeys": [
                        "SystemsManagerJustInTimeNodeAccessManaged"
                    ]
                }
            }
        },
        {
            "Sid": "AllowIamRoleForChatbotAction",
            "Effect": "Allow",
            "Action": [
                "iam:PassRole"
            ],
            "Resource": "arn:aws:iam::111122223333:role/role name",
            "Condition": {
                "StringEquals": {
                    "iam:PassedToService": [
                        "chatbot.amazonaws.com"
                    ]
                }
            }
        },
        {
            "Sid": "AllowIamServiceRoleForChat",
            "Effect": "Allow",
            "Action": [
                "iam:CreateServiceLinkedRole"
            ],
            "Resource": "arn:aws:iam::111122223333:role/aws-service-role/management.chatbot.amazonaws.com/AWSServiceRoleForAWSChatbot"
        },
        {
            "Sid": "CloudWatchLogs",
            "Effect": "Allow",
            "Action": [
                "logs:DescribeLogGroups"
            ],
            "Resource": "arn:aws:logs:*:111122223333:log-group::log-stream:"
        },
        {
            "Sid": "IdentityStorePermissions",
            "Effect": "Allow",
            "Action": [
                "sso:ListDirectoryAssociations",
                "identitystore:GetUserId",
                "sso-directory:SearchUsers",
                "sso-directory:SearchGroups",
                "identitystore:DescribeGroup",
                "identitystore:DescribeUser"
            ],
            "Resource": "*"
        }
    ]
}
```

------

## 用於存取請求核准者的 IAM 政策
<a name="just-in-time-access-request-approver-policy"></a>

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "AllowAccessRequestDescriptions",
            "Effect": "Allow",
            "Action": [
                "ssm:DescribeOpsItems",
                "ssm:GetOpsSummary",
                "ssm:ListOpsItemEvents"
            ],
            "Resource": "*"
        },
        {
            "Sid": "AllowGetSpecificAccessRequest",
            "Effect": "Allow",
            "Action": [
                "ssm:GetOpsItem"
            ],
            "Resource": "arn:aws:ssm:us-east-1:111122223333:opsitem/*"
        },
        {
            "Sid": "AllowApprovalRejectionSignal",
            "Effect": "Allow",
            "Action": [
                "ssm:SendAutomationSignal"
            ],
            "Resource": "arn:aws:ssm:*:*:automation-execution/*",
            "Condition": {
                "StringEquals": {
                    "aws:ResourceTag/SystemsManagerJustInTimeNodeAccessManaged": "true"
                }
            }
        },
        {
            "Sid": "QuickSetupConfigurationManagers",
            "Effect": "Allow",
            "Action": [
                "ssm-quicksetup:ListConfigurationManagers",
                "ssm-quicksetup:ListConfigurations",
                "ssm-quicksetup:GetConfigurationManager",
                "ssm-quicksetup:ListQuickSetupTypes",
                "ssm-quicksetup:GetConfiguration"
            ],
            "Resource": "*"
        },
        {
            "Sid": "QuickSetupDeployments",
            "Effect": "Allow",
            "Action": [
                "cloudformation:ListStacks",
                "cloudformation:DescribeStacks",
                "organizations:DescribeOrganization",
                "organizations:ListDelegatedAdministrators"
            ],
            "Resource": "*"
        },
        {
            "Sid": "AllowSsmJitnaPoliciesCrudOperations",
            "Effect": "Allow",
            "Action": [
                "ssm:GetDocument",
                "ssm:DescribeDocument"
            ],
            "Resource": [
                "arn:aws:ssm:us-east-1:111122223333:document/*"
            ],
            "Condition": {
                "StringEquals": {
                    "ssm:DocumentType": [
                        "ManualApprovalPolicy",
                        "AutoApprovalPolicy"
                    ]
                }
            }
        },
        {
            "Sid": "AllowSsmJitnaPoliciesListOperations",
            "Effect": "Allow",
            "Action": [
                "ssm:ListDocuments",
                "ssm:ListDocumentVersions"
            ],
            "Resource": "*"
        },
        {
            "Sid": "IDCPermissions",
            "Effect": "Allow",
            "Action": [
                "sso:DescribeRegisteredRegions",
                "sso:ListDirectoryAssociations",
                "identitystore:GetUserId",
                "identitystore:DescribeUser",
                "identitystore:DescribeGroup",
                "identitystore:ListGroupMembershipsForMember"
            ],
            "Resource": "*"
        }
    ]
}
```

------

## 用於即時節點存取使用者的 IAM 政策
<a name="just-in-time-access-requester-policy"></a>

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "AllowJITNAOperations",
            "Effect": "Allow",
            "Action": [
                "ssm:StartAccessRequest",
                "ssm:GetAccessToken"
            ],
            "Resource": "*"
        },
        {
            "Sid": "AllowOpsItemCreationAndRetrieval",
            "Effect": "Allow",
            "Action": [
                "ssm:CreateOpsItem",
                "ssm:GetOpsItem"
            ],
            "Resource": "arn:aws:ssm:*:*:opsitem/*"
        },
        {
            "Sid": "AllowListAccessRequests",
            "Effect": "Allow",
            "Action": [
                "ssm:DescribeOpsItems",
                "ssm:GetOpsSummary",
                "ssm:ListOpsItemEvents",
                "ssm:DescribeSessions"
            ],
            "Resource": "*"
        },
        {
            "Sid": "RequestManualApprovals",
            "Action": "ssm:StartAutomationExecution",
            "Effect": "Allow",
            "Resource": "arn:aws:ssm:*:*:document/*",
            "Condition": {
                "StringEquals": {
                    "ssm:DocumentType": "ManualApprovalPolicy"
                }
            }
        },
        {
            "Sid": "StartManualApprovalsAutomationExecution",
            "Effect": "Allow",
            "Action": "ssm:StartAutomationExecution",
            "Resource": "arn:aws:ssm:*:*:automation-execution/*"
        },
        {
            "Sid": "CancelAccessRequestManualApproval",
            "Effect": "Allow",
            "Action": "ssm:StopAutomationExecution",
            "Resource": "arn:aws:ssm:*:*:automation-execution/*",
            "Condition": {
                "StringEquals": {
                    "aws:ResourceTag/SystemsManagerJustInTimeNodeAccessManaged": "true"
                }
            }
        },
        {
            "Sid": "DescribeEC2Instances",
            "Effect": "Allow",
            "Action": [
                "ec2:DescribeInstances",
                "ec2:DescribeTags",
                "ec2:GetPasswordData"
            ],
            "Resource": "*"
        },
        {
            "Sid": "AllowListSSMManagedNodesAndTags",
            "Effect": "Allow",
            "Action": [
                "ssm:DescribeInstanceInformation",
                "ssm:ListTagsForResource"
            ],
            "Resource": "*"
        },
        {
            "Sid": "QuickSetupConfigurationManagers",
            "Effect": "Allow",
            "Action": [
                "ssm-quicksetup:ListConfigurationManagers",
                "ssm-quicksetup:GetConfigurationManager",
                "ssm-quicksetup:ListConfigurations",
                "ssm-quicksetup:ListQuickSetupTypes",
                "ssm-quicksetup:GetConfiguration"
            ],
            "Resource": "*"
        },
        {
            "Sid": "AllowSessionManagerOperations",
            "Effect": "Allow",
            "Action": [
                "ssm:DescribeSessions",
                "ssm:GetConnectionStatus"
            ],
            "Resource": "*"
        },
        {
            "Sid": "AllowRDPOperations",
            "Effect": "Allow",
            "Action": [
                "ssm-guiconnect:ListConnections",
                "ssm:GetConnectionStatus"
            ],
            "Resource": "*"
        },
        {
            "Sid": "QuickSetupDeployments",
            "Effect": "Allow",
            "Action": [
                "cloudformation:ListStacks",
                "cloudformation:DescribeStacks",
                "organizations:DescribeOrganization",
                "organizations:ListDelegatedAdministrators"
            ],
            "Resource": "*"
        },
        {
            "Sid": "AllowSsmJitnaPoliciesReadOnly",
            "Effect": "Allow",
            "Action": [
                "ssm:GetDocument",
                "ssm:DescribeDocument"
            ],
            "Resource": [
                "arn:aws:ssm:*:111122223333:document/*"
            ],
            "Condition": {
                "StringEquals": {
                    "ssm:DocumentType": [
                        "ManualApprovalPolicy",
                        "AutoApprovalPolicy"
                    ]
                }
            }
        },
        {
            "Sid": "AllowSsmJitnaPoliciesListOperations",
            "Effect": "Allow",
            "Action": [
                "ssm:ListDocuments",
                "ssm:ListDocumentVersions"
            ],
            "Resource": "*"
        },
        {
            "Sid": "ExploreNodes",
            "Effect": "Allow",
            "Action": [
                "ssm:ListNodesSummary",
                "ssm:ListNodes",
                "ssm:DescribeInstanceProperties"
            ],
            "Resource": "*"
        },
        {
            "Sid": "IdentityStorePermissions",
            "Effect": "Allow",
            "Action": [
                "sso:DescribeRegisteredRegions",
                "sso:ListDirectoryAssociations",
                "identitystore:GetUserId",
                "identitystore:DescribeUser",
                "identitystore:DescribeGroup"
            ],
            "Resource": "*"
        }
    ]
}
```

------

**注意**  
若要限制對建立、更新或刪除核准政策的 API 操作的存取，針對 `AutoApprovalPolicy` 和 `ManualApprovalPolicy ` 文件類型，請使用 `ssm:DocumentType` 條件索引鍵。`StartAccessRequest` 和 `GetAccessToken` API 操作不支援下列全域內容索引鍵：  
`aws:SourceVpc`
`aws:SourceVpce`
`aws:VpcSourceIp`
`aws:UserAgent`
`aws:MultiFactorAuthPresent`

如需有關 Systems Manager 條件內容索引鍵的詳細資訊，請參閱 *Service Authorization Reference* 中的 [Condition keys for AWS Systems Manager](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awssystemsmanager.html#awssystemsmanager-policy-keys)。

下列程序說明如何完成即時節點存取的第一個設定步驟。

**設定即時節點存取**

1. 登入組織的 Systems Manager 委派管理員帳戶。

1. 在 https：//[https://console.aws.amazon.com/systems-manager/](https://console.aws.amazon.com/systems-manager/) 開啟 AWS Systems Manager 主控台。

1. 在導覽窗格中，選取**即時節點存取**。

1. 選取**啟用新版本**。

1. 選擇您要啟用即時節點存取的區域。依預設，系統會選取您在設定 Systems Manager 整合式主控台時所選擇的相同區域，用於即時節點存取。不支援選擇在設定 Systems Manager 整合式主控台時未選取的新區域。

1. 選取**啟用即時節點存取**。

啟用此功能後 30 天內使用即時節點存取無需付費。在 30 天的試用期之後，使用即時節點存取需要付費。如需詳細資訊，請參閱 [AWS Systems Manager 定價](https://aws.amazon.com/systems-manager/pricing/)。

# 為您的節點建立核准政策
<a name="systems-manager-just-in-time-node-access-approval-policies"></a>

核准政策定義使用者存取節點所需的核准。由於即時節點存取不需要透過 IAM 政策對節點提供長期許可，因此您必須建立核准政策，以允許對節點的存取權。如果節點沒有套用任何核准政策，使用者就無法請求存取該節點。

在即時節點存取中，有三種政策類型。這三種政策類型分別為*自動核准*、*拒絕存取*和*手動核准*。

**即時節點存取政策類型**
+ 自動核准政策定義使用者可以自動連線哪些節點。
+ 手動核准政策定義要存取您指定的節點而必須取得的手動核准數量和層級。
+ 拒絕存取政策明確防止自動核准對您指定節點的存取請求。

拒絕存取政策適用於 AWS Organizations 組織中的所有帳戶。例如，您可以明確拒絕自動核准 `Intern` 群組對 `Production` 鍵標記之節點的存取。自動核准和手動核准政策僅適用於建立它們 AWS 區域 的 AWS 帳戶 和 。組織中的每個成員帳戶負責管理自己的核准政策。核准政策的評估順序如下：

1. 拒絕存取

1. 自動核准

1. 手動

每個組織只能有一個拒絕存取政策，每個帳戶和區域只能有一個自動核准政策，但在一個帳戶中可以有數個手動核准政策。評估手動核准政策時，即時節點存取一律優先節點上套用的更具體的政策。手動核准政策的評估順序如下：

1. 標籤特定目標

1. 所有節點目標

例如，您有一個以 `Demo` 鍵標記的節點。在同一帳戶中，您有一個以所有節點為目標的手動核准政策，該政策需要一個層級的一個核准。您還有一個針對以 `Demo` 鍵標記的節點的手動核准政策，該政策需要兩個層級的兩個核准。Systems Manager 會將以 `Demo` 標籤為目標的政策套用至該節點，因為它比以所有節點為目標的政策更為具體。這可讓您為帳戶中的所有節點建立一般政策，確保使用者可以提交存取請求，同時讓您能夠視需要建立更精細的政策。

根據您的組織，可能有多個標籤套用至您的節點。在此案例中，如果多個手動核准政策套用至一個節點，存取請求會失敗。例如，節點同時標記了 `Production` 和 `Database` 鍵。在同一帳戶中，如果您有一個手動核准政策套用至以 `Production` 鍵標記的節點，以及另一個手動核准政策套用至以 `Database` 鍵標記的節點。這會導致以兩個鍵標記的節點發生衝突，造成存取請求失敗。Systems Manager 會將使用者重新導向至失敗的請求。在失敗請求中，使用者可以檢視有關衝突政策和標籤的詳細資訊，以便在他們進行必要的調整 (如果他們擁有所需許可)。如果他們沒有所需許可，他們可以通知組織中具有修改政策所需許可的同事。導致存取請求失敗的政策衝突會發出 EventBridge 事件，以便您靈活地建置自己的回應工作流程。此外，Systems Manager 會將政策衝突導致存取請求失敗的通知透過電子郵件傳送給您指定的收件人。如需有關設定政策衝突電子郵件通知的詳細資訊，請參閱[設定即時存取請求的通知](systems-manager-just-in-time-node-access-notifications.md)。

在*拒絕存取*政策中，您可以使用 Cedar 政策語言來定義使用者明確無法自動連線到組織中哪些節點。此政策是從組織的委派管理員帳戶建立和共用。拒絕存取政策會取代所有自動核准政策。每個組織只能有一個拒絕存取政策。

在*自動核准*政策中，您可以使用 Cedar 政策語言來定義哪些使用者可以自動連線到指定的節點，而無需手動核准。自動核准的存取請求的存取持續時間為 1 小時。此值無法變更。每個帳戶和區域只能有一個自動核准政策。

在*手動*核准政策中，您可以指定存取持續時間、需要多少層級的核准、每個層級所需的核准者數目，以及他們可以核准即時存取請求的節點。手動核准政策的存取持續時間必須介於 1 到 336 小時之間。如果您指定多個層級的核准，則存取請求的核准程序一次處理一個層級。這表示您必須先提供某個層級所需的所有核准，核准程序才會繼續到下一層級。如果您在手動核准政策中指定多個標籤，系統會將其評估為 `or` 陳述式而非 `and` 陳述式。例如，如果您建立包含標籤 `Application`、`Web` 和 `Test` 的手動核准政策，該政策會套用至任何以其中一個鍵標記的節點。該政策不只是適用於以全部三個鍵標記的節點。

建議您使用手動核准政策與自動核准政策的組合，來協助您保護具有更關鍵資料的節點，同時無需介入便能允許使用者連線至較不關鍵的節點。例如，您可以要求手動核准對資料庫節點的存取請求，自動核准對非持久性表示層節點的存取工作階段。

下列程序說明如何建立即時節點存取的核准政策。

**Topics**
+ [建立即時節點存取的手動核准政策](systems-manager-just-in-time-node-access-create-manual-policies.md)
+ [自動核准和拒絕存取政策的陳述式結構和內建運算子](auto-approval-deny-access-policy-statement-structure.md)
+ [建立just-in-time節點存取的自動核准政策](systems-manager-just-in-time-node-access-create-auto-approval-policies.md)
+ [建立拒絕存取政策以just-in-time存取節點](systems-manager-just-in-time-node-access-create-deny-access-policies.md)
+ [使用 Amazon Q 建立即時節點存取的核准政策](systems-manager-just-in-time-node-access-create-approval-policies-q-ide-cli.md)

# 建立即時節點存取的手動核准政策
<a name="systems-manager-just-in-time-node-access-create-manual-policies"></a>

下列程序說明如何建立手動核准政策。Systems Manager 可讓您為每個 AWS 帳戶 和 建立最多 50 個手動核准政策 AWS 區域。

**建立手動核准政策**

1. 在 https：//[https://console.aws.amazon.com/systems-manager/](https://console.aws.amazon.com/systems-manager/) 開啟 AWS Systems Manager 主控台。

1. 在導覽窗格中，選取**管理節點存取**。

1. 在**建立手動核准政策**步驟的**政策詳細資訊**區段中，輸入核准政策的名稱和描述。

1. 輸入**存取持續時間**的值。這是核准存取請求後，使用者對節點啟動的工作階段持續時間上限。該值必須介於 1 到 336 小時之間。

1. 在**節點目標**區段中，輸入與您希望政策套用的節點相關聯的標籤鍵值對。如果政策中指定的標籤都未與節點相關聯，則該政策不會套用至節點。

1. 在**存取請求核准者**區段中，輸入您要讓其核准對政策中節點目標的存取請求的使用者或群組。存取請求核准者可以是 IAM Identity Center 使用者和群組或 IAM 角色。每個層級最多可以指定 5 個核准者，以及最多指定 5 個核准者層級。

1. 選取**建立手動核准政策**。

# 自動核准和拒絕存取政策的陳述式結構和內建運算子
<a name="auto-approval-deny-access-policy-statement-structure"></a>

下表顯示自動核准與拒絕存取政策的結構。


| 元件 | 語法 | 
| --- | --- | 
| 效用 |  `permit \| forbid`  | 
| scope |  `(principal, action, resource)`  | 
| 條件子句 |  <pre>when {<br />    principal or resource has attribute name             <br />};</pre>  | 

## 政策元件
<a name="policy-components"></a>

自動核准或拒絕存取政策包含下列元件：
+ **效果** – `permit` (允許) 或 `forbid` (拒絕) 存取。
+ **範圍** – 套用效果的主體、動作和資源。您可以不識別特定主體、動作或資源，讓 Cedar 中的範圍保持未定義的狀態。在此情況下，政策適用於所有可能的主體、動作和資源。對於即時節點存取，`action` 一律為 `AWS::SSM::Action::"getTokenForInstanceAccess"`。
+ **條件子句** – 套用效果的內容。

## 說明
<a name="auth-policies-policy-comments"></a>

您可以在政策中包含註解。註解定義為以 `//` 開頭和以換行符號字元結尾的行。

以下範例顯示政策中的註解。

```
// Allows users in the Engineering group from the Platform org to automatically connect to nodes tagged with Engineering and Production keys. 
permit (
    principal in AWS::IdentityStore::Group::"d4q81745-r081-7079-d789-14da1EXAMPLE",
    action == AWS::SSM::Action::"getTokenForInstanceAccess",
    resource
)
when {
    principal has organization && resource.hasTag("Engineering") && resource.hasTag("Production") && principal.organization == "Platform"
};
```

## 多個子句
<a name="multiple-clauses"></a>

您可以使用 `&&` 運算子，在政策陳述式中使用多個條件子句。

```
// Allow access if node has tag where the tag key is Environment 
// & tag value is Development 

permit(principal, action == AWS::SSM::getTokenForInstanceAccess, resource)
when {
    resource.hasTag("Environment") &&
    resource.getTag("Environment") == "Development"
};
```

## 保留字元
<a name="reserved-characters"></a>

下列範例顯示如何在內容屬性使用 `:` (分號) (這是政策語言中的保留字元) 時寫入政策。

```
permit (
    principal,
    action == AWS::SSM::Action::"getTokenForInstanceAccess",
    resource
)
when {
    principal has employeeNumber && principal.employeeNumber like "E-1*" && resource.hasTag("Purpose") && resource.getTag("Purpose") == "Testing"
}
```

如需額外的範例，請參閱[政策陳述式範例](#policy-statement-examples)。

## 即時節點存取結構描述
<a name="auto-approval-deny-access-policy-statement-schema"></a>

以下是即時節點存取的 Cedar 結構描述。

```
namespace AWS::EC2 {
    entity Instance tags String;
}


namespace AWS::IdentityStore {
    entity Group;
    
    entity User in [Group] {
    employeeNumber?: String,
    costCenter?: String,
    organization?: String,
    division?: String,
    };

}


namespace AWS::IAM {

    entity Role;
    
    type AuthorizationContext = {
        principalTags: PrincipalTags,
    };
    
    entity PrincipalTags tags String;
}

namespace AWS::SSM {

    entity ManagedInstance tags String;

    action "getTokenForInstanceAccess" appliesTo {
    principal: [AWS::IdentityStore::User],
    resource: [AWS::EC2::Instance, AWS::SSM::ManagedInstance],
    context: {
        "iam": AWS::IAM::AuthorizationContext
        }
    };
}
```

## 內建運算子
<a name="built-in-policy-operators"></a>

使用各種條件建立自動核准或拒絕存取政策的內容時，您可以使用 `&&` 運算子新增其他條件。您也可以使用許多其他內建運算子，為您的政策條件新增額外的表述能力。下表包含所有內建運算子，以供參考。

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/systems-manager/latest/userguide/auto-approval-deny-access-policy-statement-structure.html)

## 政策陳述式範例
<a name="policy-statement-examples"></a>

以下是政策陳述式範例。

```
// Users assuming IAM roles with a principal tag of "Elevated" can automatically access nodes tagged with the "Environment" key when the value equals "prod"
permit(principal, action == AWS::SSM::getTokenForInstanceAccess, resource)
when {
    // Verify IAM role principal tag
    context.iam.principalTags.getTag("AccessLevel") == "Elevated" &&
    
    // Verify the node has a tag with "Environment" tag key and a tag value of "prod"
    resource.hasTag("Environment") &&
    resource.getTag("Environment") == "prod"
};
```

```
// Identity Center users in the "Contractor" division can automatically access nodes tagged with the "Environment" key when the value equals "dev"
permit(principal, action == AWS::SSM::getTokenForInstanceAccess, resource)
when {
    // Verify that the user is part of the "Contractor" division
    principal.division == "Contractor" &&
    
    // Verify the node has a tag with "Environment" tag key and a tag value of "dev"
    resource.hasTag("Environment") &&
    resource.getTag("Environment") == "dev"
};
```

```
// Identity Center users in a specified group can automatically access nodes tagged with the "Environment" key when the value equals "Production"
permit(principal in AWS::IdentityStore::Group::"d4q81745-r081-7079-d789-14da1EXAMPLE",
    action == AWS::SSM::getTokenForInstanceAccess,
    resource)
when {
    resource.hasTag("Environment") &&
    resource.getTag("Environment") == "Production"
};
```

# 建立just-in-time節點存取的自動核准政策
<a name="systems-manager-just-in-time-node-access-create-auto-approval-policies"></a>

自動核准政策使用 Cedar 政策語言來定義哪些使用者可以在沒有手動核准的情況下，自動連線至指定節點。自動核准政策包含多個指定 `principal` 和 `resource` 的 `permit` 陳述式。每個陳述式都包含一個定義自動核准條件的 `when` 子句。

自動核准政策範例如下所示：

```
permit (
    principal in AWS::IdentityStore::Group::"e8c17310-e011-7089-d989-10da1EXAMPLE",
    action == AWS::SSM::Action::"getTokenForInstanceAccess",
    resource
)
when {
    principal has costCenter && resource.hasTag("CostCenter") && principal.costCenter == resource.getTag("CostCenter")
};

permit (
    principal in AWS::IdentityStore::Group::"d4q81745-r081-7079-d789-14da1EXAMPLE",
    action == AWS::SSM::Action::"getTokenForInstanceAccess",
    resource
)
when {
    principal has organization && resource.hasTag("Engineering") && resource.hasTag("Production") && principal.organization == "Platform"
};

permit (
    principal,
    action == AWS::SSM::Action::"getTokenForInstanceAccess",
    resource
)
when {
    principal has employeeNumber && principal.employeeNumber like "E-1*" && resource.hasTag("Purpose") && resource.getTag("Purpose") == "Testing"
};
```

下列程序說明如何為即時節點存取建立自動核准政策。自動核准的存取請求的存取持續時間為 1 小時。此值無法變更。每個 AWS 帳戶 和 只能有一個自動核准政策 AWS 區域。如需有關如何建構政策陳述式的詳細資訊，請參閱[自動核准和拒絕存取政策的陳述式結構和內建運算子](auto-approval-deny-access-policy-statement-structure.md)。

**建立自動核准政策**

1. 在 https：//[https://console.aws.amazon.com/systems-manager/](https://console.aws.amazon.com/systems-manager/) 開啟 AWS Systems Manager 主控台。

1. 在導覽窗格中，選取**管理節點存取**。

1. 在**核准政策**索引標籤中，選取**建立自動核准政策**。

1. 在**政策陳述式**區段中輸入自動核准政策的政策陳述式。您可以使用提供的**範例陳述式**來協助您建立政策。

1. 選取**建立自動核准政策**。

# 建立拒絕存取政策以just-in-time存取節點
<a name="systems-manager-just-in-time-node-access-create-deny-access-policies"></a>

拒絕存取政策使用 Cedar 政策語言來定義使用者在沒有手動核准的情況下無法自動連線哪些節點。拒絕存取政策包含多個指定 `principal` 和 `resource` 的 `forbid` 陳述式。每個陳述式都包含一個定義明確拒絕自動核准之條件的 `when` 子句。

拒絕存取政策範例如下所示：

```
forbid (
    principal in AWS::IdentityStore::Group::"e8c17310-e011-7089-d989-10da1EXAMPLE",
    action == AWS::SSM::Action::"getTokenForInstanceAccess",
    resource
)
when {
    resource.hasTag("Environment") && resource.getTag("Environment") == "Production"
};

forbid (
    principal,
    action == AWS::SSM::Action::"getTokenForInstanceAccess",
    resource
)
when {
    principal has division && principal.division != "Finance" && resource.hasTag("DataClassification") && resource.getTag("DataClassification") == "Financial"
};


forbid (
    principal,
    action == AWS::SSM::Action::"getTokenForInstanceAccess",
    resource
)
when {
    
    principal has employeeNumber && principal.employeeNumber like "TEMP-*" && resource.hasTag("Criticality") && resource.getTag("Criticality") == "High"
};
```

下列程序說明如何為即時節點存取建立拒絕存取政策。如需有關如何建構政策陳述式的詳細資訊，請參閱[自動核准和拒絕存取政策的陳述式結構和內建運算子](auto-approval-deny-access-policy-statement-structure.md)。

**注意**  
記下以下資訊。  
您可以在登入 AWS 管理帳戶或委派管理員帳戶後建立拒絕存取政策。您的 AWS Organizations 組織只能有一個拒絕存取政策。
Just-in-time節點存取使用 AWS Resource Access Manager (AWS RAM) 與組織中的成員帳戶共用拒絕存取政策。如果您想要與組織中的成員帳戶共用拒絕存取政策，則必須在組織的管理帳戶中啟用資源共用。如需詳細資訊，請參閱*《AWS RAM 使用者指南》*中的[透過 AWS Organizations啟用共用](https://docs.aws.amazon.com/ram/latest/userguide/getting-started-sharing.html#getting-started-sharing-orgs)。

**建立拒絕存取政策**

1. 在 https：//[https://console.aws.amazon.com/systems-manager/](https://console.aws.amazon.com/systems-manager/) 開啟 AWS Systems Manager 主控台。

1. 在導覽窗格中，選取**管理節點存取**。

1. 在**核准政策**索引標籤中，選取**建立拒絕存取政策**。

1. 在**政策陳述式**區段中輸入拒絕存取政策的政策陳述式。您可以使用提供的**範例陳述**式來協助您建立政策。

1. 選取**建立拒絕存取政策**。

# 使用 Amazon Q 建立即時節點存取的核准政策
<a name="systems-manager-just-in-time-node-access-create-approval-policies-q-ide-cli"></a>

在命令列中使用 Amazon Q Developer，可在軟體開發的各個層面提供指導和支援。對於即時節點存取，Amazon Q 可產生和更新政策的程式碼、分析政策陳述式等，協助您建立核准政策。以下資訊說明如何使用適用於命令列的 Amazon Q 來建立核准政策。

## 識別您的使用案例
<a name="identify-use-case"></a>

建立核准政策的第一步是清楚定義您的使用案例。例如，在您的組織中，您可能想要自動核准對具有 `Environment:Testing` 標籤之節點的存取請求。您可能也想要明確拒絕自動核准以 `TEMP` 開頭的員工 ID 對具有 `Environment:Production` 標籤之節點的存取請求。對於具有 `Tier:Database` 標籤的節點，您可能想要設定兩個層級的手動核准。

在任何特定案例中，您可能會偏好某個政策或條件。因此，建議您明確定義政策行為，以便決定哪些陳述式最適合您的使用案例，同時還要明確定義偏好設定。

## 設定開發環境
<a name="set-up-environment"></a>

在要開發核准政策的位置安裝適用於命令列的 Amazon Q。如需有關安裝適用於命令列的 Amazon Q 的資訊，請參閱 *Amazon Q Developer User Guide* 中的 [Installing Amazon Q for command line](https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/command-line-installing.html)。

我們也建議您為 AWS 文件安裝 MCP 伺服器。此 MCP 伺服器會將適用於命令列的 Amazon Q 連線至最新的文件資源。如需有關將 MCP 與適用於命令列的 Amazon Q 搭配使用的資訊，請參閱 *Amazon Q Developer User Guide* 中的 [Using MCP with Amazon Q Developer](https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/command-line-mcp.html)。

如需 AWS 文件 MCP 伺服器的詳細資訊，請參閱 [AWS 文件 MCP 伺服器](https://awslabs.github.io/mcp/servers/aws-documentation-mcp-server/)。

如果您尚未安裝和設定 AWS CLI。有關資訊，請參閱 [Installing or updating the latest version of the AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)。

## 開發核准政策內容
<a name="develop-content"></a>

識別使用案例並設定環境後，即可準備開發政策適用的內容。您的使用案例和偏好設定將主要決定您使用的核准政策和陳述式類型。

如果您不確定如何使用特定政策，或需要有關政策結構描述的詳細資訊，請參閱[為您的節點建立核准政策](systems-manager-just-in-time-node-access-approval-policies.md)和後續主題。這些主題詳細說明如何評估政策，並提供有效的範例陳述式。

下列程序說明如何使用適用於命令列的 Amazon Q 建立核准政策。

**注意**  
Amazon Q Developer 使用生成式 AI。您可能需要驗證回應內容。請參閱[AWS 負責任的 AI 政策](https://aws.amazon.com/ai/responsible-ai/policy/)。

**使用適用於命令列的 Amazon Q 建立核准政策**

1. 開啟終端並使用 Amazon Q 啟動工作階段。

   ```
   $ q chat
   ```

1. 輸入提示並描述您要建立的政策陳述式類型。例如，如果使用先前的核准政策案例，您可以輸入下列提示：

   ```
   Create a Cedar policy statement that allows a principal to use the “getTokenForInstanceAccess" action for a resource 
   that has a tag key “Environment” and tag value of “Testing”. Use the following example statement for reference to verify the syntax.
   
   permit (
       principal in AWS::IdentityStore::Group::"e8c17310-e011-7089-d989-10da1EXAMPLE",
       action == AWS::SSM::Action::"getTokenForInstanceAccess",
       resource
   )
   when {
       principal has organization && resource.hasTag("Engineering") && resource.hasTag("Production") && principal.organization == "Platform"
   };
   
   The Cedar policy statement you create must be valid. Validate the Cedar statement using the AWS documentation provided for just-in-time node access policy statement structure and make sure you abide by the schema.
   ```

1. 輸入此範例提示會產生下列輸出：

   ```
   Based on the AWS documentation for Cedar policy statements and the examples provided, I'll create a valid Cedar policy 
   statement that allows a principal to use the "getTokenForInstanceAccess" action for resources with the tag key "Environment" and tag value "Testing".
                               
   Here's the Cedar policy statement:
   
   permit (
       principal,
       action == AWS::SSM::Action::"getTokenForInstanceAccess",
       resource
   )
   when {
       resource.hasTag("Environment") &&
       resource.getTag("Environment") == "Testing"
   };
   
   
   This policy statement:
   1. Uses the permit effect to allow access
   2. Applies to any principal (since no specific principal is defined)
   3. Specifically targets the "getTokenForInstanceAccess" action
   4. Applies to resources that have a tag with key "Environment" and value "Testing"
   5. Uses the proper syntax for the condition clause with the hasTag() and getTag() operators
   
   The statement follows the Cedar policy language structure as documented in the AWS Systems Manager documentation for just-in-time node access policies.
   ```

1. 將政策陳述式貼到新的 Cedar 檔案中，以驗證語法。您也可以使用 [Cedar 演練場](https://www.cedarpolicy.com/en/playground)驗證陳述式。

1. 驗證陳述式之後，儲存 Cedar 檔案。

1. 從終端機執行下列 AWS CLI 命令，以使用您的政策內容建立 SSM 文件。在生產環境中使用核准政策之前，請使用 AWS 帳戶 和 中的身分和節點子集來測試核准政策 AWS 區域。
**注意**  
對於自動核准政策，文件名稱必須為 `SSM-JustInTimeAccessAutoApprovalPolicy`。每個 AWS 帳戶 和 只能有一個自動核准政策 AWS 區域。對於拒絕存取政策，文件名稱必須是 `SSM-JustInTimeAccessDenyAccessOrgPolicy`。每個 AWS Organizations 組織只能有一個拒絕存取政策，且必須在 Systems Manager 的委派管理員帳戶中建立政策。手動核准政策的命名限制與其他 SSM 文件相同。如需詳細資訊，請參閱 [CreateDocument](https://docs.aws.amazon.com/systems-manager/latest/APIReference/API_CreateDocument.html#systemsmanager-CreateDocument-request-Name)。

------
#### [ Linux & macOS ]

   ```
   aws ssm create-document \
       --content file://path/to/file/policyContent.cedar \
       --name "SSM-JustInTimeAccessAutoApprovalPolicy" \
       --document-type "AutoApproval"
   ```

------
#### [  Windows  ]

   ```
   aws ssm create-document ^
       --content file://C:\path\to\file\policyContent.cedar ^
       --name "SSM-JustInTimeAccessAutoApprovalPolicy" ^
       --document-type "AutoApproval"
   ```

------
#### [   PowerShell   ]

   ```
   $cedar = Get-Content -Path "C:\path\to\file\policyContent.cedar" | Out-String
   New-SSMDocument `
       -Content $cedar `
       -Name "SSM-JustInTimeAccessAutoApprovalPolicy" `
       -DocumentType "AutoApproval"
   ```

------

# 更新即時節點存取工作階段偏好設定
<a name="systems-manager-just-in-time-node-access-session-preferences"></a>

透過just-in-time節點存取，您可以在 AWS 區域 組織中的每個 和 中指定一般工作階段 AWS 帳戶 和記錄偏好設定。或者，您可以使用 CloudFormation StackSets 在多個帳戶和區域中建立工作階段偏好設定文件，以協助您擁有一致的工作階段偏好設定。如需有關工作階段偏好設定文件結構描述的資訊，請參閱[工作階段文件結構描述](session-manager-schema.md)。

為了記錄，建議搭配 Amazon CloudWatch Logs 使用串流選項。此功能可以讓您將持續的工作階段資料日誌串流傳送到 Amazon CloudWatch Logs。串流工作階段資料時會包含基本詳細資料，例如使用者在工作階段中執行的命令、執行命令的使用者 ID，以及工作階段資料串流至 CloudWatch Logs 時的時間戳記。串流工作階段資料時，日誌會採用 JSON 格式，以協助您與現有的日誌解決方案進行整合。

Systems Manager 不會自動終止即時節點存取工作階段。最佳實務是為*工作階段持續時間上限*和*閒置工作階段逾時*設定指定值。使用這些設定可協助您防止使用者在超出存取請求核准的時段外仍然保持與節點的連線。下列程序說明如何更新即時節點存取的工作階段偏好設定。

**重要**  
您必須使用標籤 AWS KMS 金鑰 和標籤值 ，在just-in-time節點存取中標記用於Session Manager加密`SystemsManagerJustInTimeNodeAccessManaged`和 RDP 記錄的金鑰`true`。  
如需有關標記 KMS 金鑰的資訊，請參閱 *AWS Key Management Service Developer Guide* 中的 [Tags in AWS KMS](https://docs.aws.amazon.com/kms/latest/developerguide/tagging-keys.html)。

**更新工作階段偏好設定**

1. 在 https：//[https://console.aws.amazon.com/systems-manager/](https://console.aws.amazon.com/systems-manager/) 開啟 AWS Systems Manager 主控台。

1. 在導覽窗格中選取**設定**。

1. 選取**即時節點存取**索引標籤。

1. 在**工作階段偏好設定**區段中，選取**編輯**。

1. 視需要更新您的一般偏好設定和記錄偏好設定，然後選取**儲存**。

# 設定即時存取請求的通知
<a name="systems-manager-just-in-time-node-access-notifications"></a>

您可以將 Systems Manager 設定為在使用者建立即時節點存取請求時，向核准者和申請者傳送電子郵件通知，或是在聊天用戶端傳送通知。通知包含請求者提供的存取請求的原因、 AWS 帳戶 AWS 區域、請求的狀態，以及目標節點的 ID。目前，Systems Manager 透過與聊天應用程式中的 Amazon Q Developer 整合來支援 Slack 和 Microsoft Teams 用戶端。透過聊天用戶端使用通知時，存取請求核准者可以直接與存取請求互動。如此，核准者無需登入主控台，即可對存取請求採取動作。

**開始之前**  
設定即時節點存取通知的聊天用戶端之前，請注意下列要求：
+ 如果您使用 IAM 角色來管理帳戶中的使用者身分，則必須手動將要向其傳送通知的核准者或申請者的電子郵件地址與相關聯的角色建立關聯。否則，無法透過電子郵件通知預期的收件人。

下列程序說明如何設定即時節點存取請求的通知。

**為即時節點存取設定聊天用戶端通知**

1. 在 https：//[https://console.aws.amazon.com/systems-manager/](https://console.aws.amazon.com/systems-manager/) 開啟 AWS Systems Manager 主控台。

1. 在導覽窗格中選取**設定**。

1. 選取**即時節點存取**索引標籤。

1. 在**聊天**區段中，選取**設定新用戶端**。

1. 在**選取用戶端類型**下拉式清單中，選擇您要設定的聊天用戶端類型，然後選取**下一步**。

1. 系統會提示您允許聊天應用程式中的 Amazon Q Developer 存取您的聊天用戶端。選取**允許**。

1. 在**設定管道**區段中，輸入聊天用戶端管道的資訊，然後選取您要接收的通知類型。

1. 如果您設定的是 Slack 通知，請邀請 "@Amazon Q" 加入正在設定通知的每個 Slack 管道。

1. 選取**設定管道**。

**注意**  
若要允許直接在 Slack 管道中核准/拒絕存取請求，請確定使用 Slack 管道設定的 IAM 角色具有 `ssm:SendAutomationSignal` 許可，且具有包含 Chatbot 的信任政策：  

```
{
            "Effect": "Allow",
            "Principal": {
                "Service": "chatbot.amazonaws.com"
            },
            "Action": "sts:AssumeRole"
}
```

**為即時節點存取設定電子郵件通知**

1. 在 https：//[https://console.aws.amazon.com/systems-manager/](https://console.aws.amazon.com/systems-manager/) 開啟 AWS Systems Manager 主控台。

1. 在導覽窗格中選取**設定**。

1. 選取**即時節點存取**索引標籤。

1. 在**電子郵件**區段中，選取**編輯**。

1. 選取**新增電子郵件**，選擇您要手動將電子郵件地址與其關聯的 **IAM 角色**。

1. 在**電子郵件地址**欄位中，輸入電子郵件地址。每當有需要您指定之 IAM 角色核准的存取請求建立時，與該角色關聯的電子郵件地址都會收到通知。

1. 選取**新增電子郵件地址**。

# 錄製 RDP 連線
<a name="systems-manager-just-in-time-node-access-rdp-recording"></a>

即時節點存取包括錄製對 Windows Server 節點進行的 RDP 連線。錄製 RDP 連線需要 S3 儲存貯體和 AWS Key Management Service (AWS KMS) 客戶自管金鑰。在記錄資料產生並存放在 Systems Manager 資源時， AWS KMS key 會用來暫時加密記錄資料。客戶自管金鑰必須是具有加密和解密金鑰使用功能的對稱金鑰。您可以為組織使用多區域金鑰，或者在已啟用即時節點存取的每個區域中建立客戶自管金鑰。

如果您已在儲存錄製的 S3 儲存貯體上啟用 KMS 加密，則必須為 `ssm-guiconnect` 服務主體提供用於儲存貯體加密的客戶自管金鑰的存取權限。此客戶自管金鑰可以是不同於您在錄製設定中指定的金鑰，其中必須包含建立連線所需的 `kms:CreateGrant` 許可。

## 設定 RDP 錄製的 S3 儲存貯體加密
<a name="rdp-recording-bucket-encryption"></a>

您的連線錄製會存放在您在啟用 RDP 錄製時指定的 S3 儲存貯體中。

如果您使用 KMS 金鑰作為 S3 儲存貯體 (SSE-KMS) 的預設加密機制，則必須允許 `ssm-guiconnect` 服務主體存取金鑰上的 `kms:GenerateDataKey` 動作。建議在搭配使用 SSE-KMS 加密和 S3 儲存貯體時，使用客戶自管金鑰。這是因為您可以更新客戶自管金鑰的相關金鑰政策。您無法更新 的金鑰政策 AWS 受管金鑰。

**重要**  
您必須使用標籤 AWS KMS 金鑰 和標籤值 ，在just-in-time節點存取中標記用於Session Manager加密`SystemsManagerJustInTimeNodeAccessManaged`和 RDP 記錄的金鑰`true`。  
如需有關標記 KMS 金鑰的資訊，請參閱 *AWS Key Management Service Developer Guide* 中的 [Tags in AWS KMS](https://docs.aws.amazon.com/kms/latest/developerguide/tagging-keys.html)。

使用下列客戶自管金鑰政策，可允許 `ssm-guiconnect` 服務存取 S3 儲存的 KMS 金鑰。如需有關更新客戶自管金鑰的資訊，請參閱 *AWS Key Management Service Developer Guide* 中的 [Change a key policy](https://docs.aws.amazon.com/kms/latest/developerguide/key-policy-modifying.html)。

使用您自己的資訊取代每個*範例資源預留位置*：
+ *account-id* 代表啟動連線的 AWS 帳戶 ID。
+ *region* 代表 S3 AWS 區域 儲存貯體所在的 。(如果儲存貯體會收到來自多個區域的錄製，您可以使用 `*`。範例：`s3.*.amazonaws.com`。)

**注意**  
如果帳戶屬於 AWS Organizations中的組織，您可以在政策中使用 `aws:SourceOrgID`，而不是 `aws:SourceAccount`。

```
{
    "Sid": "Allow the GUI Connect service principal to access S3",
    "Effect": "Allow",
    "Principal": {
        "Service": "ssm-guiconnect.amazonaws.com"
    },
    "Action": [
        "kms:GenerateDataKey*"
    ],
    "Resource": "*",
    "Condition": {
        "StringEquals": {
            "aws:SourceAccount": "account-id"
        },
        "StringLike": {
            "kms:ViaService": "s3.region.amazonaws.com"
        }
    }
}
```

## 設定錄製 RDP 連線的 IAM 許可
<a name="rdp-recording-iam-policy-examples"></a>

除了即時節點存取所需的 IAM 許可之外，還必須根據要執行的任務，授予您要使用的使用者或角色下列許可。

**設定連線錄製的許可**  
若要設定 RDP 連線錄製，需要下列許可：
+ `ssm-guiconnect:UpdateConnectionRecordingPreferences`
+ `ssm-guiconnect:GetConnectionRecordingPreferences`
+ `ssm-guiconnect:DeleteConnectionRecordingPreferences`
+ `kms:CreateGrant`

**啟動連線的許可**  
若要使用 RDP 連線進行即時節點存取，需要下列許可：
+ `ssm-guiconnect:CancelConnection`
+ `ssm-guiconnect:GetConnection`
+ `ssm-guiconnect:StartConnection`
+ `kms:CreateGrant`

**開始之前**  
若要存放連線錄製，您必須先建立 S3 儲存貯體，並新增下列儲存貯體政策。將每個*範例資源預留位置*取代為您自己的資訊。

(如需有關新增儲存貯體政策的資訊，請參閱 *Amazon Simple Storage Service User Guide* 中的 [Adding a bucket policy by using the Amazon S3 console](https://docs.aws.amazon.com/AmazonS3/latest/userguide/add-bucket-policy.html)。)

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "ConnectionRecording",
            "Effect": "Allow",
            "Principal": {
                "Service": [
                    "ssm-guiconnect.amazonaws.com"
                ]
            },
            "Action": "s3:PutObject",
            "Resource": [
                "arn:aws:s3:::amzn-s3-demo-bucket", 
                "arn:aws:s3:::amzn-s3-demo-bucket/*"
            ],
            "Condition":{
            "StringEquals":{
                "aws:SourceAccount":"111122223333"
                }
            }            
        }
    ]
}
```

------

## 啟用和設定 RDP 連線錄製
<a name="enable-rdp-connection-recording"></a>

下列程序說明如何啟用和設定 RDP 連線錄製。

**啟用和設定 RDP 連線錄製**

1. 在 https：//[https://console.aws.amazon.com/systems-manager/](https://console.aws.amazon.com/systems-manager/) 開啟 AWS Systems Manager 主控台。

1. 在導覽窗格中選取**設定**。

1. 選取**即時節點存取**索引標籤。

1. 在 **RDP 錄製**區段中，選取**啟用 RDP 錄製**。

1. 選擇您要向其上傳工作階段錄製的 S3 儲存貯體。

1. 選擇您要使用的客戶自管金鑰，用於暫時加密在 Systems Manager 資源上產生和存放的錄製資料。(此客戶自管金鑰可以與您用來加密儲存貯體的客戶自管金鑰不同。)

1. 選取**儲存**。

## RDP 連線錄製狀態值
<a name="rdp-recording-status"></a>

RPD 連線錄製的有效狀態值包括下列項目：
+ `Recording` – 連線正在進行錄製
+ `Processing` – 連線終止後正在處理影片。
+ `Finished` – 成功的終止狀態：連線錄製影片已成功處理並上傳至指定的儲存貯體。
+ `Failed` – 失敗的終止狀態。未成功錄製連線。
+ `ProcessingError` – 影片處理期間發生一或多個中繼失敗/錯誤。可能的原因包括服務相依性失敗，或由於指定用於儲存錄製的 S3 儲存貯體上存在設定錯誤而缺少許可。錄製處於此狀態時，服務會繼續嘗試處理。

**注意**  
`ProcessingError` 可能是連線建立後，`ssm-guiconnect` 服務主體沒有許可將物件上傳至 S3 儲存貯體的結果。另一個可能原因是用於 S3 儲存貯體加密的 KMS 金鑰缺少 KMS 許可。

# 修改目標
<a name="systems-manager-just-in-time-node-access-modify-targets"></a>

設定即時節點存取時，您可以選擇要設定即時節點存取的*目標*。目標由 AWS Organizations 組織單位 (OUs和 組成 AWS 區域。根據預設，系統會選取您在設定統一 Systems Manager 主控台時所選擇的相同目標，以進行just-in-time節點存取。您可以選擇為所有相同的目標或您在設定統一 Systems Manager 主控台時指定的目標子集設定just-in-time節點存取。不支援新增設定統一 Systems Manager 主控台時未選取的新目標。設定即時節點存取後，可以變更您選取的目標。

下列程序說明如何修改即時節點存取的目標。

**修改目標**

1. 在 https：//[https://console.aws.amazon.com/systems-manager/](https://console.aws.amazon.com/systems-manager/) 開啟 AWS Systems Manager 主控台。

1. 在導覽窗格中選取**設定**。

1. 選取**即時節點存取**索引標籤。

1. 在**目標**區段中，選取**編輯**。

1. 選取您要使用即時節點存取的**組織單位**和**區域**。

1. 選取**儲存**。

# 變更身分提供者
<a name="systems-manager-just-in-time-node-access-change-identity-provider"></a>

依預設，即時節點存取會使用 IAM 作為身分提供者。啟用即時節點存取後，使用整合式主控台的組織客戶可以修改此設定，以使用 IAM Identity Center。即時節點存取僅針對單一帳戶和區域設定時，不支援 IAM Identity Center 作為身分提供者。

下列程序說明如何修改即時節點存取的身分提供者。

**修改身分提供者**

1. 在 https：//[https://console.aws.amazon.com/systems-manager/](https://console.aws.amazon.com/systems-manager/) 開啟 AWS Systems Manager 主控台。

1. 在導覽窗格中選取**設定**。

1. 選取**即時節點存取**索引標籤。

1. 在**使用者身分**區段中，選取**編輯**。

1. 選擇 **AWS IAM Identity Center**。

1. 選取 **Save** (儲存)。