mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(cloudfront): store and return a distribution's ConnectionMode (#8934)
* fix(cloudfront): store and return a distribution's ConnectionMode * test(cloudfront): deploy the ConnectionMode stack with CfnRequests and check refusals store nothing
This commit is contained in:
1 parent
9a38bd0bd2
commit
afd3107151
9 files changed
+234
-1
No files matched your search
+4
@@ -523,6 +523,10 @@ public class CloudFrontCfnProvisioner implements CfnResourceProvisioner {
|
||||
config.setDefaultRootObject(cfnText(dc, "DefaultRootObject", engine));
|
||||
config.setHttpVersion(cfnTextOrDefault(dc, "HttpVersion", engine, "http2"));
|
||||
config.setPriceClass(cfnTextOrDefault(dc, "PriceClass", engine, "PriceClass_All"));
|
||||
String connectionMode = cfnText(dc, "ConnectionMode", engine);
|
||||
if (!connectionMode.isEmpty()) {
|
||||
config.setConnectionMode(connectionMode);
|
||||
}
|
||||
config.setAliases(cfnStringList(dc.path("Aliases"), engine));
|
||||
config.setOrigins(cfnOrigins(dc, engine));
|
||||
config.setDefaultCacheBehavior(cfnDefaultCacheBehavior(dc.path("DefaultCacheBehavior"), engine));
|
||||
|
||||
@@ -1964,6 +1964,9 @@ public class CloudFrontController {
|
||||
xml.raw(xmlViewerCertificate(cfg.getViewerCertificate()));
|
||||
xml.raw(xmlRestrictions(cfg.getGeoRestriction()));
|
||||
xml.raw(xmlLogging(cfg.getLogging()));
|
||||
if (cfg.getConnectionMode() != null) {
|
||||
xml.elem("ConnectionMode", cfg.getConnectionMode());
|
||||
}
|
||||
|
||||
return xml.build();
|
||||
}
|
||||
@@ -2409,6 +2412,9 @@ public class CloudFrontController {
|
||||
|
||||
xml.raw(xmlViewerCertificate(cfg != null ? cfg.getViewerCertificate() : null));
|
||||
xml.raw(xmlRestrictions(cfg != null ? cfg.getGeoRestriction() : null));
|
||||
if (cfg != null && cfg.getConnectionMode() != null) {
|
||||
xml.elem("ConnectionMode", cfg.getConnectionMode());
|
||||
}
|
||||
|
||||
xml.end("DistributionSummary");
|
||||
return xml.build();
|
||||
@@ -2673,6 +2679,7 @@ public class CloudFrontController {
|
||||
values.get("ContinuousDeploymentPolicyId"));
|
||||
cfg.setStaging("true".equalsIgnoreCase(
|
||||
values.getOrDefault("Staging", "false")));
|
||||
cfg.setConnectionMode(values.get("ConnectionMode"));
|
||||
|
||||
cfg.setOrigins(parseOrigins(body));
|
||||
cfg.setDefaultCacheBehavior(parseDefaultCacheBehavior(body));
|
||||
@@ -2750,7 +2757,8 @@ public class CloudFrontController {
|
||||
"WebACLId",
|
||||
"WebAclId",
|
||||
"ContinuousDeploymentPolicyId",
|
||||
"Staging" -> true;
|
||||
"Staging",
|
||||
"ConnectionMode" -> true;
|
||||
default -> false;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -90,6 +90,8 @@ public class CloudFrontService implements ServerCertificateReferenceProvider {
|
||||
"TLSv1.2_2025", "TLSv1.3_2025");
|
||||
/** The values {@code SSLSupportMethod} admits, the enumeration its shape declares. */
|
||||
private static final Set<String> SSL_SUPPORT_METHODS = Set.of("sni-only", "vip", "static-ip");
|
||||
/** The values {@code ConnectionMode} admits, the enumeration its shape declares. */
|
||||
private static final Set<String> CONNECTION_MODES = Set.of("direct", "tenant-only");
|
||||
/**
|
||||
* The forms a member declared {@code boolean} can carry, XML giving such a value as
|
||||
* {@code true}, {@code false}, {@code 1} or {@code 0}.
|
||||
@@ -245,6 +247,7 @@ public class CloudFrontService implements ServerCertificateReferenceProvider {
|
||||
validateResponseHeadersPolicyReferences(dist.getConfig(), null);
|
||||
validateTrustedKeyGroups(dist.getConfig());
|
||||
validateOriginAccessControls(dist.getConfig());
|
||||
validateConnectionMode(dist.getConfig());
|
||||
validateViewerCertificateSettings(dist.getConfig(), DistributionWrite.CREATE);
|
||||
applyDefaultCertificateProtocolVersion(dist.getConfig());
|
||||
return whileCertificatesHeld(dist.getConfig(), () -> {
|
||||
@@ -282,6 +285,7 @@ public class CloudFrontService implements ServerCertificateReferenceProvider {
|
||||
validateResponseHeadersPolicyReferences(updated.getConfig(), id);
|
||||
validateTrustedKeyGroups(updated.getConfig());
|
||||
validateOriginAccessControls(updated.getConfig());
|
||||
validateConnectionMode(updated.getConfig());
|
||||
validateViewerCertificateSettings(updated.getConfig(), DistributionWrite.UPDATE);
|
||||
applyDefaultCertificateProtocolVersion(updated.getConfig());
|
||||
return whileCertificatesHeld(updated.getConfig(), () -> {
|
||||
@@ -377,6 +381,23 @@ public class CloudFrontService implements ServerCertificateReferenceProvider {
|
||||
return parsed;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@code ConnectionMode} is held to the enumeration its shape declares, {@code direct} or
|
||||
* {@code tenant-only}. The member has no code of its own, so a value outside the set reads as
|
||||
* the {@code InvalidArgument} this service already answers a member outside its shape with, as
|
||||
* {@code SSLSupportMethod} does. An omitted mode is kept omitted: no published sentence says
|
||||
* which mode such a distribution reads back as, nor what a {@code tenant-only} distribution
|
||||
* does with a viewer certificate it leaves out, so neither is filled in here.
|
||||
*/
|
||||
private static void validateConnectionMode(DistributionConfig config) {
|
||||
if (config == null || config.getConnectionMode() == null) {
|
||||
return;
|
||||
}
|
||||
if (!CONNECTION_MODES.contains(config.getConnectionMode())) {
|
||||
throw new AwsException("InvalidArgument", "The ConnectionMode specified is not valid.", 400);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Which distribution write is being validated. The two differ in one answer, the code the
|
||||
* {@code SSLv3} with {@code sni-only} pair is refused with, which is the code the operation
|
||||
|
||||
@@ -26,6 +26,7 @@ public class DistributionConfig {
|
||||
private Map<String, Object> logging;
|
||||
private String continuousDeploymentPolicyId;
|
||||
private boolean staging;
|
||||
private String connectionMode;
|
||||
|
||||
public DistributionConfig() {}
|
||||
|
||||
@@ -82,4 +83,7 @@ public class DistributionConfig {
|
||||
|
||||
public boolean isStaging() { return staging; }
|
||||
public void setStaging(boolean staging) { this.staging = staging; }
|
||||
|
||||
public String getConnectionMode() { return connectionMode; }
|
||||
public void setConnectionMode(String connectionMode) { this.connectionMode = connectionMode; }
|
||||
}
|
||||
Reference in new issue
Block a user