

• AWS Systems Manager CloudWatch 控制面板在 2026 年 4 月 30 日之后将不再可用。客户可以像现在一样继续使用 Amazon CloudWatch 控制台来查看、创建和管理其 Amazon CloudWatch 控制面板。有关更多信息，请参阅 [Amazon CloudWatch 控制面板文档](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Dashboards.html)。

# 使用 Systems Manager 进行即时节点访问
<a name="systems-manager-just-in-time-node-access"></a>

Systems Manager 通过支持*即时*访问来帮助您提高节点的安全性。即时节点访问允许用户请求对节点的临时、有时限的访问，只有在真正需要访问时才可批准访问。这样就无需为由 IAM 策略管理的节点提供长期访问权限。此外，Systems Manager 还为 Windows Server 节点的 RDP 会话提供会话录制，以帮助您满足合规性要求、执行根本原因分析等。要使用即时节点访问，必须设置统一的 Systems Manager 控制台。

通过即时节点访问，您可以创建精细的 IAM 策略，确保只有您许可的用户才能向您的节点提交访问请求。然后，您可以创建*审批策略*，这些策略定义了连接到您的节点所需的审批。对于即时节点访问，有*自动审批*策略和*手动审批*策略。自动审批策略定义了用户可以自动连接到哪些节点。手动审批策略定义了访问您指定的节点时必须提供的手动审批的数量和级别。此外，您还可以创建*拒绝访问*策略。拒绝访问策略明确禁止对您指定节点的访问请求的自动审批。拒绝访问策略适用于 AWS Organizations 组织中的所有账户。自动审批和手动审批策略仅适用于其创建所在的 AWS 账户和 AWS 区域。

当用户尝试连接到某个节点时，系统会提示他们输入访问该节点的原因。然后您的审批策略会经过评估。根据您的策略，用户要么自动连接到目标节点，要么 Systems Manager 自动代表请求者创建手动审批请求。然后，在适用于该节点的手动审批策略中指定的审批者会收到访问请求的通知，他们可以批准或拒绝该请求。审批者和请求者可以通过电子邮件收到通知，也可以通过与 Slack 或 Microsoft Teams 集成的聊天应用程序中的 Amazon Q 开发者版收到通知。只有当指定的审批者提供全部所需批准时，Systems Manager 才会授予对所请求节点的访问权限。收到全部所需批准后，用户可以在审批策略中指定的访问时段期间根据需要启动任意数量的节点会话。Systems Manager 不会自动终止即时节点访问会话。作为最佳实践，请指定会话首选项*最长会话持续时间*和*空闲会话超时*的值。这些首选项可防止用户在批准的访问时段之外仍保持与节点的连接。

我们建议使用审批策略组合来帮助您保护包含更多关键数据的节点，同时允许用户无需干预即可连接到不太重要的节点。例如，您可以要求手动审批对数据库节点的访问请求，以及自动审批非持久性表示层节点的会话。

Systems Manager 支持与 IAM Identity Center 或 IAM 联合的用户进行即时节点访问。当联合用户提交访问请求时，他们会指定目标节点以及需要连接到该节点的原因。Systems Manager 会将用户的身份与组织的审批策略中定义的参数进行比较。当满足自动审批策略条件或审批者手动提供批准时，请求者便可连接到目标节点。用户尝试连接到已批准的节点时，Systems Manager 会创建并使用临时令牌来建立会话。

由于 Systems Manager 服务负责处理访问请求的身份验证和建立会话，您不必使用 IAM 策略来管理对节点的访问。通过使用即时节点访问，Systems Manager 可以帮助组织接近零常设权限，因为您只需要允许用户创建访问请求，而不必允许他们以对节点的永久权限启动会话。为帮助您满足合规性要求，Systems Manager 会将所有访问请求保留 1 年。Systems Manager 还会针对以下情况发出 EventBridge 事件：失败访问请求的即时节点访问，以及手动审批的访问请求状态更新。有关更多信息，请参阅[使用 Amazon EventBridge 监控 Systems Manager 事件](monitoring-eventbridge-events.md)。

**Topics**
+ [使用 Systems Manager 设置即时访问](systems-manager-just-in-time-node-access-setting-up.md)
+ [启动即时节点访问会话](systems-manager-just-in-time-node-access-start-session.md)
+ [管理即时访问请求](systems-manager-just-in-time-node-access-manage-requests.md)
+ [从Session Manager移至即时节点访问](systems-manager-just-in-time-node-access-moving-from-session-manager.md)
+ [使用 Systems Manager 禁止即时访问](systems-manager-just-in-time-node-access-disable.md)
+ [即时节点访问权限常见问题](just-in-time-node-access-faq.md)

# 使用 Systems Manager 设置即时访问
<a name="systems-manager-just-in-time-node-access-setting-up"></a>

使用 Systems Manager 设置即时节点访问涉及多个步骤。首先，选择要设置即时节点访问的*目标*。目标包括 AWS Organizations 组织单元（OU）和 AWS 区域。默认情况下，会选择您在设置统一 Systems Manager 控制台时选择的相同目标进行即时节点访问。您可以选择为所有相同的目标设置即时节点访问权限，或为设置统一的 Systems Manager 控制台时指定的目标子集设置即时节点访问权限。不支持添加在设置统一的 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://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)
+ [为即时节点访问创建自动审批策略](systems-manager-just-in-time-node-access-create-auto-approval-policies.md)
+ [为即时节点访问创建拒绝访问策略](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 账户和 AWS 区域创建最多 50 个手动审批策略。

**创建手动审批策略**

1. 访问 [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`  | 
| 范围 |  `(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_cn/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"
};
```

# 为即时节点访问创建自动审批策略
<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://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-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 组织只能有一个拒绝访问策略。
即时节点访问功能使用 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://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 开发者版，可在软件开发的各个方面提供指导和支持。对于即时访问节点，Amazon Q 可通过生成和更新策略代码、分析策略语句等来帮助您创建审批策略。以下信息介绍如何使用适用于命令行的 Amazon Q 创建审批策略。

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

创建审批策略的第一步是明确定义您的使用案例。例如，在您的组织中，您可能希望自动批准对带有 `Environment:Testing` 标签的节点的访问请求。如果员工 ID 以 `TEMP` 开头，您可能还想明确拒绝对带有 `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)。

我们还建议安装 MCP 服务器以获取 AWS 文档。此 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 Documentation MCP Server](https://awslabs.github.io/mcp/servers/aws-documentation-mcp-server/)。

安装并配置 AWS CLI（如果尚未执行该操作）。有关更多信息，请参阅[安装或更新最新版本的 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 开发者版使用生成式人工智能。您可能需要验证回复。请参阅 [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>

通过即时节点访问，您可以在组织的每个 AWS 账户和 AWS 区域中指定常规会话和日志记录首选项。或者，您可以使用 CloudFormation StackSets 在多个账户和区域中创建会话首选项文档，帮助您获得一致的会话首选项。有关会话首选项文档的架构的更多信息，请参阅[会话文档架构](session-manager-schema.md)。

出于日志记录目的，我们建议在 Amazon CloudWatch Logs 中使用流选项。此功能允许您向 CloudWatch Logs 发送持续的会话数据日志流。在流式传输会话数据时，将包括必要的详细信息，例如用户在会话中运行的命令、运行命令的用户的 ID，以及将会话数据流式传输到 CloudWatch Logs 的时间戳。流式传输会话数据时，日志采用 JSON 格式，以帮助您与现有的日志记录解决方案相集成。

Systems Manager 不会自动终止即时节点访问会话。作为最佳实践，请指定*最长会话持续时间*和*空闲会话超时*设置的值。使用这些设置有助于防止用户保持与节点的连接时间超过访问请求中批准的时间范围。以下过程介绍如何更新即时节点访问的会话首选项。

**重要**  
您必须使用标签键 `SystemsManagerJustInTimeNodeAccessManaged` 和标签值 `true` 来标记用于即时节点访问中的 Session Manager 加密和 RDP 记录的 AWS KMS 密钥。  
有关标记 KMS 密钥的信息，请参阅《*AWS Key Management Service 开发人员指南*》中的 [Tags in AWS KMS](https://docs.aws.amazon.com/kms/latest/developerguide/tagging-keys.html)。

**更新会话首选项**

1. 访问 [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 开发者版集成来支持 Slack 和 Microsoft Teams 客户端。通过聊天客户端使用通知时，访问请求审批者可以直接与访问请求进行交互。这样就无需登录控制台即可对访问请求采取行动。

**开始前的准备工作**  
在为即时节点访问通知配置聊天客户端之前，请注意下面的要求：
+ 如果使用 IAM 角色管理账户中的用户身份，则必须手动将要向其发送通知的审批者或请求者的电子邮件地址与关联角色相关联。否则，将无法通过电子邮件通知目标收件人。

以下过程介绍如何为即时节点访问请求配置通知。

**为即时节点访问通知配置聊天客户端**

1. 访问 [https://console.aws.amazon.com/systems-manager/](https://console.aws.amazon.com/systems-manager/)，打开 AWS Systems Manager 控制台。

1. 在导航窗格中选择**设置**。

1. 选择**即时节点访问**选项卡。

1. 在**聊天**部分中，选择**配置新客户端**。

1. 在**选择客户端类型**下拉列表中，选择要配置的聊天客户端类型，然后选择**下一步**。

1. 系统会提示您允许聊天应用程序中的 Amazon Q 开发者版访问您的聊天客户端。选择**允许**。

1. 在**配置渠道**部分中，输入聊天客户端渠道的信息，然后选择要接收的通知类型。

1. 如果正在配置 Slack 通知，请邀请“@Amazon Q”加入正在配置通知的每个 Slack 通道。

1. 选择**配置渠道**。

**注意**  
要允许直接从 Slack 通道批准/拒绝访问请求，请确保使用 Slack 通道配置的 IAM 角色具有 `ssm:SendAutomationSignal` 权限，并且具有包含聊天机器人的信任策略：  

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

**为即时节点访问通知配置电子邮件通知**

1. 访问 [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 托管式密钥的密钥策略。

**重要**  
您必须使用标签键 `SystemsManagerJustInTimeNodeAccessManaged` 和标签值 `true` 来标记用于即时节点访问中的 Session Manager 加密和 RDP 记录的 AWS KMS 密钥。  
有关标记 KMS 密钥的信息，请参阅《*AWS Key Management Service 开发人员指南*》中的 [Tags in AWS KMS](https://docs.aws.amazon.com/kms/latest/developerguide/tagging-keys.html)。

使用以下客户自主管理型密钥策略允许 `ssm-guiconnect` 服务访问 S3 存储的 KMS 密钥。有关更新客户自主管理型密钥的信息，请参阅《AWS Key Management Service 开发人员指南》中的 [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"
        }
    }
}
```

## 配置 IAM 权限以录制 RDP 连接
<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 用户指南》中的[使用 Amazon S3 控制台添加存储桶策略](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://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 组织单元（OU）和 AWS 区域。默认情况下，会选择您在设置统一 Systems Manager 控制台时选择的相同目标进行即时节点访问。您可以选择为所有相同的目标设置即时节点访问权限，或为设置统一的 Systems Manager 控制台时指定的目标子集设置即时节点访问权限。不支持添加在设置统一的 Systems Manager 控制台时未选择的新目标。在设置即时节点访问后，您可以更改所选的目标。

以下过程介绍如何修改目标以实现即时节点访问。

**修改目标**

1. 访问 [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://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. 选择**保存**。

# 启动即时节点访问会话
<a name="systems-manager-just-in-time-node-access-start-session"></a>

启用和设置即时节点访问以及配置会话和通知首选项后，用户便可启动即时节点访问会话。您可以从 Systems Manager 控制台或从使用Session Manager插件的 AWS Command Line Interface，使用即时节点访问来启动会话。可以在同一账户和区域中的节点上启动即时节点访问会话。以下过程介绍如何使用即时节点访问来启动会话。

**注意**  
如果您的用户以前曾使用Session Manager连接到节点，则您必须从他们的 IAM 策略中移除Session Manager权限（例如 `ssm:StartSession`），才能使用即时节点访问来启动会话。否则，当连接到节点时，将继续使用Session Manager。

**通过控制台使用即时节点访问来启动会话**

1. 访问 [https://console.aws.amazon.com/systems-manager/](https://console.aws.amazon.com/systems-manager/)，打开 AWS Systems Manager 控制台。

1. 在导航窗格中选择**浏览节点**。

1. 选择要连接到的节点。

1. 在**操作**下拉列表中，选择**连接**。

如果组织的批准政策不允许您自动连接到该节点，则系统会提示您提交访问请求。填写所需信息并提交访问请求后，在收到全部所需批准后，您便可开始与该节点的会话。

**通过AWS CLI使用即时节点访问来启动会话**

1. 运行以下命令以开始访问请求工作流，并确保将*占位符值*替换为您自己的信息。

   ```
   aws ssm start-access-request \
       --targets  Key=InstanceIds,Values=i-02573cafcfEXAMPLE
       --reason "Troubleshooting networking performance issue"
   ```

   根据组织的审批政策，要么会自动连接到节点，要么会启动手动审批流程。对于需要手动审批的请求，请记下响应中返回的访问请求的 ID。

1. 等待提供全部所需批准。

1. 提供全部所需批准后，运行以下命令以获取包含临时凭证的访问令牌。将*占位符值* 替换为您自己的信息。

   ```
   aws ssm get-access-token \
       --access-request-id oi-12345abcdef
   ```

   记下响应中返回的访问令牌。

1. 运行以下命令以使用 AWS CLI 中的临时凭证，并确保将*占位符值*替换为您自己的信息。

   ```
   export AWS_SESSION_TOKEN=AQoDYXdzEJr...<remainder of session token>
   ```

1. 运行以下命令以启动与节点的会话，并确保将*占位符值*替换为您自己的信息。

   ```
   aws ssm start-session \
       --target i-02573cafcfEXAMPLE
   ```

# 管理即时访问请求
<a name="systems-manager-just-in-time-node-access-manage-requests"></a>

为了提高整个组织的可见性，Systems Manager 会将访问请求复制到贵组织的委派管理员账户。为帮助您满足合规性要求，Systems Manager 会将所有访问请求保留 1 年。以下主题介绍了如何管理即时节点访问请求。此信息适用于访问请求审批人。在开始之前，我们建议您查看 IAM 策略，并确保您拥有管理即时节点访问所需的权限。有关更多信息，请参阅[使用 Systems Manager 设置即时访问](systems-manager-just-in-time-node-access-setting-up.md)。

**Topics**
+ [批准和拒绝即时节点访问请求](systems-manager-just-in-time-node-access-approve-deny-requests.md)

# 批准和拒绝即时节点访问请求
<a name="systems-manager-just-in-time-node-access-approve-deny-requests"></a>

访问请求审批人可以批准或拒绝来自统一 Systems Manager 控制台或使用您的首选命令行工具的即时节点访问请求。此信息适用于访问请求审批人。如果您没有批准或拒绝访问请求所需的权限，请联系您的管理员。以下过程介绍如何批准或拒绝即时节点访问请求。

**使用控制台批准或拒绝即时节点访问请求**

1. 访问 [https://console.aws.amazon.com/systems-manager/](https://console.aws.amazon.com/systems-manager/)，打开 AWS Systems Manager 控制台。

1. 在导航窗格中选择**管理节点访问**。

1. 选择**访问请求**选项卡。

1. 选择**我的请求**开关。

1. 在要批准或拒绝的访问请求旁边，选中相应的复选框。

1. 选择**批准**或**拒绝**。

批准访问请求后，您可以随时通过选择**撤销**来撤消您的批准。

**使用命令行批准或拒绝即时节点访问请求**

1. 记下通知中的访问请求 ID。例如，*oi-12345abcdef*。

1. 运行以下命令，返回有关访问请求批准工作流的详细信息，确保将*占位符值*替换为您自己的信息。

   ```
   aws ssm get-ops-item \
       --ops-item-id oi-12345abcdef
   ```

   请记下 `OperationalData` 的 `/aws/accessrequest` 字段中的 `automationExecutionId` 值。例如 *9231944f-61c6-40be-8bce-8ee2bEXAMPLE*。

1. 运行以下命令，批准或拒绝访问请求。使用 `Approve` 信号类型批准请求，使用 `Deny` 拒绝请求。确保将*占位符值*替换为您自己的信息。

   ```
   aws ssm send-automation-signal \
       --automation-execution-id 9231944f-61c6-40be-8bce-8ee2bEXAMPLE \
       --signal-type "Approve"
   ```

# 从Session Manager移至即时节点访问
<a name="systems-manager-just-in-time-node-access-moving-from-session-manager"></a>

启用即时节点访问后，会话管理器不会对Session Manager的现有资源进行任何更改。这样可确保您的现有环境不会中断，并且在您创建和验证审批策略的同时，用户可以继续启动会话。您准备好测试审批策略后，必须修改现有 IAM 策略以完成向即时节点访问的过渡。这包括向身份添加即时节点访问所需的权限，并移除对Session Manager `StartSession` API 操作的权限。我们建议使用 AWS 账户和 AWS 区域中的身份和节点子集来测试审批策略。

有关即时节点访问所需权限的更多信息，请参阅[使用 Systems Manager 设置即时访问](systems-manager-just-in-time-node-access-setting-up.md)。

有关修改和身份的 IAM 权限的更多信息，请参阅《IAM 用户指南》**中的[添加和删除 IAM 身份权限](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_manage-attach-detach.html)。

下面介绍一种详细的方法，说明如何从Session Manager移至即时节点访问。

从会话管理器移至即时节点访问需要仔细的规划和测试，以确保在不中断操作的情况下平稳过渡。以下各部分将介绍如何完成此过程。

## 先决条件
<a name="migration-prerequisites"></a>

在开始之前，请确保您已完成以下任务：
+ 设置 Systems Manager 统一控制台。
+ 已确认您有权修改账户中的 IAM 策略。
+ 已确定当前授予Session Manager权限的所有 IAM 策略和角色。
+ 记录了当前的Session Manager配置，包括会话首选项和日志记录设置。

## 评测
<a name="environment-assessment"></a>

完成以下任务，评测当前的环境并概述所需的批准行为：

1. **清点您的节点**：确定用户当前通过Session Manager访问的所有节点。

1. **确定用户访问模式**：记录哪些用户或角色在什么情况下需要访问哪些节点。

1. **映射批准工作流**：确定谁应批准不同类型节点的访问请求。

1. **审查标记策略**：确保节点已正确标记，以支持计划的审批策略。

1. **审核现有 IAM 策略**：确定所有包含Session Manager权限的策略。

## 规划
<a name="migration-planning"></a>

### 分阶段策略
<a name="migration-planning-strategy"></a>

从Session Manager移至即时节点访问时，建议使用如下所示的分阶段方法：

1. **第 1 阶段：设置和配置** – 启用即时节点访问，无需修改现有Session Manager权限。

1. **第 2 阶段：策略制定** – 为节点创建和测试审批策略。

1. **第 3 阶段：试点迁移** – 将一小部分非关键节点和用户或角色从Session Manager修改为即时节点访问。

1. **第 4 阶段：完全迁移** – 逐步迁移所有剩余的节点和用户或角色。

### 时间线注意事项
<a name="migration-planning-timeline"></a>

在创建时间线以从Session Manager移至即时节点访问时，请考虑以下因素：
+ 留出时间以便根据新的审批工作流进行用户培训和调整。
+ 计划在操作活动较少的时段进行的迁移。
+ 将故障排除和调整的缓冲时间包含在内。
+ 在两个系统都可用的情况下，计划一段并行操作的时期。

## 实现步骤
<a name="migration-implementation"></a>

### 第 1 阶段：设置和配置
<a name="migration-implementation-phase1"></a>

1. 在 Systems Manager 控制台中启用即时节点访问。有关详细步骤，请参阅[使用 Systems Manager 设置即时访问](systems-manager-just-in-time-node-access-setting-up.md)。

1. 为即时节点访问配置会话首选项，使其与您当前的Session Manager设置相匹配。有关更多信息，请参阅 [更新即时节点访问会话首选项](systems-manager-just-in-time-node-access-session-preferences.md)。

1. 设置访问请求的通知首选项。有关更多信息，请参阅 [为即时访问请求配置通知](systems-manager-just-in-time-node-access-notifications.md)。

1. 如果您使用与 Windows Server 节点的 RDP 连接，请配置 RDP 录制。有关更多信息，请参阅 [录制 RDP 连接](systems-manager-just-in-time-node-access-rdp-recording.md)。

### 第 2 阶段：策略制定
<a name="migration-implementation-phase2"></a>

1. 为即时节点访问管理员和用户创建 IAM 策略。

1. 根据您的安全要求和应用场景制定审批策略。

1. 请在非生产环境中测试策略，确保其按预期运行。

### 第 3 阶段：试点迁移
<a name="migration-implementation-phase3"></a>

1. 为试点选择一小群用户和非关键节点。

1. 为试点用户创建包含即时节点访问权限的新 IAM 策略。

1. 从试点用户的 IAM 策略中删除Session Manager权限 (`ssm:StartSession`)。

1. 对试点用户进行有关新的访问请求工作流的培训。

1. 监控试点是否存在问题并收集反馈。

1. 根据试点结果调整策略和程序。

**试点用户的 IAM 策略修改示例**  
具有Session Manager权限的原始策略：

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

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "ssm:StartSession",
        "ssm:ResumeSession",
        "ssm:TerminateSession"
      ],
      "Resource": "*"
    }
  ]
}
```

------

修改后的即时节点访问策略：

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

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "ssm:StartAccessRequest",
        "ssm:GetAccessToken",
        "ssm:ResumeSession",
        "ssm:TerminateSession"
      ],
      "Resource": "*"
    }
  ]
}
```

------

### 第 4 阶段：完全迁移
<a name="migration-implementation-phase4"></a>

制定分批迁移剩余用户和节点的计划。

## 测试方法
<a name="migration-testing"></a>

在整个迁移过程中，请进行以下测试：
+ **策略验证**：验证审批策略是否正确适用于目标节点和用户。
+ **访问请求工作流**：针对自动审批和手动审批方案，测试从访问请求到会话建立的完整工作流。
+ **通知**：验证审批者是否通过配置的渠道（电子邮件、Slack、Microsoft Teams）接收通知。
+ **日志记录和监控**：验证是否正确捕获和存储了会话日志和访问请求。

## 有关成功迁移的最佳实践
<a name="migration-best-practices"></a>
+ **尽早并经常沟通**：告知用户迁移时间线和即时节点访问的优势。
+ **从非关键系统开始**：在进入生产环境之前，从开发或测试环境开始迁移。
+ **记录所有内容**：保留您的审批策略、IAM 策略更改和配置设置的详细记录。
+ **监控和调整**：持续监控访问请求和批准工作流，根据需要调整策略。
+ **建立治理方案**：创建流程，以便在环境改变时定期审查和更新审批策略。

# 使用 Systems Manager 禁止即时访问
<a name="systems-manager-just-in-time-node-access-disable"></a>

以下过程描述了如何禁用即时节点访问。禁用即时节点访问后，除非您已经实施了其他连接方法，否则组织中的用户可能无法连接到您的节点。

**禁用即时节点访问**

1. 登录贵组织的 Systems Manager 委派管理员账户。

1. 访问 [https://console.aws.amazon.com/systems-manager/](https://console.aws.amazon.com/systems-manager/)，打开 AWS Systems Manager 控制台。

1. 在导航窗格中选择**设置**。

1. 在**即时节点访问**选项卡中，选择**禁用**。

# 即时节点访问权限常见问题
<a name="just-in-time-node-access-faq"></a>

## 如何从 Session Manager 迁移到即时节点访问？
<a name="migrating"></a>

设置统一控制台并启用即时节点访问后，必须修改现有 IAM 策略才能完成向即时节点访问的迁移。这包括为即时节点访问添加所需权限，并移除对 Session Manager `StartSession` API 操作的权限。有关用于即时节点访问的 IAM 策略的更多信息，请参阅[使用 Systems Manager 设置即时访问](systems-manager-just-in-time-node-access-setting-up.md)。

## 是否必须设置统一控制台才能使用即时节点访问？
<a name="prerequisites"></a>

是的，设置统一控制台是使用即时节点访问的先决条件。但是，在设置统一控制台并启用即时节点访问后，可通过多种方法连接到节点。例如，可以从 Amazon EC2 控制台和 AWS CLI 启动即时节点访问会话。有关设置统一控制台的更多信息，请参阅[为组织设置 Systems Manager 统一控制台](systems-manager-setting-up-organizations.md)。

## 即时节点访问会产生费用吗？
<a name="pricing"></a>

Systems Manager 为即时节点访问提供 30 天免费试用。试用期结束后，即时节点访问会产生费用。有关更多信息，请参阅[AWS Systems Manager定价](https://aws.amazon.com/systems-manager/pricing/)。

## 即时节点访问审批策略的优先顺序是什么？
<a name="policy-precedence"></a>

审批策略按以下顺序评估：

1. 拒绝访问

1. 自动审批

1. 手动

## 如何评估手动审批策略？
<a name="manual-policy-precedence"></a>

即时节点访问始终优先应用针对节点的更具体策略。手动审批策略按以下顺序评估：

1. 特定标签的目标

1. 所有节点目标

## 如果没有适用于节点的审批策略会怎样？
<a name="no-policy-error"></a>

要使用即时节点访问连接到节点，必须有适用于该节点的审批策略。如果没有适用于节点的审批策略，则用户将无法请求访问该节点。

## 多个审批策略可以针对同一标签吗？
<a name="tag-target"></a>

每个标签在审批策略中只能被针对一次。

## 如果由于标签重叠导致多个手动审批策略应用于同一节点会怎样？
<a name="policy-conflict"></a>

当多个手动审批策略应用于一个节点时，会导致冲突，用户将无法请求访问该节点。创建手动审批策略时请记住这一点，某些实例可能因具体用例带有多个标签。

## 能否使用即时节点访问，跨账户和跨区域请求访问节点并启动会话？
<a name="cross-account"></a>

即时节点访问支持对与请求者位于同一账户和区域内的节点请求访问并启动会话。

## 能否使用即时节点访问，请求访问通过混合激活注册的节点并启动会话？
<a name="hybrid-nodes"></a>

可以，即时节点访问支持对通过混合激活注册的节点请求访问并启动会话，但节点必须注册到请求者所在的同一账户和区域内。