i got this ec2 instances from my Stack in CDK, as you can see below. the machine share the same configuration except for the custom ami (both windows server 2016, buth with different software inside).
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
});
the pipeline goes as expected, the machines are up and running.
For the VPC i have already configured the services endpoint required by session manager and added the policy AmazonSSMManagedInstanceCore to the 'role4win' IAM Role.
On my personal laptop i've installed the Session Manager plugin. Thus i can connect to the sw-WindowsInstance using that plugin with the RDP but i can't connect to the ls-WindowsInstance.
The error
An error occurred (TargetNotConnected) when calling the StartSession operation: i-xxxxxxxxxxxxxxxxx is not connected.
where i-xxxxxxxxxxxxxxxxx is the instance-ID of the ls-WindowsInstance.
i found this article that explain
PROBLEM: You try to start a session, but the system returns the error message, "An error occurred (TargetNotConnected) when calling the StartSession operation: InstanceID isn't connected."
Solution A: This error is returned when the specified target instance for the session isn't fully configured for use with Session Manager. For information, see Setting up Session Manager.
Solution B: This error is also returned if you attempt to start a session on an instance that is located in a different AWS account or AWS Region.
but, as i said, the machines shares the same configuration: same subnet, same security group, same, role, same os and same region. Can someone help me?!