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

@@ -50,6 +50,17 @@ class AwsRegionFactsTest {
assertTrue(AwsRegionFacts.samlSignOnUrl(null).isEmpty());
}
/** The hosts the China and GovCloud user guides state; no guide covers the ISO or EUSC partitions. */
@Test
void consoleHostIsPerPartitionWhereAGuideStatesIt() {
assertEquals(Optional.of("console.aws.amazon.com"), AwsRegionFacts.consoleHost("aws"));
assertEquals(Optional.of("console.amazonaws.cn"), AwsRegionFacts.consoleHost("aws-cn"));
assertEquals(Optional.of("console.amazonaws-us-gov.com"), AwsRegionFacts.consoleHost("aws-us-gov"));
assertTrue(AwsRegionFacts.consoleHost("aws-iso").isEmpty());
assertTrue(AwsRegionFacts.consoleHost("aws-eusc").isEmpty());
assertTrue(AwsRegionFacts.consoleHost(null).isEmpty());
}
@ParameterizedTest
@CsvSource({
"us-east-1, s3, com.amazonaws.us-east-1.s3",
@@ -8,6 +8,8 @@ import io.github.hectorvent.floci.services.eventbridge.EventBridgeService;
import io.github.hectorvent.floci.services.sns.SnsService;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
@@ -18,12 +20,16 @@ import java.util.Map;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.Mockito.verify;
/**
* Unit tests for {@link CodePipelineEventPublisher#actionStateChange}'s execution-result
* shape, pinned at the entry handed to {@code eventBridgeService.putEvents} so a regression
* in the optional-field guards is caught even though the event delivery itself is best-effort.
* in the optional-field guards is caught even though the event delivery itself is best-effort,
* and for the approval notification's console links, pinned at the message handed to
* {@code snsService.publish}.
*/
@ExtendWith(MockitoExtension.class)
class CodePipelineEventPublisherTest {
@@ -83,6 +89,41 @@ class CodePipelineEventPublisherTest {
assertFalse(detail.path("execution-result").has("error-code"));
}
/**
* The console host follows the pipeline's partition where a user guide states one; EUSC and
* ISO have no published host and keep the commercial one.
*/
@ParameterizedTest
@CsvSource({
"us-east-1, console.aws.amazon.com",
"cn-north-1, console.amazonaws.cn",
"us-gov-west-1, console.amazonaws-us-gov.com",
"eusc-de-east-1, console.aws.amazon.com",
"us-iso-east-1, console.aws.amazon.com"})
void approvalLinksUseTheConsoleHostOfThePipelinesPartition(String region, String host) throws Exception {
CodePipelineEventPublisher publisher =
new CodePipelineEventPublisher(eventBridgeService, snsService, MAPPER);
CodePipelineExecution execution = new CodePipelineExecution();
execution.setRegion(region);
execution.setAccountId("000000000000");
execution.setPipelineName("release");
ActionExecution action = new ActionExecution();
action.setStageName("Gate");
action.setActionName("Approve");
action.setToken("token-1");
publisher.approvalNeeded(execution, action, "topic-arn", null, null, 1700000000);
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
verify(snsService).publish(eq("topic-arn"), isNull(), captor.capture(), any(), eq(region));
JsonNode message = MAPPER.readTree(captor.getValue());
String consoleLink = "https://" + host + "/codepipeline/home?region=" + region + "#/view/release";
assertEquals(consoleLink, message.path("consoleLink").asText());
assertEquals(consoleLink + "/Gate/Approve/approve/token-1",
message.path("approval").path("approvalReviewLink").asText());
}
@Test
@SuppressWarnings("unchecked")
void startTimeKeepsTheMillisecondsOfTheStoredStartTime() throws Exception {