mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 22:11:36 -05:00
refactor(cloudformation): move AWS::Route53::RecordSet into Route53CfnProvisioner (#3724)
* refactor(cloudformation): move AWS::Route53::RecordSet into Route53CfnProvisioner The record set leaves CloudFormationResourceProvisioner for the provisioner that already owns AWS::Route53::HostedZone, which gains a type switch in provision and delete; the hosted-zone path is untouched. The record-set arm keeps the legacy behaviour exactly, a name-only resource whose Ref is the resolved Name or a generated record- id, and now also publishes Id, the registry schema's only read-only property, which Fn::GetAtt could never resolve before. Its delete logs the same warning the legacy default arm did, since nothing was ever written for the record. Writing the record through ChangeResourceRecordSets and enforcing the schema's required Type and Name are follow-ups, not part of the move. The legacy switch goes from 24 to 23 types and the monolith loses its last Route53 reference. * refactor(cloudformation): keep AWS::Route53::RecordSet free of GetAtt attributes The move published Id because the schema coverage gate asks for every read-only property in the registry schema. That schema has no handlers: RecordSet is a legacy type, and the CloudFormation resource specification gives it no attributes, so Ref stays its only reference, as it was in the legacy provisioner. Id is recorded in getatt-attribute-gaps.tsv instead.
This commit is contained in:
1 parent
f7565dff3e
commit
9cd27190ff
6 files changed
+243
-11
No files matched your search
+1
-8
@@ -134,8 +134,7 @@ public class CloudFormationResourceProvisioner {
|
||||
"AWS::IAM::ManagedPolicy",
|
||||
"AWS::IAM::Policy",
|
||||
"AWS::Lambda::Function",
|
||||
"AWS::Lambda::LayerVersion",
|
||||
"AWS::Route53::RecordSet");
|
||||
"AWS::Lambda::LayerVersion");
|
||||
|
||||
/** Reserved attribute keys used to carry custom-resource state to the later Delete invocation. */
|
||||
private static final String CR_SERVICE_TOKEN_ATTR = "__FlociServiceToken";
|
||||
@@ -245,7 +244,6 @@ public class CloudFormationResourceProvisioner {
|
||||
case "AWS::IAM::ManagedPolicy" ->
|
||||
provisionIamManagedPolicy(resource, properties, engine, accountId, stackName);
|
||||
case "AWS::IAM::InstanceProfile" -> provisionInstanceProfile(resource, properties, engine, accountId, stackName);
|
||||
case "AWS::Route53::RecordSet" -> provisionRoute53RecordSet(resource, properties, engine);
|
||||
case "AWS::ApiGateway::RestApi" -> provisionApiGatewayRestApi(resource, properties, engine, region, accountId, stackName);
|
||||
case "AWS::ApiGateway::Resource" -> provisionApiGatewayResource(resource, properties, engine, region);
|
||||
case "AWS::ApiGateway::Authorizer" -> provisionApiGatewayAuthorizer(resource, properties, engine, region);
|
||||
@@ -1962,11 +1960,6 @@ public class CloudFormationResourceProvisioner {
|
||||
}
|
||||
}
|
||||
|
||||
private void provisionRoute53RecordSet(StackResource r, JsonNode props, CloudFormationTemplateEngine engine) {
|
||||
String name = resolveOptional(props, "Name", engine);
|
||||
r.setPhysicalId(name != null ? name : "record-" + UUID.randomUUID().toString().substring(0, 8));
|
||||
}
|
||||
|
||||
// ── ApiGateway (V1) ──────────────────────────────────────────────────────
|
||||
|
||||
private void provisionApiGatewayRestApi(StackResource r, JsonNode props, CloudFormationTemplateEngine engine,
|
||||
|
||||
+44
-2
@@ -7,14 +7,32 @@ import io.github.hectorvent.floci.services.route53.Route53Service;
|
||||
import io.github.hectorvent.floci.services.route53.model.VpcAssociation;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Provisions {@code AWS::Route53::HostedZone} and {@code AWS::Route53::RecordSet}.
|
||||
*
|
||||
* <p>A record set is a name-only resource here, as it was in the legacy
|
||||
* {@code CloudFormationResourceProvisioner} it moved out of: nothing is written to the zone,
|
||||
* {@code Ref} is the record name (or a generated {@code record-} id when the template gives
|
||||
* none), and no {@code Fn::GetAtt} attribute is published. The registry schema lists {@code Id}
|
||||
* as read-only, but the type has no registry handlers and the CloudFormation resource
|
||||
* specification gives it no attributes, so {@code Ref} is its only reference. Writing the record
|
||||
* through {@code ChangeResourceRecordSets} is a follow-up.
|
||||
*/
|
||||
@ApplicationScoped
|
||||
public class Route53CfnProvisioner implements CfnResourceProvisioner {
|
||||
static final String HOSTED_ZONE = "AWS::Route53::HostedZone";
|
||||
static final String RECORD_SET = "AWS::Route53::RecordSet";
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(Route53CfnProvisioner.class);
|
||||
|
||||
private final Route53Service route53Service;
|
||||
|
||||
@Inject
|
||||
@@ -24,11 +42,26 @@ public class Route53CfnProvisioner implements CfnResourceProvisioner {
|
||||
|
||||
@Override
|
||||
public Set<String> resourceTypes() {
|
||||
return Set.of("AWS::Route53::HostedZone");
|
||||
return Set.of(HOSTED_ZONE, RECORD_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void provision(StackResource resource, JsonNode props, ProvisionContext ctx) {
|
||||
switch (resource.getResourceType()) {
|
||||
case "AWS::Route53::HostedZone" -> provisionHostedZone(resource, props, ctx);
|
||||
case "AWS::Route53::RecordSet" -> provisionRecordSet(resource, props, ctx);
|
||||
default -> throw new IllegalStateException(
|
||||
"Route53CfnProvisioner received an unsupported type: " + resource.getResourceType());
|
||||
}
|
||||
}
|
||||
|
||||
private void provisionRecordSet(StackResource resource, JsonNode props, ProvisionContext ctx) {
|
||||
String name = ctx.resolveOptional(props, "Name");
|
||||
String id = name != null ? name : "record-" + UUID.randomUUID().toString().substring(0, 8);
|
||||
resource.setPhysicalId(id);
|
||||
}
|
||||
|
||||
private void provisionHostedZone(StackResource resource, JsonNode props, ProvisionContext ctx) {
|
||||
String name = ctx.resolveOptional(props, "Name");
|
||||
if (name == null || name.isBlank()) {
|
||||
throw new IllegalArgumentException("AWS::Route53::HostedZone requires Name");
|
||||
@@ -126,7 +159,16 @@ public class Route53CfnProvisioner implements CfnResourceProvisioner {
|
||||
|
||||
@Override
|
||||
public void delete(String resourceType, String physicalId, String region) {
|
||||
route53Service.deleteHostedZone(physicalId);
|
||||
switch (resourceType) {
|
||||
case "AWS::Route53::HostedZone" -> route53Service.deleteHostedZone(physicalId);
|
||||
// Nothing was written for the record, so there is nothing to remove; the warning
|
||||
// mirrors the legacy dispatcher's default arm so the gap stays visible in the log.
|
||||
case "AWS::Route53::RecordSet" -> LOG.warnv(
|
||||
"No delete implemented for resource type {0}: {1} is not removed here.",
|
||||
resourceType, physicalId);
|
||||
default -> throw new IllegalStateException(
|
||||
"Route53CfnProvisioner received an unsupported type: " + resourceType);
|
||||
}
|
||||
}
|
||||
|
||||
private List<VpcAssociation> parseVpcs(JsonNode node) {
|
||||
|
||||
Reference in new issue
Block a user