fix(cloudformation): publish EC2 SecurityGroup Id and Instance VpcId for Fn::GetAtt (#4155)

Both are handler-backed but were gapped, so Fn::GetAtt resolved to the literal
"Logical.Attr" string instead of the real value. Publish SecurityGroup Id
(= GroupId) and Instance VpcId, and drop their gap rows. Instance State stays
gapped, as there is no stable value to publish for it.
This commit is contained in:
Hector Ventura authored and GitHub committed 2026-09-22 09:03:21 -04:00
1 parent 0524d156d4
commit e60cf84922
5 files changed
+13 -5

No files matched your search

@@ -301,6 +301,11 @@ public class Ec2InstanceCfnProvisioner implements CfnResourceProvisioner {
} else {
r.getAttributes().remove("AvailabilityZone");
}
if (instance.getVpcId() != null) {
r.getAttributes().put("VpcId", instance.getVpcId());
} else {
r.getAttributes().remove("VpcId");
}
}
/** Reconciles the instance tags to the template when the instance is kept in place. */
@@ -84,6 +84,8 @@ public class Ec2SecurityGroupCfnProvisioner implements CfnResourceProvisioner {
// Ref on AWS::EC2::SecurityGroup returns the group id for VPC security groups.
r.setPhysicalId(sg.getGroupId());
r.getAttributes().put("GroupId", sg.getGroupId());
// Id is the schema's primary identifier and equals the group id, the same value as GroupId.
r.getAttributes().put("Id", sg.getGroupId());
if (sg.getVpcId() != null) {
r.getAttributes().put("VpcId", sg.getVpcId());
}