0

我从我的 CDK 堆栈中获得了这个 ec2 实例,如下所示。除了自定义 ami 之外,机器共享相同的配置(都是 windows server 2016,但内部有不同的软件)。

 const ec2License = new ec2.Instance(this, `ls-WindowsInstance`, {
        vpc: this.vpc,
        vpcSubnets: {subnetType: ec2.SubnetType.PRIVATE_WITH_NAT},
        instanceType: ec2.InstanceType.of(ec2.InstanceClass.T3, ec2.InstanceSize.MEDIUM),
        machineImage: ami_license,
        securityGroup: securityGroupS,
        keyName: key.keyPairName,
        role: role4win
      });
  const ec2software = new ec2.Instance(this, `sw-WindowsInstance`, {
        vpc: this.vpc,
        vpcSubnets: {subnetType: ec2.SubnetType.PRIVATE_WITH_NAT},
        instanceType: ec2.InstanceType.of(ec2.InstanceClass.T3, ec2.InstanceSize.MEDIUM),
        machineImage: ami_software,
        securityGroup: securityGroupS,
        keyName: key.keyPairName,
        role: role4win
      });

管道按预期进行,机器已启动并运行。对于 VPC,我已经配置了会话管理器所需的服务端点,并将策略添加AmazonSSMManagedInstanceCore到“role4win”IAM 角色。

在我的个人笔记本电脑上,我安装了Session Manager 插件。因此,我可以使用带有 RDP 的插件连接到 sw-WindowsInstance,但我无法连接到 ls-WindowsInstance。

错误

An error occurred (TargetNotConnected) when calling the StartSession operation: i-xxxxxxxxxxxxxxxxx is not connected.

其中 i-xxxxxxxxxxxxxxxxx 是 ls-WindowsInstance 的实例 ID。

我发现这篇文章解释了

问题:您尝试启动会话,但系统返回错误消息“调用 StartSession 操作时发生错误 (TargetNotConnected):InstanceID 未连接。”

解决方案 A:当会话的指定目标实例未完全配置为与 Session Manager 一起使用时,将返回此错误。有关信息,请参阅设置会话管理器。

解决方案 B:如果您尝试在位于不同 AWS 账户或 AWS 区域的实例上启动会话,也会返回此错误。

但是,正如我所说,这些机器共享相同的配置:相同的子网、相同的安全组、相同的角色、相同的操作系统和相同的区域。 有人能帮我吗?!

4

0 回答 0