fix(appconfig): keep environment monitors and report deployment sources (#6665)

CreateEnvironment dropped the Monitors it was sent, and StartDeployment
and GetDeployment never reported the deployed profile's name or
location. AWS documents all three on these operations.

- CreateEnvironment stores Monitors and environment reads return them.
  They are checked against AWS's limits (at most five; AlarmArn of 1 to
  2048 characters; AlarmRoleArn an IAM role ARN in any partition) and
  refused with BadRequestException before anything is stored. An
  environment created without monitors returns no Monitors member, as
  AWS's own example shows.
- StartDeployment records the profile's ConfigurationName and
  ConfigurationLocationUri, and GetDeployment returns them.
- Records stored by earlier builds load unchanged: the new members are
  omitted when absent, so their responses stay byte-identical.

A configuration profile created without Type still reports none: AWS
documents no default, and its CreateConfigurationProfile example returns
a null Type.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
This commit is contained in:
Jackson Price authored and GitHub committed 2026-10-26 14:24:27 -04:00
1 parent 4506645d0f
commit b280a7764a
9 files changed
+521 -2

No files matched your search

@@ -12,6 +12,7 @@ import software.amazon.awssdk.services.appconfigdata.model.StartConfigurationSes
import software.amazon.awssdk.services.appconfigdata.model.StartConfigurationSessionResponse;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -611,4 +612,69 @@ class AppConfigTest {
}
}
}
@Test
@Order(57)
@DisplayName("Environments return their monitors and deployments their profile's name and location")
void monitorsAndDeploymentSourceRoundTrip() {
String monitoredAppId = appConfig.createApplication(CreateApplicationRequest.builder()
.name(TestFixtures.uniqueName("monitored-app")).build()).id();
try {
Monitor withRole = Monitor.builder()
.alarmArn("arn:aws:cloudwatch:us-east-1:000000000000:alarm:configuration-errors")
.alarmRoleArn("arn:aws:iam::000000000000:role/appconfig-alarm-monitor")
.build();
Monitor withoutRole = Monitor.builder()
.alarmArn("arn:aws:cloudwatch:us-east-1:000000000000:alarm:configuration-latency")
.build();
CreateEnvironmentResponse monitored = appConfig.createEnvironment(CreateEnvironmentRequest.builder()
.applicationId(monitoredAppId).name("monitored").monitors(withRole, withoutRole).build());
assertThat(monitored.monitors()).containsExactly(withRole, withoutRole);
assertThat(appConfig.getEnvironment(GetEnvironmentRequest.builder()
.applicationId(monitoredAppId).environmentId(monitored.id()).build()).monitors())
.containsExactly(withRole, withoutRole);
assertThat(appConfig.createEnvironment(CreateEnvironmentRequest.builder()
.applicationId(monitoredAppId).name("unmonitored").build()).hasMonitors()).isFalse();
// Qualified: the imported BadRequestException is AppConfigData's, this one is AppConfig's.
assertThrows(software.amazon.awssdk.services.appconfig.model.BadRequestException.class,
() -> appConfig.createEnvironment(CreateEnvironmentRequest.builder()
.applicationId(monitoredAppId).name("refused")
.monitors(Collections.nCopies(6, withoutRole)).build()));
String profileId = appConfig.createConfigurationProfile(CreateConfigurationProfileRequest.builder()
.applicationId(monitoredAppId)
.name("service-settings")
.locationUri("ssm-parameter://service-settings")
.type("AWS.Freeform")
.build()).id();
StartDeploymentResponse started = appConfig.startDeployment(StartDeploymentRequest.builder()
.applicationId(monitoredAppId)
.environmentId(monitored.id())
.configurationProfileId(profileId)
.configurationVersion("1")
.deploymentStrategyId("AppConfig.AllAtOnce")
.build());
assertThat(started.configurationName()).isEqualTo("service-settings");
assertThat(started.configurationLocationUri()).isEqualTo("ssm-parameter://service-settings");
GetDeploymentResponse deployment = appConfig.getDeployment(GetDeploymentRequest.builder()
.applicationId(monitoredAppId)
.environmentId(monitored.id())
.deploymentNumber(started.deploymentNumber())
.build());
assertThat(deployment.configurationName()).isEqualTo("service-settings");
assertThat(deployment.configurationLocationUri()).isEqualTo("ssm-parameter://service-settings");
// AWS documents no default Type: a profile created without one reports none.
assertThat(appConfig.createConfigurationProfile(CreateConfigurationProfileRequest.builder()
.applicationId(monitoredAppId).name("untyped").locationUri("hosted").build()).type()).isNull();
} finally {
try {
appConfig.deleteApplication(DeleteApplicationRequest.builder().applicationId(monitoredAppId).build());
} catch (Exception ignored) {
// Best-effort cleanup: the application name is unique, so a leftover cannot affect other tests.
}
}
}
}