mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
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:
1 parent
0524d156d4
commit
e60cf84922
5 files changed
+13
-5
No files matched your search
+5
@@ -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. */
|
||||
|
||||
+2
@@ -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());
|
||||
}
|
||||
|
||||
+3
-1
@@ -62,6 +62,7 @@ class Ec2InstanceCfnProvisionerTest {
|
||||
instance.setPrivateDnsName("ip-10-0-0-5.ec2.internal");
|
||||
instance.setPublicDnsName("ec2-54-0-0-5.compute-1.amazonaws.com");
|
||||
instance.setPlacement(new Placement("us-east-1a"));
|
||||
instance.setVpcId("vpc-1");
|
||||
stubLaunch(instance);
|
||||
StackResource r = resource("Server");
|
||||
|
||||
@@ -69,9 +70,10 @@ class Ec2InstanceCfnProvisionerTest {
|
||||
|
||||
assertEquals("i-1", r.getPhysicalId());
|
||||
assertEquals(Set.of("InstanceId", "PrivateIp", "PublicIp", "PrivateDnsName", "PublicDnsName",
|
||||
"AvailabilityZone"), r.getAttributes().keySet());
|
||||
"AvailabilityZone", "VpcId"), r.getAttributes().keySet());
|
||||
assertEquals("10.0.0.5", r.getAttributes().get("PrivateIp"));
|
||||
assertEquals("us-east-1a", r.getAttributes().get("AvailabilityZone"));
|
||||
assertEquals("vpc-1", r.getAttributes().get("VpcId"));
|
||||
verify(ec2).awaitContainerLaunch(instance);
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -47,7 +47,7 @@ class Ec2SecurityGroupCfnProvisionerTest {
|
||||
private final ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
@Test
|
||||
void createPublishesGroupIdAndVpcIdOnly() throws Exception {
|
||||
void createPublishesGroupIdIdAndVpcId() throws Exception {
|
||||
when(ec2.createSecurityGroup("us-east-1", "web", "web tier", "vpc-1"))
|
||||
.thenReturn(group("sg-1", "web", "web tier", "vpc-1"));
|
||||
StackResource r = resource("WebSg");
|
||||
@@ -57,8 +57,9 @@ class Ec2SecurityGroupCfnProvisionerTest {
|
||||
"""), ctx(null));
|
||||
|
||||
assertEquals("sg-1", r.getPhysicalId());
|
||||
assertEquals(Set.of("GroupId", "VpcId"), r.getAttributes().keySet());
|
||||
assertEquals(Set.of("GroupId", "Id", "VpcId"), r.getAttributes().keySet());
|
||||
assertEquals("sg-1", r.getAttributes().get("GroupId"));
|
||||
assertEquals("sg-1", r.getAttributes().get("Id"));
|
||||
assertEquals("vpc-1", r.getAttributes().get("VpcId"));
|
||||
}
|
||||
|
||||
|
||||
@@ -3,12 +3,10 @@ AWS::CodeBuild::Project Id schema gives no description; AWS's Id may differ from
|
||||
AWS::CodePipeline::CustomActionType Id schema gives no description; the custom action has no separate id in Floci
|
||||
AWS::CodePipeline::Webhook Id schema gives no description; Floci keys webhooks by name
|
||||
AWS::EC2::Instance State not published yet: Floci tracks the instance state, setting it is a separate change to what Fn::GetAtt returns
|
||||
AWS::EC2::Instance VpcId not published yet: the instance's VPC comes from its subnet, setting it is a separate change to what Fn::GetAtt returns
|
||||
AWS::EC2::NatGateway AutoProvisionZones availability-mode NAT gateways are not emulated
|
||||
AWS::EC2::NatGateway AutoScalingIps availability-mode NAT gateways are not emulated
|
||||
AWS::EC2::NatGateway EniId the NAT gateway's network interface is not created
|
||||
AWS::EC2::NatGateway RouteTableId availability-mode NAT gateways are not emulated
|
||||
AWS::EC2::SecurityGroup Id not published yet: the group id is already published as GroupId, adding Id is a separate change to what Fn::GetAtt returns
|
||||
AWS::EC2::Subnet BlockPublicAccessStates VPC block public access is not emulated
|
||||
AWS::EC2::Subnet Ipv6CidrBlocks IPv6 CIDR association is not emulated
|
||||
AWS::EC2::Subnet NetworkAclAssociationId the subnet's default network ACL association is not created with the subnet
|
||||
|
||||
|
Reference in new issue
Block a user