fix(codepipeline): link approval notifications to the partition's console host (#5595)

* fix(codepipeline): link approval notifications to the partition's console host

The approval-needed notification built consoleLink and approvalReviewLink on
the commercial console host for every pipeline, so a pipeline in China or
GovCloud sent its approver to a console where the pipeline does not exist.

The console host becomes a vendored per-partition fact, consoleHost in
aws/region-facts.json, read by the generator from the user-guide snapshots
under local/aws/aws-docs/partition-guides: cn/console.md for aws-cn
(console.amazonaws.cn), gov/configure-account.md for aws-us-gov
(console.amazonaws-us-gov.com) and gov/govcloud-organizations.md for the
commercial host. The China guide also spells the host console.www.amazonaws.cn
once, in cn/managing-aws.md; the console page's own statement is the one used.
A guide page that lost its sentence, or states two hosts with it, fails the
generation instead of leaving a stale value.

CodePipelineEventPublisher resolves the host from the execution's region, since
it runs on a worker thread without a request context. No source states a
console host for the ISO or EUSC partitions, which keep the commercial one and
are listed as an open question. The path after the host stays the commercial
console's: no source gives the per-service path per partition.

Signed-off-by: Hector Ventura <hectorvent@gmail.com>

* fix(codepipeline): parse the China console host from the Markdown guide page, require sourced hosts

AWS serves each user-guide page as Markdown at the same URL with .md in
place of .html, and that rendering writes the China console host as a
link, "[https://console.amazonaws.cn](https://console.amazonaws.cn).".
The aws-cn pattern only took the page-text form, so a snapshot saved
from the Markdown page failed the generator, and with it the rest of
"make aws-data-sync". The pattern now takes both forms.

The docstring names the three guide page URLs and the path each is
saved under.

self_check now requires consoleHost for the three partitions that have
a source (aws, aws-cn, aws-us-gov). The shape-only check used when the
sources are not checked out accepted a file without them, which would
link approval notifications to the commercial console.

Signed-off-by: Hector Ventura <hectorvent@gmail.com>

---------

Signed-off-by: Hector Ventura <hectorvent@gmail.com>
This commit is contained in:
Hector Ventura authored and GitHub committed 2026-10-13 23:02:27 -04:00
1 parent 94a801e05f
commit 8bd88bfb40
8 files changed
+233 -32

No files matched your search

@@ -13,9 +13,9 @@ import java.util.Set;
/**
* The per-region and per-partition constants AWS publishes only as prose tables, vendored in
* {@code aws/region-facts.json} by {@code tools/aws/regen_region_facts.py} from the Terraform
* provider and the CDK: load balancer and S3 website hosted zone ids, the CloudFront hosted
* zone per partition, the SAML sign-on URL per partition and the VPC endpoint service-name
* prefixes. Every accessor is {@link Optional}: the ISO and EUSC partitions have no published
* provider, the CDK and the China and GovCloud user guides: load balancer and S3 website hosted
* zone ids, the CloudFront hosted zone per partition, the SAML sign-on URL and the management
* console host per partition and the VPC endpoint service-name prefixes. Every accessor is {@link Optional}: the ISO and EUSC partitions have no published
* hosted zones, and a service that needs one there has nothing faithful to answer.
*/
public final class AwsRegionFacts {
@@ -58,6 +58,14 @@ public final class AwsRegionFacts {
return partitionText(partition, "samlSignOnUrl");
}
/**
* The management console host, without a scheme. Stated by the user guides for {@code aws},
* {@code aws-cn} and {@code aws-us-gov}; absent for the ISO partitions and {@code aws-eusc}.
*/
public static Optional<String> consoleHost(String partition) {
return partitionText(partition, "consoleHost");
}
/** {@code com.amazonaws.vpce}, {@code cn.com.amazonaws.vpce}, ...: the reversed DNS suffix plus {@code .vpce}. */
public static Optional<String> vpcEndpointServiceNamePrefix(String partition) {
return partitionText(partition, "vpcEndpointServiceNamePrefix");
@@ -4,6 +4,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import io.github.hectorvent.floci.core.common.AwsArnUtils;
import io.github.hectorvent.floci.core.common.AwsRegionFacts;
import io.github.hectorvent.floci.core.common.AwsRegions;
import io.github.hectorvent.floci.core.common.RequestScopes;
import io.github.hectorvent.floci.services.codepipeline.model.CodePipelineExecution;
import io.github.hectorvent.floci.services.codepipeline.model.CodePipelineExecution.ActionExecution;
@@ -31,7 +33,7 @@ public class CodePipelineEventPublisher {
private static final Logger LOG = Logger.getLogger(CodePipelineEventPublisher.class);
private static final int MAX_SNS_SUBJECT_LENGTH = 100;
private static final String CONSOLE_URL = "https://console.aws.amazon.com/codepipeline/home";
private static final String CONSOLE_PATH = "/codepipeline/home";
/** The approval message's {@code expires} is to the minute, e.g. 2016-07-07T20:22Z. */
private static final DateTimeFormatter MINUTE_FORMAT =
DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm'Z'").withZone(ZoneOffset.UTC);
@@ -107,7 +109,7 @@ public class CodePipelineEventPublisher {
String externalEntityLink, double expires) {
try {
ObjectNode message = mapper.createObjectNode();
String consoleLink = CONSOLE_URL + "?region=" + execution.getRegion()
String consoleLink = consoleUrl(execution.getRegion()) + "?region=" + execution.getRegion()
+ "#/view/" + execution.getPipelineName();
message.put("region", execution.getRegion());
message.put("consoleLink", consoleLink);
@@ -138,6 +140,20 @@ public class CodePipelineEventPublisher {
}
}
/**
* The CodePipeline console page on the console host of the pipeline's partition, derived
* from the execution's region because this runs with no request context. The user guides
* state the host for the commercial, China and GovCloud partitions; the ISO and EUSC
* partitions have no published one and keep the commercial host. The path is the commercial
* console's in every partition: no source gives the per-service path per partition.
*/
private static String consoleUrl(String region) {
String host = AwsRegionFacts.consoleHost(AwsRegions.partitionFor(region))
.or(() -> AwsRegionFacts.consoleHost(AwsRegions.DEFAULT_PARTITION))
.orElseThrow();
return "https://" + host + CONSOLE_PATH;
}
/** Epoch seconds (with fraction) as the ISO-8601 UTC timestamp CodePipeline emits, e.g. 2023-10-26T13:31:39.604Z. */
private static String isoTimestamp(double epochSeconds) {
return Instant.ofEpochMilli(Math.round(epochSeconds * 1000)).toString();