Reputation: 11
Trying to get the instance ID of an EC2 instance created by CF (generated by AWS CDK), this used to work in at least v0.28:
const natInstance1 = new CfnInstance(this, 'NatInstance1', {
imageId: NAT_AMI_ID,
instanceType: NAT_INSTANCE_TYPE,
subnetId: vpc.publicSubnets[0].subnetId,
keyName: NAT_SSH_KEY,
sourceDestCheck: false,
securityGroupIds: [
publicSecurityGroup.securityGroupId
]
});
new ec2.CfnEIPAssociation(this, 'NatEip1', {
eip: NAT_EIP_POOL[0],
instanceId: natInstance1.instanceId
});
This no longer works in v0.37.0, get error: Property 'instanceId' does not exist on type 'CfnInstance'.ts(2339)
Upvotes: 1
Views: 1270
Reputation: 3608
The question was raised as aws-cdk issue and answered. Here the the code snippet taken from the linked answer:
new ec2.CfnEIPAssociation(this, 'NatEip1', {
eip: NAT_EIP_POOL[0],
instanceId: natInstance1.ref
});
Upvotes: 5