mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
fix(cloudformation): publish RuleName and the RDS group ARNs the current registry schemas declare (#4135)
The current CloudFormation registry schemas changed the readOnlyProperties of six resource types, and CfnSchemaCoverageTest, which only runs where the schema corpus is present, has failed against them since. AWS::Events::Rule now declares RuleName, and AWS::RDS::DBSubnetGroup and AWS::RDS::DBParameterGroup declare DBSubnetGroupArn and DBParameterGroupArn. The provisioners set all three; until now Fn::GetAtt on them resolved to the literal LogicalId.Attribute string. The two RDS models already carry the ARN. AWS::RDS::DBInstance now declares StorageOperationStatus and StorageOperationPercentProgress, which Floci does not emulate, so both are recorded as gaps. AWS::CertificateManager::Certificate and AWS::Route53::RecordSet no longer declare Id, so their gap rows go.
This commit is contained in:
1 parent
69e371721b
commit
a0e3b6b674
7 files changed
+151
-2
No files matched your search
+1
@@ -141,6 +141,7 @@ public class EventsCfnProvisioner implements CfnResourceProvisioner {
|
||||
state, description, roleArn, Map.of(), ctx.region());
|
||||
r.setPhysicalId(ruleName);
|
||||
r.getAttributes().put("Arn", rule.getArn());
|
||||
r.getAttributes().put("RuleName", ruleName);
|
||||
// A rule on a custom bus is keyed by that bus; remember it so the resource delete can target
|
||||
// the right bus (the physical id is only the rule name, which resolves to the default bus).
|
||||
if (busName != null && !busName.isBlank()) {
|
||||
|
||||
+6
@@ -222,6 +222,9 @@ public class RdsCfnProvisioner implements CfnResourceProvisioner {
|
||||
}
|
||||
r.setPhysicalId(group.getDbSubnetGroupName());
|
||||
r.getAttributes().put("DBSubnetGroupName", group.getDbSubnetGroupName());
|
||||
if (group.getDbSubnetGroupArn() != null) {
|
||||
r.getAttributes().put("DBSubnetGroupArn", group.getDbSubnetGroupArn());
|
||||
}
|
||||
}
|
||||
|
||||
private void provisionDbParameterGroup(StackResource r, JsonNode props, CloudFormationTemplateEngine engine,
|
||||
@@ -254,6 +257,9 @@ public class RdsCfnProvisioner implements CfnResourceProvisioner {
|
||||
}
|
||||
r.setPhysicalId(group.getDbParameterGroupName());
|
||||
r.getAttributes().put("DBParameterGroupName", group.getDbParameterGroupName());
|
||||
if (group.getDbParameterGroupArn() != null) {
|
||||
r.getAttributes().put("DBParameterGroupArn", group.getDbParameterGroupArn());
|
||||
}
|
||||
}
|
||||
|
||||
private void provisionDbClusterParameterGroup(StackResource r, JsonNode props,
|
||||
|
||||
+57
@@ -1,5 +1,6 @@
|
||||
package io.github.hectorvent.floci.services.cloudformation;
|
||||
|
||||
import io.github.hectorvent.floci.core.common.XmlParser;
|
||||
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
@@ -7,8 +8,11 @@ import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
* Verifies CloudFormation provisions {@code AWS::Events::EventBus} as a real custom EventBridge bus.
|
||||
@@ -297,6 +301,59 @@ class CloudFormationEventBusIntegrationTest {
|
||||
.body(containsString("ResourceNotFoundException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void getAttRuleNameResolvesToTheRuleName() throws InterruptedException {
|
||||
String suffix = Long.toString(System.nanoTime(), 36);
|
||||
String ruleName = "cfn-rulename-" + suffix;
|
||||
String stackName = "rulename-stack-" + suffix;
|
||||
String template = """
|
||||
{
|
||||
"Resources": {
|
||||
"Named": {
|
||||
"Type": "AWS::Events::Rule",
|
||||
"Properties": {
|
||||
"Name": "%s",
|
||||
"EventPattern": { "source": ["com.example.orders"] }
|
||||
}
|
||||
},
|
||||
"Unnamed": {
|
||||
"Type": "AWS::Events::Rule",
|
||||
"Properties": {
|
||||
"EventPattern": { "source": ["com.example.orders"] }
|
||||
}
|
||||
}
|
||||
},
|
||||
"Outputs": {
|
||||
"NamedRuleName": { "Value": { "Fn::GetAtt": ["Named", "RuleName"] } },
|
||||
"UnnamedRuleName": { "Value": { "Fn::GetAtt": ["Unnamed", "RuleName"] } },
|
||||
"UnnamedRef": { "Value": { "Ref": "Unnamed" } }
|
||||
}
|
||||
}
|
||||
""".formatted(ruleName);
|
||||
|
||||
createStack(stackName, template);
|
||||
try {
|
||||
assertStackStatus(stackName, "CREATE_COMPLETE");
|
||||
String xml = given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.header("Authorization", CFN_AUTH)
|
||||
.formParam("Action", "DescribeStacks")
|
||||
.formParam("StackName", stackName)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.extract().asString();
|
||||
Map<String, String> outputs = XmlParser.extractPairs(xml, "Outputs", "OutputKey", "OutputValue");
|
||||
|
||||
assertEquals(ruleName, outputs.get("NamedRuleName"));
|
||||
assertEquals(outputs.get("UnnamedRef"), outputs.get("UnnamedRuleName"));
|
||||
} finally {
|
||||
deleteStack(stackName);
|
||||
awaitStackDeleted(stackName);
|
||||
}
|
||||
}
|
||||
|
||||
private void awaitStackDeleted(String stackName) throws InterruptedException {
|
||||
String lastBody = null;
|
||||
for (int i = 0; i < 100; i++) {
|
||||
|
||||
+78
@@ -5,6 +5,8 @@ import io.github.hectorvent.floci.services.ec2.Ec2Service;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
@@ -162,6 +164,82 @@ class CloudFormationRdsIntegrationTest {
|
||||
.body(containsString(groupName));
|
||||
}
|
||||
|
||||
@Test
|
||||
void getAttResolvesTheSubnetAndParameterGroupArns() {
|
||||
String suffix = Long.toString(System.nanoTime(), 36);
|
||||
String subnetGroupName = "cfn-rds-arn-subnets-" + suffix;
|
||||
String parameterGroupName = "cfn-rds-arn-params-" + suffix;
|
||||
String stackName = "cfn-rds-arn-stack-" + suffix;
|
||||
String template = """
|
||||
{
|
||||
"Resources": {
|
||||
"DbSubnets": {
|
||||
"Type": "AWS::RDS::DBSubnetGroup",
|
||||
"Properties": {
|
||||
"DBSubnetGroupName": "%s",
|
||||
"DBSubnetGroupDescription": "managed by cfn",
|
||||
"SubnetIds": ["%s", "%s"]
|
||||
}
|
||||
},
|
||||
"DbParams": {
|
||||
"Type": "AWS::RDS::DBParameterGroup",
|
||||
"Properties": {
|
||||
"DBParameterGroupName": "%s",
|
||||
"Family": "postgres16",
|
||||
"Description": "managed by cfn"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Outputs": {
|
||||
"SubnetGroupArn": {"Value": {"Fn::GetAtt": ["DbSubnets", "DBSubnetGroupArn"]}},
|
||||
"ParameterGroupArn": {"Value": {"Fn::GetAtt": ["DbParams", "DBParameterGroupArn"]}}
|
||||
}
|
||||
}
|
||||
""".formatted(subnetGroupName, Ec2Service.defaultSubnetId("us-east-1", "a"),
|
||||
Ec2Service.defaultSubnetId("us-east-1", "b"), parameterGroupName);
|
||||
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.header("Authorization", CFN_AUTH)
|
||||
.formParam("Action", "CreateStack")
|
||||
.formParam("StackName", stackName)
|
||||
.formParam("TemplateBody", template)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
|
||||
try {
|
||||
String xml = given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.header("Authorization", CFN_AUTH)
|
||||
.formParam("Action", "DescribeStacks")
|
||||
.formParam("StackName", stackName)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body(containsString("<StackStatus>CREATE_COMPLETE</StackStatus>"))
|
||||
.extract().asString();
|
||||
Map<String, String> outputs = XmlParser.extractPairs(xml, "Outputs", "OutputKey", "OutputValue");
|
||||
|
||||
assertEquals("arn:aws:rds:us-east-1:000000000000:subgrp:" + subnetGroupName,
|
||||
outputs.get("SubnetGroupArn"));
|
||||
assertEquals("arn:aws:rds:us-east-1:000000000000:pg:" + parameterGroupName,
|
||||
outputs.get("ParameterGroupArn"));
|
||||
} finally {
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.header("Authorization", CFN_AUTH)
|
||||
.formParam("Action", "DeleteStack")
|
||||
.formParam("StackName", stackName)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
}
|
||||
}
|
||||
|
||||
private static String dbSubnetGroupTemplate(String groupName) {
|
||||
return """
|
||||
{
|
||||
|
||||
+5
@@ -876,6 +876,7 @@ class RdsCfnProvisionerTest {
|
||||
void provisionsDbSubnetGroupWithResolvedSubnetIds() {
|
||||
DbSubnetGroup group = mock(DbSubnetGroup.class);
|
||||
when(group.getDbSubnetGroupName()).thenReturn("my-subnet-group");
|
||||
when(group.getDbSubnetGroupArn()).thenReturn("arn:aws:rds:us-east-1:000000000000:subgrp:my-subnet-group");
|
||||
when(rdsService.createDbSubnetGroup(any(), any(), anyList(), any())).thenReturn(group);
|
||||
|
||||
StackResource r = provision("Sg", "AWS::RDS::DBSubnetGroup", """
|
||||
@@ -885,6 +886,8 @@ class RdsCfnProvisionerTest {
|
||||
|
||||
assertEquals("my-subnet-group", r.getPhysicalId());
|
||||
assertEquals("my-subnet-group", r.getAttributes().get("DBSubnetGroupName"));
|
||||
assertEquals("arn:aws:rds:us-east-1:000000000000:subgrp:my-subnet-group",
|
||||
r.getAttributes().get("DBSubnetGroupArn"));
|
||||
verify(rdsService).createDbSubnetGroup("my-subnet-group", "db subnets",
|
||||
List.of("subnet-a", "subnet-b"), "us-east-1");
|
||||
}
|
||||
@@ -989,6 +992,7 @@ class RdsCfnProvisionerTest {
|
||||
void provisionsDbParameterGroup() {
|
||||
DbParameterGroup group = mock(DbParameterGroup.class);
|
||||
when(group.getDbParameterGroupName()).thenReturn("my-pg");
|
||||
when(group.getDbParameterGroupArn()).thenReturn("arn:aws:rds:us-east-1:000000000000:pg:my-pg");
|
||||
when(rdsService.createDbParameterGroup(any(), any(), any(), any())).thenReturn(group);
|
||||
|
||||
StackResource r = provision("Pg", "AWS::RDS::DBParameterGroup", """
|
||||
@@ -997,6 +1001,7 @@ class RdsCfnProvisionerTest {
|
||||
|
||||
assertEquals("my-pg", r.getPhysicalId());
|
||||
assertEquals("my-pg", r.getAttributes().get("DBParameterGroupName"));
|
||||
assertEquals("arn:aws:rds:us-east-1:000000000000:pg:my-pg", r.getAttributes().get("DBParameterGroupArn"));
|
||||
verify(rdsService).createDbParameterGroup(
|
||||
"my-pg", "postgres16", "params", "us-east-1");
|
||||
}
|
||||
|
||||
+2
@@ -87,6 +87,7 @@ class EventsCfnProvisionerTest {
|
||||
provisioner.provision(r, mapper.createObjectNode(), ctx("my-stack-Rule-ab12cd"));
|
||||
|
||||
assertEquals("my-stack-Rule-ab12cd", r.getPhysicalId());
|
||||
assertEquals("my-stack-Rule-ab12cd", r.getAttributes().get("RuleName"));
|
||||
verify(events).putRule(eq("my-stack-Rule-ab12cd"), any(), any(), any(), any(), any(), any(),
|
||||
any(), anyString());
|
||||
}
|
||||
@@ -100,6 +101,7 @@ class EventsCfnProvisionerTest {
|
||||
|
||||
assertEquals("orders", r.getPhysicalId());
|
||||
assertEquals(RULE_ARN, r.getAttributes().get("Arn"));
|
||||
assertEquals("orders", r.getAttributes().get("RuleName"));
|
||||
}
|
||||
|
||||
// ── targets are driven to the template's desired state ───────────────────
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
AWS::AppSync::GraphQLApi GraphQLEndpointArn the private-endpoint ARN of the GraphQL endpoint; Floci serves one public endpoint and has no private-endpoint model
|
||||
AWS::CertificateManager::Certificate Id schema gives no description; Ref returns the ARN and the legacy spec gives the type no attributes
|
||||
AWS::CodeBuild::Project Id schema gives no description; AWS's Id may differ from the project name Floci uses
|
||||
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
|
||||
@@ -46,8 +45,9 @@ AWS::RDS::DBInstance ReadReplicaDBInstanceIdentifiers read replicas are not emul
|
||||
AWS::RDS::DBInstance ResumeFullAutomationModeTime RDS Custom automation mode is not emulated
|
||||
AWS::RDS::DBInstance SecondaryAvailabilityZone multi-AZ secondary placement is not emulated
|
||||
AWS::RDS::DBInstance StatusInfos read-replica status detail is not emulated
|
||||
AWS::RDS::DBInstance StorageOperationPercentProgress storage operations (scaling, type changes) are not emulated; storage changes apply synchronously
|
||||
AWS::RDS::DBInstance StorageOperationStatus storage operations (scaling, type changes) are not emulated; storage changes apply synchronously
|
||||
AWS::Redshift::Cluster DeferMaintenanceIdentifier Floci does not emulate deferred maintenance windows
|
||||
AWS::Route53::RecordSet Id schema gives no description; Ref returns the record name and the legacy spec gives the type no attributes
|
||||
AWS::SQS::QueuePolicy Id schema gives no description; the policy has no backing entity to take an id from
|
||||
AWS::SecretsManager::Secret Id Fn::GetAtt Id on a secret is its ARN, which the provisioner already sets as the physical id and as Arn; closable, deferred to a follow-up PR to keep this one a pure move
|
||||
AWS::EKS::Cluster ClusterSecurityGroupId not modeled: Floci does not create a cluster security group, so there is no id to publish
|
||||
|
||||
|
Reference in new issue
Block a user