From e4a2a75b3af330acb078e9c39774ecd15c2b3cdd Mon Sep 17 00:00:00 2001 From: bennettn4 Date: Tue, 22 Oct 2024 18:10:30 -0400 Subject: [PATCH 01/22] add configuration for azure environment --- .../common/utils/LandingZoneFlightBeanBag.java | 7 +++++++ .../library/AzureCredentialsProvider.java | 5 ++++- .../library/LandingZoneManagerProvider.java | 8 ++++++-- .../LandingZoneAzureConfiguration.java | 17 +++++++++++++++++ .../flight/create/CreateLandingZoneFlight.java | 2 +- 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/library/src/main/java/bio/terra/landingzone/common/utils/LandingZoneFlightBeanBag.java b/library/src/main/java/bio/terra/landingzone/common/utils/LandingZoneFlightBeanBag.java index 90ec49a98..72794e10f 100644 --- a/library/src/main/java/bio/terra/landingzone/common/utils/LandingZoneFlightBeanBag.java +++ b/library/src/main/java/bio/terra/landingzone/common/utils/LandingZoneFlightBeanBag.java @@ -4,6 +4,7 @@ import bio.terra.landingzone.library.AzureCredentialsProvider; import bio.terra.landingzone.library.LandingZoneManagerProvider; import bio.terra.landingzone.library.configuration.AzureCustomerUsageConfiguration; +import bio.terra.landingzone.library.configuration.LandingZoneAzureConfiguration; import bio.terra.landingzone.library.configuration.LandingZoneProtectedDataConfiguration; import bio.terra.landingzone.library.configuration.LandingZoneTestingConfiguration; import bio.terra.landingzone.service.bpm.LandingZoneBillingProfileManagerService; @@ -28,6 +29,8 @@ public class LandingZoneFlightBeanBag { private final ParametersResolverProvider parametersResolverProvider; private final AzureCustomerUsageConfiguration azureCustomerUsageConfiguration; private final AzureCredentialsProvider azureCredentialsProvider; + private final LandingZoneAzureConfiguration azureConfiguration; + @Lazy @Autowired @@ -42,6 +45,7 @@ public LandingZoneFlightBeanBag( ParametersResolverProvider parametersResolverProvider, AzureCustomerUsageConfiguration azureCustomerUsageConfiguration, AzureCredentialsProvider azureCredentialsProvider, + LandingZoneAzureConfiguration azureConfiguration, ObjectMapper objectMapper) { this.landingZoneService = landingZoneService; this.landingZoneDao = landingZoneDao; @@ -53,6 +57,7 @@ public LandingZoneFlightBeanBag( this.parametersResolverProvider = parametersResolverProvider; this.azureCustomerUsageConfiguration = azureCustomerUsageConfiguration; this.azureCredentialsProvider = azureCredentialsProvider; + this.azureConfiguration = azureConfiguration; this.objectMapper = objectMapper; } @@ -103,4 +108,6 @@ public AzureCustomerUsageConfiguration getAzureCustomerUsageConfiguration() { public AzureCredentialsProvider getAzureCredentialsProvider() { return azureCredentialsProvider; } + + public LandingZoneAzureConfiguration getAzureConfiguration() {return azureConfiguration;} } diff --git a/library/src/main/java/bio/terra/landingzone/library/AzureCredentialsProvider.java b/library/src/main/java/bio/terra/landingzone/library/AzureCredentialsProvider.java index ae94d85f1..261af11eb 100644 --- a/library/src/main/java/bio/terra/landingzone/library/AzureCredentialsProvider.java +++ b/library/src/main/java/bio/terra/landingzone/library/AzureCredentialsProvider.java @@ -33,12 +33,15 @@ public TokenCredential getTokenCredential() { && Objects.nonNull(azureConfiguration.getManagedAppClientSecret()) && Objects.nonNull(azureConfiguration.getManagedAppClientId())) { return new ClientSecretCredentialBuilder() + .authorityHost(azureConfiguration.getAzureEnvironment().getActiveDirectoryEndpoint()) .clientId(azureConfiguration.getManagedAppClientId()) .clientSecret(azureConfiguration.getManagedAppClientSecret()) .tenantId(azureConfiguration.getManagedAppTenantId()) .build(); } - return new DefaultAzureCredentialBuilder().build(); + return new DefaultAzureCredentialBuilder() + .authorityHost(azureConfiguration.getAzureEnvironment().getActiveDirectoryEndpoint()) + .build(); } } diff --git a/library/src/main/java/bio/terra/landingzone/library/LandingZoneManagerProvider.java b/library/src/main/java/bio/terra/landingzone/library/LandingZoneManagerProvider.java index 0a5d43d82..a3ad91bbc 100644 --- a/library/src/main/java/bio/terra/landingzone/library/LandingZoneManagerProvider.java +++ b/library/src/main/java/bio/terra/landingzone/library/LandingZoneManagerProvider.java @@ -1,6 +1,7 @@ package bio.terra.landingzone.library; import bio.terra.landingzone.library.configuration.AzureCustomerUsageConfiguration; +import bio.terra.landingzone.library.configuration.LandingZoneAzureConfiguration; import bio.terra.landingzone.library.landingzones.management.LandingZoneManager; import bio.terra.landingzone.model.LandingZoneTarget; import com.azure.core.credential.TokenCredential; @@ -15,13 +16,16 @@ public class LandingZoneManagerProvider { private AzureCustomerUsageConfiguration azureCustomerUsageConfiguration; private final AzureCredentialsProvider azureCredentialsProvider; + private final LandingZoneAzureConfiguration azureConfiguration; @Autowired public LandingZoneManagerProvider( AzureCustomerUsageConfiguration azureCustomerUsageConfiguration, - AzureCredentialsProvider azureCredentialsProvider) { + AzureCredentialsProvider azureCredentialsProvider, + LandingZoneAzureConfiguration azureConfiguration) { this.azureCustomerUsageConfiguration = azureCustomerUsageConfiguration; this.azureCredentialsProvider = azureCredentialsProvider; + this.azureConfiguration = azureConfiguration; } public LandingZoneManager createLandingZoneManager(LandingZoneTarget landingZoneTarget) { @@ -38,7 +42,7 @@ public AzureProfile createAzureProfile(LandingZoneTarget landingZoneTarget) { return new AzureProfile( landingZoneTarget.azureTenantId(), landingZoneTarget.azureSubscriptionId(), - AzureEnvironment.AZURE); + azureConfiguration.getAzureEnvironment()); } public AzureResourceManager createAzureResourceManagerClient( diff --git a/library/src/main/java/bio/terra/landingzone/library/configuration/LandingZoneAzureConfiguration.java b/library/src/main/java/bio/terra/landingzone/library/configuration/LandingZoneAzureConfiguration.java index 1c5012fd0..f951a1dea 100644 --- a/library/src/main/java/bio/terra/landingzone/library/configuration/LandingZoneAzureConfiguration.java +++ b/library/src/main/java/bio/terra/landingzone/library/configuration/LandingZoneAzureConfiguration.java @@ -1,5 +1,6 @@ package bio.terra.landingzone.library.configuration; +import com.azure.core.management.AzureEnvironment; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Configuration; @@ -10,6 +11,7 @@ public class LandingZoneAzureConfiguration { private String managedAppClientId; private String managedAppClientSecret; private String managedAppTenantId; + private String azureEnvironment; public String getManagedAppClientId() { return managedAppClientId; @@ -34,4 +36,19 @@ public String getManagedAppTenantId() { public void setManagedAppTenantId(String managedAppTenantId) { this.managedAppTenantId = managedAppTenantId; } + + public AzureEnvironment getAzureEnvironment() { + switch (azureEnvironment) { + case "AZURE": + return AzureEnvironment.AZURE; + case "AZURE_GOV": + return AzureEnvironment.AZURE_US_GOVERNMENT; + default: + throw new IllegalArgumentException(String.format("Unknown Azure environment: %s", azureEnvironment)); + } + } + + public void setAzureEnvironment(String azureEnvironment) { + this.azureEnvironment = azureEnvironment; + } } diff --git a/library/src/main/java/bio/terra/landingzone/stairway/flight/create/CreateLandingZoneFlight.java b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/CreateLandingZoneFlight.java index 6ba3bd256..e6633125d 100644 --- a/library/src/main/java/bio/terra/landingzone/stairway/flight/create/CreateLandingZoneFlight.java +++ b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/CreateLandingZoneFlight.java @@ -112,7 +112,7 @@ protected ArmManagers getArmManagers( new AzureProfile( landingZoneTarget.azureTenantId(), landingZoneTarget.azureSubscriptionId(), - AzureEnvironment.AZURE); + flightBeanBag.getAzureConfiguration().getAzureEnvironment()); return LandingZoneManager.createArmManagers( flightBeanBag.getAzureCredentialsProvider().getTokenCredential(), azureProfile, From 96f92ed72280c8200369692819f755ea9686ca23 Mon Sep 17 00:00:00 2001 From: bennettn4 Date: Tue, 22 Oct 2024 18:18:20 -0400 Subject: [PATCH 02/22] Update application.yml --- service/src/main/resources/application.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/service/src/main/resources/application.yml b/service/src/main/resources/application.yml index 948f2dbec..e156269d1 100644 --- a/service/src/main/resources/application.yml +++ b/service/src/main/resources/application.yml @@ -33,6 +33,8 @@ spring: #since LZ is amalgamated we need to inherit "workspace" prefix. later it should be changed to landingzone. workspace: + azure: + azureEnvironment: AZURE ingress: # Default value that's overridden by Helm. domain-name: localhost:8080 From ba0a805623dee183a30a8dad0a91589d2515c883 Mon Sep 17 00:00:00 2001 From: Jonathon Saunders Date: Tue, 22 Oct 2024 15:42:37 -0700 Subject: [PATCH 03/22] spotless --- .../common/utils/LandingZoneFlightBeanBag.java | 7 ++++--- .../library/AzureCredentialsProvider.java | 4 ++-- .../library/LandingZoneManagerProvider.java | 1 - .../LandingZoneAzureConfiguration.java | 17 +++++++++-------- .../flight/create/CreateLandingZoneFlight.java | 1 - 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/library/src/main/java/bio/terra/landingzone/common/utils/LandingZoneFlightBeanBag.java b/library/src/main/java/bio/terra/landingzone/common/utils/LandingZoneFlightBeanBag.java index 72794e10f..973f3c2ec 100644 --- a/library/src/main/java/bio/terra/landingzone/common/utils/LandingZoneFlightBeanBag.java +++ b/library/src/main/java/bio/terra/landingzone/common/utils/LandingZoneFlightBeanBag.java @@ -31,7 +31,6 @@ public class LandingZoneFlightBeanBag { private final AzureCredentialsProvider azureCredentialsProvider; private final LandingZoneAzureConfiguration azureConfiguration; - @Lazy @Autowired public LandingZoneFlightBeanBag( @@ -57,7 +56,7 @@ public LandingZoneFlightBeanBag( this.parametersResolverProvider = parametersResolverProvider; this.azureCustomerUsageConfiguration = azureCustomerUsageConfiguration; this.azureCredentialsProvider = azureCredentialsProvider; - this.azureConfiguration = azureConfiguration; + this.azureConfiguration = azureConfiguration; this.objectMapper = objectMapper; } @@ -109,5 +108,7 @@ public AzureCredentialsProvider getAzureCredentialsProvider() { return azureCredentialsProvider; } - public LandingZoneAzureConfiguration getAzureConfiguration() {return azureConfiguration;} + public LandingZoneAzureConfiguration getAzureConfiguration() { + return azureConfiguration; + } } diff --git a/library/src/main/java/bio/terra/landingzone/library/AzureCredentialsProvider.java b/library/src/main/java/bio/terra/landingzone/library/AzureCredentialsProvider.java index 261af11eb..6212c18d0 100644 --- a/library/src/main/java/bio/terra/landingzone/library/AzureCredentialsProvider.java +++ b/library/src/main/java/bio/terra/landingzone/library/AzureCredentialsProvider.java @@ -41,7 +41,7 @@ public TokenCredential getTokenCredential() { } return new DefaultAzureCredentialBuilder() - .authorityHost(azureConfiguration.getAzureEnvironment().getActiveDirectoryEndpoint()) - .build(); + .authorityHost(azureConfiguration.getAzureEnvironment().getActiveDirectoryEndpoint()) + .build(); } } diff --git a/library/src/main/java/bio/terra/landingzone/library/LandingZoneManagerProvider.java b/library/src/main/java/bio/terra/landingzone/library/LandingZoneManagerProvider.java index a3ad91bbc..ca552f02c 100644 --- a/library/src/main/java/bio/terra/landingzone/library/LandingZoneManagerProvider.java +++ b/library/src/main/java/bio/terra/landingzone/library/LandingZoneManagerProvider.java @@ -5,7 +5,6 @@ import bio.terra.landingzone.library.landingzones.management.LandingZoneManager; import bio.terra.landingzone.model.LandingZoneTarget; import com.azure.core.credential.TokenCredential; -import com.azure.core.management.AzureEnvironment; import com.azure.core.management.profile.AzureProfile; import com.azure.resourcemanager.AzureResourceManager; import org.jetbrains.annotations.NotNull; diff --git a/library/src/main/java/bio/terra/landingzone/library/configuration/LandingZoneAzureConfiguration.java b/library/src/main/java/bio/terra/landingzone/library/configuration/LandingZoneAzureConfiguration.java index f951a1dea..084de0654 100644 --- a/library/src/main/java/bio/terra/landingzone/library/configuration/LandingZoneAzureConfiguration.java +++ b/library/src/main/java/bio/terra/landingzone/library/configuration/LandingZoneAzureConfiguration.java @@ -38,14 +38,15 @@ public void setManagedAppTenantId(String managedAppTenantId) { } public AzureEnvironment getAzureEnvironment() { - switch (azureEnvironment) { - case "AZURE": - return AzureEnvironment.AZURE; - case "AZURE_GOV": - return AzureEnvironment.AZURE_US_GOVERNMENT; - default: - throw new IllegalArgumentException(String.format("Unknown Azure environment: %s", azureEnvironment)); - } + switch (azureEnvironment) { + case "AZURE": + return AzureEnvironment.AZURE; + case "AZURE_GOV": + return AzureEnvironment.AZURE_US_GOVERNMENT; + default: + throw new IllegalArgumentException( + String.format("Unknown Azure environment: %s", azureEnvironment)); + } } public void setAzureEnvironment(String azureEnvironment) { diff --git a/library/src/main/java/bio/terra/landingzone/stairway/flight/create/CreateLandingZoneFlight.java b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/CreateLandingZoneFlight.java index e6633125d..4546f1586 100644 --- a/library/src/main/java/bio/terra/landingzone/stairway/flight/create/CreateLandingZoneFlight.java +++ b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/CreateLandingZoneFlight.java @@ -15,7 +15,6 @@ import bio.terra.landingzone.stairway.flight.exception.LandingZoneCreateException; import bio.terra.profile.model.ProfileModel; import bio.terra.stairway.*; -import com.azure.core.management.AzureEnvironment; import com.azure.core.management.profile.AzureProfile; import java.util.UUID; From 9b24a8bf137803915222516ca8c07b5e6d4d7f3f Mon Sep 17 00:00:00 2001 From: Jonathon Saunders Date: Tue, 22 Oct 2024 16:29:21 -0700 Subject: [PATCH 04/22] Update settings.gradle --- settings.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.gradle b/settings.gradle index 12ddd7120..921d4d318 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,6 +1,6 @@ rootProject.name = 'terra-landing-zone-service' include('service','library', 'scripts') -gradle.ext.releaseVersion = "0.0.367-SNAPSHOT" +gradle.ext.releaseVersion = "0.0.367-DEV" include 'client' From 1556167dfc01cc40f13e9db04e412332e4ad98a5 Mon Sep 17 00:00:00 2001 From: bennettn4 Date: Wed, 23 Oct 2024 11:08:40 -0400 Subject: [PATCH 05/22] Update build.gradle --- buildSrc/build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index ee9fd3b85..adc6738cf 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -1,5 +1,6 @@ plugins { id 'groovy-gradle-plugin' + id 'maven-publish' } repositories { From 313222f16ad34de19c763fe71658b9e8742cd8c6 Mon Sep 17 00:00:00 2001 From: bennettn4 Date: Wed, 23 Oct 2024 11:18:28 -0400 Subject: [PATCH 06/22] maven local --- buildSrc/build.gradle | 1 - service/build.gradle | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index adc6738cf..ee9fd3b85 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -1,6 +1,5 @@ plugins { id 'groovy-gradle-plugin' - id 'maven-publish' } repositories { diff --git a/service/build.gradle b/service/build.gradle index 6d95c55f2..ad0e7470b 100644 --- a/service/build.gradle +++ b/service/build.gradle @@ -5,6 +5,7 @@ plugins { id 'com.srcclr.gradle' id 'com.gorylenko.gradle-git-properties' version '2.4.2' id "au.com.dius.pact" version "4.6.14" + id 'maven-publish' } project.ext { From 7f52d67fe1efac2dfecb1b4b1d3796489a7d1aac Mon Sep 17 00:00:00 2001 From: bennettn4 Date: Wed, 23 Oct 2024 12:43:20 -0400 Subject: [PATCH 07/22] Update build.gradle --- service/build.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/service/build.gradle b/service/build.gradle index ad0e7470b..6d95c55f2 100644 --- a/service/build.gradle +++ b/service/build.gradle @@ -5,7 +5,6 @@ plugins { id 'com.srcclr.gradle' id 'com.gorylenko.gradle-git-properties' version '2.4.2' id "au.com.dius.pact" version "4.6.14" - id 'maven-publish' } project.ext { From 5f75618000a653bdbd48ed3b310787fbad47e5ac Mon Sep 17 00:00:00 2001 From: bennettn4 Date: Tue, 29 Oct 2024 10:27:12 -0400 Subject: [PATCH 08/22] Update CreatePostgresqlDNSStep.java --- .../step/postgres/CreatePostgresqlDNSStep.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/library/src/main/java/bio/terra/landingzone/stairway/flight/create/resource/step/postgres/CreatePostgresqlDNSStep.java b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/resource/step/postgres/CreatePostgresqlDNSStep.java index a4815a560..2b8e22827 100644 --- a/library/src/main/java/bio/terra/landingzone/stairway/flight/create/resource/step/postgres/CreatePostgresqlDNSStep.java +++ b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/resource/step/postgres/CreatePostgresqlDNSStep.java @@ -1,5 +1,6 @@ package bio.terra.landingzone.stairway.flight.create.resource.step.postgres; +import bio.terra.landingzone.common.utils.LandingZoneFlightBeanBag; import bio.terra.landingzone.library.landingzones.definition.ArmManagers; import bio.terra.landingzone.library.landingzones.definition.ResourceNameGenerator; import bio.terra.landingzone.library.landingzones.deployment.LandingZoneTagKeys; @@ -13,6 +14,8 @@ import java.util.Map; import java.util.Optional; import java.util.UUID; + +import com.azure.core.management.AzureEnvironment; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -21,6 +24,7 @@ public class CreatePostgresqlDNSStep extends BaseResourceCreateStep { public static final String POSTGRESQL_DNS_ID = "POSTGRESQL_DNS_ID"; public static final String POSTGRESQL_DNS_RESOURCE_KEY = "POSTGRESQL_DNS"; public static final String POSTGRES_DNS_SUFFIX = ".private.postgres.database.azure.com"; + public static final String POSTGRES_DNS_SUFFIX_GOV = ".private.postgres.database.usgovcloudapi.net"; public CreatePostgresqlDNSStep( ArmManagers armManagers, ResourceNameProvider resourceNameProvider) { @@ -29,17 +33,22 @@ public CreatePostgresqlDNSStep( @Override protected void createResource(FlightContext context, ArmManagers armManagers) { + var beanBag = LandingZoneFlightBeanBag.getFromObject(context.getApplicationContext()); + var azureEnvironment = beanBag.getAzureConfiguration().getAzureEnvironment(); + var landingZoneId = getParameterOrThrow( context.getInputParameters(), LandingZoneFlightMapKeys.LANDING_ZONE_ID, UUID.class); var dnsZoneName = resourceNameProvider.getName(getResourceType()); + String postgresDnsSuffixForEnvironment = azureEnvironment == AzureEnvironment.AZURE_US_GOVERNMENT ? POSTGRES_DNS_SUFFIX_GOV : POSTGRES_DNS_SUFFIX; + var dns = armManagers .azureResourceManager() .privateDnsZones() - .define(dnsZoneName + POSTGRES_DNS_SUFFIX) + .define(dnsZoneName + postgresDnsSuffixForEnvironment) .withExistingResourceGroup(getMRGName(context)) .withTags( Map.of(LandingZoneTagKeys.LANDING_ZONE_ID.toString(), landingZoneId.toString())) From 3b017a81b9c588fab1b66166b0beb0415e55ac0d Mon Sep 17 00:00:00 2001 From: bennettn4 Date: Tue, 29 Oct 2024 12:26:42 -0400 Subject: [PATCH 09/22] Update CreateBatchLogSettingsStep.java --- .../create/resource/step/CreateBatchLogSettingsStep.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/library/src/main/java/bio/terra/landingzone/stairway/flight/create/resource/step/CreateBatchLogSettingsStep.java b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/resource/step/CreateBatchLogSettingsStep.java index 691b505f6..4d39e78e3 100644 --- a/library/src/main/java/bio/terra/landingzone/stairway/flight/create/resource/step/CreateBatchLogSettingsStep.java +++ b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/resource/step/CreateBatchLogSettingsStep.java @@ -44,9 +44,10 @@ protected void createResource(FlightContext context, ArmManagers armManagers) { .define(batchLogSettingsName) .withResource(batchAccountId) .withLogAnalytics(logAnalyticsWorkspaceId) - .withLog("ServiceLogs", 0) // retention is handled by the log analytics workspace - .withLog("ServiceLog", 0) - .withLog("AuditLog", 0) + .withLog("allLogs", 0) // temporary change for different logs in gov vs commercial + //.withLog("ServiceLogs", 0) // retention is handled by the log analytics workspace + //.withLog("ServiceLog", 0) + //.withLog("AuditLog", 0) .create(); logger.info(RESOURCE_CREATED, getResourceType(), batchLogSettings.id(), getMRGName(context)); } From a7c7ef239c754420faeaa7d6c72814f75871b40e Mon Sep 17 00:00:00 2001 From: bennettn4 Date: Tue, 29 Oct 2024 15:16:12 -0400 Subject: [PATCH 10/22] Update CreateBatchLogSettingsStep.java --- .../create/resource/step/CreateBatchLogSettingsStep.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/library/src/main/java/bio/terra/landingzone/stairway/flight/create/resource/step/CreateBatchLogSettingsStep.java b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/resource/step/CreateBatchLogSettingsStep.java index 4d39e78e3..644da8356 100644 --- a/library/src/main/java/bio/terra/landingzone/stairway/flight/create/resource/step/CreateBatchLogSettingsStep.java +++ b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/resource/step/CreateBatchLogSettingsStep.java @@ -44,9 +44,8 @@ protected void createResource(FlightContext context, ArmManagers armManagers) { .define(batchLogSettingsName) .withResource(batchAccountId) .withLogAnalytics(logAnalyticsWorkspaceId) - .withLog("allLogs", 0) // temporary change for different logs in gov vs commercial - //.withLog("ServiceLogs", 0) // retention is handled by the log analytics workspace - //.withLog("ServiceLog", 0) + .withLog("ServiceLogs", 0) // retention is handled by the log analytics workspace + //.withLog("ServiceLog", 0) // temporary change for different logs in gov vs commercial //.withLog("AuditLog", 0) .create(); logger.info(RESOURCE_CREATED, getResourceType(), batchLogSettings.id(), getMRGName(context)); From e20b82efdf1545a5e1c58b2f61cf84280441eba4 Mon Sep 17 00:00:00 2001 From: bennettn4 Date: Tue, 29 Oct 2024 16:42:04 -0400 Subject: [PATCH 11/22] Update CreateBatchLogSettingsStep.java --- .../resource/step/CreateBatchLogSettingsStep.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/library/src/main/java/bio/terra/landingzone/stairway/flight/create/resource/step/CreateBatchLogSettingsStep.java b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/resource/step/CreateBatchLogSettingsStep.java index 644da8356..7c573d134 100644 --- a/library/src/main/java/bio/terra/landingzone/stairway/flight/create/resource/step/CreateBatchLogSettingsStep.java +++ b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/resource/step/CreateBatchLogSettingsStep.java @@ -8,6 +8,8 @@ import bio.terra.stairway.StepResult; import java.util.List; import java.util.Optional; + +import com.azure.resourcemanager.monitor.models.DiagnosticSettingsCategory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -37,6 +39,13 @@ protected void createResource(FlightContext context, ArmManagers armManagers) { String.class); var batchLogSettingsName = resourceNameProvider.getName(getResourceType()); + + + + for(DiagnosticSettingsCategory diagnosticSettingsCategory : armManagers.monitorManager().diagnosticSettings().listCategoriesByResource(batchAccountId)){ + logger.info("Currently valid diagnostic settings category for batch in current azure Environment :" +diagnosticSettingsCategory.name()); + } + var batchLogSettings = armManagers .monitorManager() @@ -44,8 +53,8 @@ protected void createResource(FlightContext context, ArmManagers armManagers) { .define(batchLogSettingsName) .withResource(batchAccountId) .withLogAnalytics(logAnalyticsWorkspaceId) - .withLog("ServiceLogs", 0) // retention is handled by the log analytics workspace - //.withLog("ServiceLog", 0) // temporary change for different logs in gov vs commercial + //withLog("ServiceLogs", 0) // retention is handled by the log analytics workspace + .withLog("ServiceLog", 0) // temporary change for different logs in gov vs commercial //.withLog("AuditLog", 0) .create(); logger.info(RESOURCE_CREATED, getResourceType(), batchLogSettings.id(), getMRGName(context)); From 8250c402f1487cc6ac7a7cfb7dcb2b4aa88c1d3a Mon Sep 17 00:00:00 2001 From: Jonathon Saunders Date: Mon, 11 Nov 2024 21:34:49 -0800 Subject: [PATCH 12/22] Updates --- ...ferencedLandingZoneStepsDefinitionProvider.java | 2 ++ .../reference/resource/step/ArmResourceType.java | 2 ++ .../step/ReferencedManagedIdentityStep.java | 14 ++++++++++++++ .../step/ReferencedPostgresqlServerStep.java | 14 ++++++++++++++ .../resource/step/ReferencedPrivateDNSStep.java | 14 ++++++++++++++ 5 files changed, 46 insertions(+) create mode 100644 library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/ReferencedManagedIdentityStep.java create mode 100644 library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/ReferencedPostgresqlServerStep.java create mode 100644 library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/ReferencedPrivateDNSStep.java diff --git a/library/src/main/java/bio/terra/landingzone/library/landingzones/definition/factories/ReferencedLandingZoneStepsDefinitionProvider.java b/library/src/main/java/bio/terra/landingzone/library/landingzones/definition/factories/ReferencedLandingZoneStepsDefinitionProvider.java index f403bcdd9..ef887f177 100644 --- a/library/src/main/java/bio/terra/landingzone/library/landingzones/definition/factories/ReferencedLandingZoneStepsDefinitionProvider.java +++ b/library/src/main/java/bio/terra/landingzone/library/landingzones/definition/factories/ReferencedLandingZoneStepsDefinitionProvider.java @@ -55,6 +55,8 @@ public List> get( Pair.of(new ReferencedBatchStep(armManagers), RetryRules.cloud()), Pair.of(new ReferencedStorageStep(armManagers), RetryRules.cloud()), Pair.of(new ReferencedRelayNamespaceStep(armManagers), RetryRules.cloud()), + Pair.of(new ReferencedManagedIdentityStep(armManagers), RetryRules.cloud()), + Pair.of(new ReferencedPostgresqlServerStep(armManagers), RetryRules.cloud()), Pair.of(new ReferencedAppInsightsStep(armManagers), RetryRules.cloud())); } } diff --git a/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/ArmResourceType.java b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/ArmResourceType.java index fba61dca1..9f442c752 100644 --- a/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/ArmResourceType.java +++ b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/ArmResourceType.java @@ -7,6 +7,8 @@ public enum ArmResourceType { POSTGRES_FLEXIBLE("Microsoft.DBforPostgreSQL/flexibleServers"), BATCH("Microsoft.Batch/batchAccounts"), APP_INSIGHTS("Microsoft.Insights/components"), + MANAGED_IDENTITY("Microsoft.ManagedIdentity/userAssignedIdentities"), + PRIVATE_DNS_ZONE("Microsoft.Network/privateDnsZones"), RELAY_NAMESPACE("Microsoft.Relay/namespaces"); private final String value; diff --git a/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/ReferencedManagedIdentityStep.java b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/ReferencedManagedIdentityStep.java new file mode 100644 index 000000000..c63214638 --- /dev/null +++ b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/ReferencedManagedIdentityStep.java @@ -0,0 +1,14 @@ +package bio.terra.landingzone.stairway.flight.create.reference.resource.step; + +import bio.terra.landingzone.library.landingzones.definition.ArmManagers; + +public class ReferencedManagedIdentityStep extends SharedReferencedResourceStep { + public ReferencedManagedIdentityStep(ArmManagers armManagers) { + super(armManagers); + } + + @Override + protected ArmResourceType getArmResourceType() { + return ArmResourceType.MANAGED_IDENTITY; + } +} diff --git a/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/ReferencedPostgresqlServerStep.java b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/ReferencedPostgresqlServerStep.java new file mode 100644 index 000000000..1160e1bd7 --- /dev/null +++ b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/ReferencedPostgresqlServerStep.java @@ -0,0 +1,14 @@ +package bio.terra.landingzone.stairway.flight.create.reference.resource.step; + +import bio.terra.landingzone.library.landingzones.definition.ArmManagers; + +public class ReferencedPostgresqlServerStep extends SharedReferencedResourceStep { + public ReferencedPostgresqlServerStep(ArmManagers armManagers) { + super(armManagers); + } + + @Override + protected ArmResourceType getArmResourceType() { + return ArmResourceType.POSTGRES_FLEXIBLE; + } +} \ No newline at end of file diff --git a/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/ReferencedPrivateDNSStep.java b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/ReferencedPrivateDNSStep.java new file mode 100644 index 000000000..a5b5989f6 --- /dev/null +++ b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/ReferencedPrivateDNSStep.java @@ -0,0 +1,14 @@ +package bio.terra.landingzone.stairway.flight.create.reference.resource.step; + +import bio.terra.landingzone.library.landingzones.definition.ArmManagers; + +public class ReferencedPrivateDNSStep extends SharedReferencedResourceStep { + public ReferencedPrivateDNSStep(ArmManagers armManagers) { + super(armManagers); + } + + @Override + protected ArmResourceType getArmResourceType() { + return ArmResourceType.PRIVATE_DNS_ZONE; + } +} From d6ce418910a93d0a18b3185b844e96c2c218e981 Mon Sep 17 00:00:00 2001 From: bennettn4 Date: Mon, 18 Nov 2024 14:27:26 -0500 Subject: [PATCH 13/22] update azure gov values --- .../LandingZoneAzureConfiguration.java | 6 ++++-- .../step/CreateBatchLogSettingsStep.java | 21 +++++++++++-------- .../postgres/CreatePostgresqlDNSStep.java | 11 ++++++---- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/library/src/main/java/bio/terra/landingzone/library/configuration/LandingZoneAzureConfiguration.java b/library/src/main/java/bio/terra/landingzone/library/configuration/LandingZoneAzureConfiguration.java index 084de0654..2ca057d60 100644 --- a/library/src/main/java/bio/terra/landingzone/library/configuration/LandingZoneAzureConfiguration.java +++ b/library/src/main/java/bio/terra/landingzone/library/configuration/LandingZoneAzureConfiguration.java @@ -37,11 +37,13 @@ public void setManagedAppTenantId(String managedAppTenantId) { this.managedAppTenantId = managedAppTenantId; } + + // AzureCloud or AzureUSGovernmentCloud public AzureEnvironment getAzureEnvironment() { switch (azureEnvironment) { - case "AZURE": + case "AzureCloud": return AzureEnvironment.AZURE; - case "AZURE_GOV": + case "AzureUSGovernmentCloud": return AzureEnvironment.AZURE_US_GOVERNMENT; default: throw new IllegalArgumentException( diff --git a/library/src/main/java/bio/terra/landingzone/stairway/flight/create/resource/step/CreateBatchLogSettingsStep.java b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/resource/step/CreateBatchLogSettingsStep.java index 7c573d134..a6c584d5a 100644 --- a/library/src/main/java/bio/terra/landingzone/stairway/flight/create/resource/step/CreateBatchLogSettingsStep.java +++ b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/resource/step/CreateBatchLogSettingsStep.java @@ -6,10 +6,9 @@ import bio.terra.landingzone.stairway.flight.ResourceNameRequirements; import bio.terra.stairway.FlightContext; import bio.terra.stairway.StepResult; +import com.azure.resourcemanager.monitor.models.DiagnosticSettingsCategory; import java.util.List; import java.util.Optional; - -import com.azure.resourcemanager.monitor.models.DiagnosticSettingsCategory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -40,10 +39,14 @@ protected void createResource(FlightContext context, ArmManagers armManagers) { var batchLogSettingsName = resourceNameProvider.getName(getResourceType()); - - - for(DiagnosticSettingsCategory diagnosticSettingsCategory : armManagers.monitorManager().diagnosticSettings().listCategoriesByResource(batchAccountId)){ - logger.info("Currently valid diagnostic settings category for batch in current azure Environment :" +diagnosticSettingsCategory.name()); + for (DiagnosticSettingsCategory diagnosticSettingsCategory : + armManagers + .monitorManager() + .diagnosticSettings() + .listCategoriesByResource(batchAccountId)) { + logger.info( + "Currently valid diagnostic settings category for batch in current azure Environment :" + + diagnosticSettingsCategory.name()); } var batchLogSettings = @@ -53,9 +56,9 @@ protected void createResource(FlightContext context, ArmManagers armManagers) { .define(batchLogSettingsName) .withResource(batchAccountId) .withLogAnalytics(logAnalyticsWorkspaceId) - //withLog("ServiceLogs", 0) // retention is handled by the log analytics workspace - .withLog("ServiceLog", 0) // temporary change for different logs in gov vs commercial - //.withLog("AuditLog", 0) + // withLog("ServiceLogs", 0) // retention is handled by the log analytics workspace + .withLog("ServiceLog", 0) // temporary change for different logs in gov vs commercial + // .withLog("AuditLog", 0) .create(); logger.info(RESOURCE_CREATED, getResourceType(), batchLogSettings.id(), getMRGName(context)); } diff --git a/library/src/main/java/bio/terra/landingzone/stairway/flight/create/resource/step/postgres/CreatePostgresqlDNSStep.java b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/resource/step/postgres/CreatePostgresqlDNSStep.java index 2b8e22827..bc6c66706 100644 --- a/library/src/main/java/bio/terra/landingzone/stairway/flight/create/resource/step/postgres/CreatePostgresqlDNSStep.java +++ b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/resource/step/postgres/CreatePostgresqlDNSStep.java @@ -10,12 +10,11 @@ import bio.terra.landingzone.stairway.flight.ResourceNameRequirements; import bio.terra.landingzone.stairway.flight.create.resource.step.BaseResourceCreateStep; import bio.terra.stairway.FlightContext; +import com.azure.core.management.AzureEnvironment; import java.util.List; import java.util.Map; import java.util.Optional; import java.util.UUID; - -import com.azure.core.management.AzureEnvironment; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -24,7 +23,8 @@ public class CreatePostgresqlDNSStep extends BaseResourceCreateStep { public static final String POSTGRESQL_DNS_ID = "POSTGRESQL_DNS_ID"; public static final String POSTGRESQL_DNS_RESOURCE_KEY = "POSTGRESQL_DNS"; public static final String POSTGRES_DNS_SUFFIX = ".private.postgres.database.azure.com"; - public static final String POSTGRES_DNS_SUFFIX_GOV = ".private.postgres.database.usgovcloudapi.net"; + public static final String POSTGRES_DNS_SUFFIX_GOV = + ".private.postgres.database.usgovcloudapi.net"; public CreatePostgresqlDNSStep( ArmManagers armManagers, ResourceNameProvider resourceNameProvider) { @@ -42,7 +42,10 @@ protected void createResource(FlightContext context, ArmManagers armManagers) { var dnsZoneName = resourceNameProvider.getName(getResourceType()); - String postgresDnsSuffixForEnvironment = azureEnvironment == AzureEnvironment.AZURE_US_GOVERNMENT ? POSTGRES_DNS_SUFFIX_GOV : POSTGRES_DNS_SUFFIX; + String postgresDnsSuffixForEnvironment = + azureEnvironment == AzureEnvironment.AZURE_US_GOVERNMENT + ? POSTGRES_DNS_SUFFIX_GOV + : POSTGRES_DNS_SUFFIX; var dns = armManagers From 1a356c812341ebe79909b2883b7deba686cac611 Mon Sep 17 00:00:00 2001 From: Jonathon Saunders Date: Mon, 18 Nov 2024 13:31:08 -0800 Subject: [PATCH 14/22] Include federated identity step --- ...cedLandingZoneStepsDefinitionProvider.java | 3 ++- .../step/BaseReferencedResourceStep.java | 4 ++++ .../resource/step/ReferencedAksStep.java | 21 ++++++++++++++++++ .../step/ReferencedManagedIdentityStep.java | 22 +++++++++++++++++++ 4 files changed, 49 insertions(+), 1 deletion(-) diff --git a/library/src/main/java/bio/terra/landingzone/library/landingzones/definition/factories/ReferencedLandingZoneStepsDefinitionProvider.java b/library/src/main/java/bio/terra/landingzone/library/landingzones/definition/factories/ReferencedLandingZoneStepsDefinitionProvider.java index ef887f177..1b60e6174 100644 --- a/library/src/main/java/bio/terra/landingzone/library/landingzones/definition/factories/ReferencedLandingZoneStepsDefinitionProvider.java +++ b/library/src/main/java/bio/terra/landingzone/library/landingzones/definition/factories/ReferencedLandingZoneStepsDefinitionProvider.java @@ -57,6 +57,7 @@ public List> get( Pair.of(new ReferencedRelayNamespaceStep(armManagers), RetryRules.cloud()), Pair.of(new ReferencedManagedIdentityStep(armManagers), RetryRules.cloud()), Pair.of(new ReferencedPostgresqlServerStep(armManagers), RetryRules.cloud()), - Pair.of(new ReferencedAppInsightsStep(armManagers), RetryRules.cloud())); + Pair.of(new ReferencedAppInsightsStep(armManagers), RetryRules.cloud()), + Pair.of(new CreateLandingZoneFederatedIdentityStep(armManagers, new KubernetesClientProviderImpl()), RetryRules.cloud())); } } diff --git a/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/BaseReferencedResourceStep.java b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/BaseReferencedResourceStep.java index 844737f9b..2f82b703b 100644 --- a/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/BaseReferencedResourceStep.java +++ b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/BaseReferencedResourceStep.java @@ -96,10 +96,14 @@ private void tagReferencedResourceAndSetContext(FlightContext context) { getArmResourceType(), getMRGName(context)))); setLandingZoneResourceTags(context, resource); + updateWorkingMap(context, armManagers, resource.id()); context.getWorkingMap().put(REFERENCED_RESOURCE_ID, resource.id()); } + // Optional hook for subclasses + protected void updateWorkingMap(FlightContext context, ArmManagers armManagers, String resourceId) { } + private void setLandingZoneResourceTags(FlightContext context, GenericResource genericResource) { UUID lzId = getLandingZoneId(context); diff --git a/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/ReferencedAksStep.java b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/ReferencedAksStep.java index 6a7dc8e00..09cc5c00e 100644 --- a/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/ReferencedAksStep.java +++ b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/ReferencedAksStep.java @@ -1,6 +1,10 @@ package bio.terra.landingzone.stairway.flight.create.reference.resource.step; import bio.terra.landingzone.library.landingzones.definition.ArmManagers; +import bio.terra.stairway.FlightContext; + +import static bio.terra.landingzone.stairway.flight.create.resource.step.CreateAksStep.AKS_OIDC_ISSUER_URL; +import static bio.terra.landingzone.stairway.flight.create.resource.step.CreateAksStep.AKS_RESOURCE_KEY; public class ReferencedAksStep extends SharedReferencedResourceStep { @@ -12,4 +16,21 @@ public ReferencedAksStep(ArmManagers armManagers) { protected ArmResourceType getArmResourceType() { return ArmResourceType.AKS; } + + @Override + protected void updateWorkingMap(FlightContext context, ArmManagers armManagers, String resourceId) + { + var aks = armManagers + .azureResourceManager() + .kubernetesClusters() + .getById(resourceId); + + context + .getWorkingMap() + .put(AKS_OIDC_ISSUER_URL, aks.innerModel().oidcIssuerProfile().issuerUrl()); + + context + .getWorkingMap() + .put(AKS_RESOURCE_KEY, resourceId); + } } diff --git a/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/ReferencedManagedIdentityStep.java b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/ReferencedManagedIdentityStep.java index c63214638..6b4642cb6 100644 --- a/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/ReferencedManagedIdentityStep.java +++ b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/ReferencedManagedIdentityStep.java @@ -1,6 +1,11 @@ package bio.terra.landingzone.stairway.flight.create.reference.resource.step; import bio.terra.landingzone.library.landingzones.definition.ArmManagers; +import bio.terra.landingzone.stairway.flight.create.resource.step.CreateLandingZoneIdentityStep; +import bio.terra.stairway.FlightContext; + +import static bio.terra.landingzone.stairway.flight.create.resource.step.CreateLandingZoneIdentityStep.LANDING_ZONE_IDENTITY_CLIENT_ID; +import static bio.terra.landingzone.stairway.flight.create.resource.step.CreateLandingZoneIdentityStep.LANDING_ZONE_IDENTITY_RESOURCE_KEY; public class ReferencedManagedIdentityStep extends SharedReferencedResourceStep { public ReferencedManagedIdentityStep(ArmManagers armManagers) { @@ -11,4 +16,21 @@ public ReferencedManagedIdentityStep(ArmManagers armManagers) { protected ArmResourceType getArmResourceType() { return ArmResourceType.MANAGED_IDENTITY; } + + @Override + protected void updateWorkingMap(FlightContext context, ArmManagers armManagers, String resourceId) + { + var id = armManagers + .azureResourceManager() + .identities() + .getById(resourceId); + + context + .getWorkingMap() + .put(LANDING_ZONE_IDENTITY_CLIENT_ID, id.innerModel().clientId()); + + context + .getWorkingMap() + .put(LANDING_ZONE_IDENTITY_RESOURCE_KEY, resourceId); + } } From 32a11ba546d572ccec1b11cf9eb108e25222d585 Mon Sep 17 00:00:00 2001 From: Jonathon Saunders Date: Mon, 18 Nov 2024 15:36:14 -0800 Subject: [PATCH 15/22] Fix --- .../reference/resource/step/ReferencedAksStep.java | 9 ++++++++- .../step/ReferencedManagedIdentityStep.java | 13 ++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/ReferencedAksStep.java b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/ReferencedAksStep.java index 09cc5c00e..f4a70fef8 100644 --- a/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/ReferencedAksStep.java +++ b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/ReferencedAksStep.java @@ -1,6 +1,7 @@ package bio.terra.landingzone.stairway.flight.create.reference.resource.step; import bio.terra.landingzone.library.landingzones.definition.ArmManagers; +import bio.terra.landingzone.service.landingzone.azure.model.LandingZoneResource; import bio.terra.stairway.FlightContext; import static bio.terra.landingzone.stairway.flight.create.resource.step.CreateAksStep.AKS_OIDC_ISSUER_URL; @@ -31,6 +32,12 @@ protected void updateWorkingMap(FlightContext context, ArmManagers armManagers, context .getWorkingMap() - .put(AKS_RESOURCE_KEY, resourceId); + .put(AKS_RESOURCE_KEY, LandingZoneResource.builder() + .resourceId(aks.id()) + .resourceType(aks.type()) + .tags(aks.tags()) + .region(aks.regionName()) + .resourceName(aks.name()) + .build()); } } diff --git a/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/ReferencedManagedIdentityStep.java b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/ReferencedManagedIdentityStep.java index 6b4642cb6..fa5ac1877 100644 --- a/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/ReferencedManagedIdentityStep.java +++ b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/ReferencedManagedIdentityStep.java @@ -1,6 +1,7 @@ package bio.terra.landingzone.stairway.flight.create.reference.resource.step; import bio.terra.landingzone.library.landingzones.definition.ArmManagers; +import bio.terra.landingzone.service.landingzone.azure.model.LandingZoneResource; import bio.terra.landingzone.stairway.flight.create.resource.step.CreateLandingZoneIdentityStep; import bio.terra.stairway.FlightContext; @@ -20,17 +21,23 @@ protected ArmResourceType getArmResourceType() { @Override protected void updateWorkingMap(FlightContext context, ArmManagers armManagers, String resourceId) { - var id = armManagers + var uami = armManagers .azureResourceManager() .identities() .getById(resourceId); context .getWorkingMap() - .put(LANDING_ZONE_IDENTITY_CLIENT_ID, id.innerModel().clientId()); + .put(LANDING_ZONE_IDENTITY_CLIENT_ID, uami.clientId()); context .getWorkingMap() - .put(LANDING_ZONE_IDENTITY_RESOURCE_KEY, resourceId); + .put(LANDING_ZONE_IDENTITY_RESOURCE_KEY, LandingZoneResource.builder() + .resourceId(uami.id()) + .resourceType(uami.type()) + .tags(uami.tags()) + .region(uami.regionName()) + .resourceName(uami.name()) + .build()); } } From 2e3557d4e2bf16c7dcf3405d228a4a65600c2744 Mon Sep 17 00:00:00 2001 From: Jonathon Saunders Date: Thu, 21 Nov 2024 12:52:25 -0800 Subject: [PATCH 16/22] spotless --- ...cedLandingZoneStepsDefinitionProvider.java | 5 +- .../step/BaseReferencedResourceStep.java | 3 +- .../resource/step/ReferencedAksStep.java | 37 ++++++------ .../step/ReferencedManagedIdentityStep.java | 58 +++++++++---------- .../step/ReferencedPostgresqlServerStep.java | 16 ++--- .../step/ReferencedPrivateDNSStep.java | 14 ++--- .../step/CreateBatchLogSettingsStep.java | 21 ++++--- .../postgres/CreatePostgresqlDNSStep.java | 11 ++-- 8 files changed, 85 insertions(+), 80 deletions(-) diff --git a/library/src/main/java/bio/terra/landingzone/library/landingzones/definition/factories/ReferencedLandingZoneStepsDefinitionProvider.java b/library/src/main/java/bio/terra/landingzone/library/landingzones/definition/factories/ReferencedLandingZoneStepsDefinitionProvider.java index 1b60e6174..dfef8f9d2 100644 --- a/library/src/main/java/bio/terra/landingzone/library/landingzones/definition/factories/ReferencedLandingZoneStepsDefinitionProvider.java +++ b/library/src/main/java/bio/terra/landingzone/library/landingzones/definition/factories/ReferencedLandingZoneStepsDefinitionProvider.java @@ -58,6 +58,9 @@ public List> get( Pair.of(new ReferencedManagedIdentityStep(armManagers), RetryRules.cloud()), Pair.of(new ReferencedPostgresqlServerStep(armManagers), RetryRules.cloud()), Pair.of(new ReferencedAppInsightsStep(armManagers), RetryRules.cloud()), - Pair.of(new CreateLandingZoneFederatedIdentityStep(armManagers, new KubernetesClientProviderImpl()), RetryRules.cloud())); + Pair.of( + new CreateLandingZoneFederatedIdentityStep( + armManagers, new KubernetesClientProviderImpl()), + RetryRules.cloud())); } } diff --git a/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/BaseReferencedResourceStep.java b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/BaseReferencedResourceStep.java index 2f82b703b..059351e35 100644 --- a/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/BaseReferencedResourceStep.java +++ b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/BaseReferencedResourceStep.java @@ -102,7 +102,8 @@ private void tagReferencedResourceAndSetContext(FlightContext context) { } // Optional hook for subclasses - protected void updateWorkingMap(FlightContext context, ArmManagers armManagers, String resourceId) { } + protected void updateWorkingMap( + FlightContext context, ArmManagers armManagers, String resourceId) {} private void setLandingZoneResourceTags(FlightContext context, GenericResource genericResource) { diff --git a/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/ReferencedAksStep.java b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/ReferencedAksStep.java index f4a70fef8..02b35234d 100644 --- a/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/ReferencedAksStep.java +++ b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/ReferencedAksStep.java @@ -1,12 +1,12 @@ package bio.terra.landingzone.stairway.flight.create.reference.resource.step; +import static bio.terra.landingzone.stairway.flight.create.resource.step.CreateAksStep.AKS_OIDC_ISSUER_URL; +import static bio.terra.landingzone.stairway.flight.create.resource.step.CreateAksStep.AKS_RESOURCE_KEY; + import bio.terra.landingzone.library.landingzones.definition.ArmManagers; import bio.terra.landingzone.service.landingzone.azure.model.LandingZoneResource; import bio.terra.stairway.FlightContext; -import static bio.terra.landingzone.stairway.flight.create.resource.step.CreateAksStep.AKS_OIDC_ISSUER_URL; -import static bio.terra.landingzone.stairway.flight.create.resource.step.CreateAksStep.AKS_RESOURCE_KEY; - public class ReferencedAksStep extends SharedReferencedResourceStep { public ReferencedAksStep(ArmManagers armManagers) { @@ -19,25 +19,24 @@ protected ArmResourceType getArmResourceType() { } @Override - protected void updateWorkingMap(FlightContext context, ArmManagers armManagers, String resourceId) - { - var aks = armManagers - .azureResourceManager() - .kubernetesClusters() - .getById(resourceId); + protected void updateWorkingMap( + FlightContext context, ArmManagers armManagers, String resourceId) { + var aks = armManagers.azureResourceManager().kubernetesClusters().getById(resourceId); context - .getWorkingMap() - .put(AKS_OIDC_ISSUER_URL, aks.innerModel().oidcIssuerProfile().issuerUrl()); + .getWorkingMap() + .put(AKS_OIDC_ISSUER_URL, aks.innerModel().oidcIssuerProfile().issuerUrl()); context - .getWorkingMap() - .put(AKS_RESOURCE_KEY, LandingZoneResource.builder() - .resourceId(aks.id()) - .resourceType(aks.type()) - .tags(aks.tags()) - .region(aks.regionName()) - .resourceName(aks.name()) - .build()); + .getWorkingMap() + .put( + AKS_RESOURCE_KEY, + LandingZoneResource.builder() + .resourceId(aks.id()) + .resourceType(aks.type()) + .tags(aks.tags()) + .region(aks.regionName()) + .resourceName(aks.name()) + .build()); } } diff --git a/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/ReferencedManagedIdentityStep.java b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/ReferencedManagedIdentityStep.java index fa5ac1877..3672865e9 100644 --- a/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/ReferencedManagedIdentityStep.java +++ b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/ReferencedManagedIdentityStep.java @@ -1,43 +1,39 @@ package bio.terra.landingzone.stairway.flight.create.reference.resource.step; +import static bio.terra.landingzone.stairway.flight.create.resource.step.CreateLandingZoneIdentityStep.LANDING_ZONE_IDENTITY_CLIENT_ID; +import static bio.terra.landingzone.stairway.flight.create.resource.step.CreateLandingZoneIdentityStep.LANDING_ZONE_IDENTITY_RESOURCE_KEY; + import bio.terra.landingzone.library.landingzones.definition.ArmManagers; import bio.terra.landingzone.service.landingzone.azure.model.LandingZoneResource; -import bio.terra.landingzone.stairway.flight.create.resource.step.CreateLandingZoneIdentityStep; import bio.terra.stairway.FlightContext; -import static bio.terra.landingzone.stairway.flight.create.resource.step.CreateLandingZoneIdentityStep.LANDING_ZONE_IDENTITY_CLIENT_ID; -import static bio.terra.landingzone.stairway.flight.create.resource.step.CreateLandingZoneIdentityStep.LANDING_ZONE_IDENTITY_RESOURCE_KEY; - public class ReferencedManagedIdentityStep extends SharedReferencedResourceStep { - public ReferencedManagedIdentityStep(ArmManagers armManagers) { - super(armManagers); - } + public ReferencedManagedIdentityStep(ArmManagers armManagers) { + super(armManagers); + } - @Override - protected ArmResourceType getArmResourceType() { - return ArmResourceType.MANAGED_IDENTITY; - } + @Override + protected ArmResourceType getArmResourceType() { + return ArmResourceType.MANAGED_IDENTITY; + } - @Override - protected void updateWorkingMap(FlightContext context, ArmManagers armManagers, String resourceId) - { - var uami = armManagers - .azureResourceManager() - .identities() - .getById(resourceId); + @Override + protected void updateWorkingMap( + FlightContext context, ArmManagers armManagers, String resourceId) { + var uami = armManagers.azureResourceManager().identities().getById(resourceId); - context - .getWorkingMap() - .put(LANDING_ZONE_IDENTITY_CLIENT_ID, uami.clientId()); + context.getWorkingMap().put(LANDING_ZONE_IDENTITY_CLIENT_ID, uami.clientId()); - context - .getWorkingMap() - .put(LANDING_ZONE_IDENTITY_RESOURCE_KEY, LandingZoneResource.builder() - .resourceId(uami.id()) - .resourceType(uami.type()) - .tags(uami.tags()) - .region(uami.regionName()) - .resourceName(uami.name()) - .build()); - } + context + .getWorkingMap() + .put( + LANDING_ZONE_IDENTITY_RESOURCE_KEY, + LandingZoneResource.builder() + .resourceId(uami.id()) + .resourceType(uami.type()) + .tags(uami.tags()) + .region(uami.regionName()) + .resourceName(uami.name()) + .build()); + } } diff --git a/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/ReferencedPostgresqlServerStep.java b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/ReferencedPostgresqlServerStep.java index 1160e1bd7..00c4314d4 100644 --- a/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/ReferencedPostgresqlServerStep.java +++ b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/ReferencedPostgresqlServerStep.java @@ -3,12 +3,12 @@ import bio.terra.landingzone.library.landingzones.definition.ArmManagers; public class ReferencedPostgresqlServerStep extends SharedReferencedResourceStep { - public ReferencedPostgresqlServerStep(ArmManagers armManagers) { - super(armManagers); - } + public ReferencedPostgresqlServerStep(ArmManagers armManagers) { + super(armManagers); + } - @Override - protected ArmResourceType getArmResourceType() { - return ArmResourceType.POSTGRES_FLEXIBLE; - } -} \ No newline at end of file + @Override + protected ArmResourceType getArmResourceType() { + return ArmResourceType.POSTGRES_FLEXIBLE; + } +} diff --git a/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/ReferencedPrivateDNSStep.java b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/ReferencedPrivateDNSStep.java index a5b5989f6..a50880d02 100644 --- a/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/ReferencedPrivateDNSStep.java +++ b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/reference/resource/step/ReferencedPrivateDNSStep.java @@ -3,12 +3,12 @@ import bio.terra.landingzone.library.landingzones.definition.ArmManagers; public class ReferencedPrivateDNSStep extends SharedReferencedResourceStep { - public ReferencedPrivateDNSStep(ArmManagers armManagers) { - super(armManagers); - } + public ReferencedPrivateDNSStep(ArmManagers armManagers) { + super(armManagers); + } - @Override - protected ArmResourceType getArmResourceType() { - return ArmResourceType.PRIVATE_DNS_ZONE; - } + @Override + protected ArmResourceType getArmResourceType() { + return ArmResourceType.PRIVATE_DNS_ZONE; + } } diff --git a/library/src/main/java/bio/terra/landingzone/stairway/flight/create/resource/step/CreateBatchLogSettingsStep.java b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/resource/step/CreateBatchLogSettingsStep.java index 7c573d134..a6c584d5a 100644 --- a/library/src/main/java/bio/terra/landingzone/stairway/flight/create/resource/step/CreateBatchLogSettingsStep.java +++ b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/resource/step/CreateBatchLogSettingsStep.java @@ -6,10 +6,9 @@ import bio.terra.landingzone.stairway.flight.ResourceNameRequirements; import bio.terra.stairway.FlightContext; import bio.terra.stairway.StepResult; +import com.azure.resourcemanager.monitor.models.DiagnosticSettingsCategory; import java.util.List; import java.util.Optional; - -import com.azure.resourcemanager.monitor.models.DiagnosticSettingsCategory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -40,10 +39,14 @@ protected void createResource(FlightContext context, ArmManagers armManagers) { var batchLogSettingsName = resourceNameProvider.getName(getResourceType()); - - - for(DiagnosticSettingsCategory diagnosticSettingsCategory : armManagers.monitorManager().diagnosticSettings().listCategoriesByResource(batchAccountId)){ - logger.info("Currently valid diagnostic settings category for batch in current azure Environment :" +diagnosticSettingsCategory.name()); + for (DiagnosticSettingsCategory diagnosticSettingsCategory : + armManagers + .monitorManager() + .diagnosticSettings() + .listCategoriesByResource(batchAccountId)) { + logger.info( + "Currently valid diagnostic settings category for batch in current azure Environment :" + + diagnosticSettingsCategory.name()); } var batchLogSettings = @@ -53,9 +56,9 @@ protected void createResource(FlightContext context, ArmManagers armManagers) { .define(batchLogSettingsName) .withResource(batchAccountId) .withLogAnalytics(logAnalyticsWorkspaceId) - //withLog("ServiceLogs", 0) // retention is handled by the log analytics workspace - .withLog("ServiceLog", 0) // temporary change for different logs in gov vs commercial - //.withLog("AuditLog", 0) + // withLog("ServiceLogs", 0) // retention is handled by the log analytics workspace + .withLog("ServiceLog", 0) // temporary change for different logs in gov vs commercial + // .withLog("AuditLog", 0) .create(); logger.info(RESOURCE_CREATED, getResourceType(), batchLogSettings.id(), getMRGName(context)); } diff --git a/library/src/main/java/bio/terra/landingzone/stairway/flight/create/resource/step/postgres/CreatePostgresqlDNSStep.java b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/resource/step/postgres/CreatePostgresqlDNSStep.java index 2b8e22827..bc6c66706 100644 --- a/library/src/main/java/bio/terra/landingzone/stairway/flight/create/resource/step/postgres/CreatePostgresqlDNSStep.java +++ b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/resource/step/postgres/CreatePostgresqlDNSStep.java @@ -10,12 +10,11 @@ import bio.terra.landingzone.stairway.flight.ResourceNameRequirements; import bio.terra.landingzone.stairway.flight.create.resource.step.BaseResourceCreateStep; import bio.terra.stairway.FlightContext; +import com.azure.core.management.AzureEnvironment; import java.util.List; import java.util.Map; import java.util.Optional; import java.util.UUID; - -import com.azure.core.management.AzureEnvironment; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -24,7 +23,8 @@ public class CreatePostgresqlDNSStep extends BaseResourceCreateStep { public static final String POSTGRESQL_DNS_ID = "POSTGRESQL_DNS_ID"; public static final String POSTGRESQL_DNS_RESOURCE_KEY = "POSTGRESQL_DNS"; public static final String POSTGRES_DNS_SUFFIX = ".private.postgres.database.azure.com"; - public static final String POSTGRES_DNS_SUFFIX_GOV = ".private.postgres.database.usgovcloudapi.net"; + public static final String POSTGRES_DNS_SUFFIX_GOV = + ".private.postgres.database.usgovcloudapi.net"; public CreatePostgresqlDNSStep( ArmManagers armManagers, ResourceNameProvider resourceNameProvider) { @@ -42,7 +42,10 @@ protected void createResource(FlightContext context, ArmManagers armManagers) { var dnsZoneName = resourceNameProvider.getName(getResourceType()); - String postgresDnsSuffixForEnvironment = azureEnvironment == AzureEnvironment.AZURE_US_GOVERNMENT ? POSTGRES_DNS_SUFFIX_GOV : POSTGRES_DNS_SUFFIX; + String postgresDnsSuffixForEnvironment = + azureEnvironment == AzureEnvironment.AZURE_US_GOVERNMENT + ? POSTGRES_DNS_SUFFIX_GOV + : POSTGRES_DNS_SUFFIX; var dns = armManagers From edf400b04c46be8b6e2ecd0ccbc5803cb1634d3d Mon Sep 17 00:00:00 2001 From: Jonathon Saunders Date: Thu, 21 Nov 2024 12:54:49 -0800 Subject: [PATCH 17/22] Spotless again --- .../library/configuration/LandingZoneAzureConfiguration.java | 1 - 1 file changed, 1 deletion(-) diff --git a/library/src/main/java/bio/terra/landingzone/library/configuration/LandingZoneAzureConfiguration.java b/library/src/main/java/bio/terra/landingzone/library/configuration/LandingZoneAzureConfiguration.java index 2ca057d60..a5e971f6a 100644 --- a/library/src/main/java/bio/terra/landingzone/library/configuration/LandingZoneAzureConfiguration.java +++ b/library/src/main/java/bio/terra/landingzone/library/configuration/LandingZoneAzureConfiguration.java @@ -37,7 +37,6 @@ public void setManagedAppTenantId(String managedAppTenantId) { this.managedAppTenantId = managedAppTenantId; } - // AzureCloud or AzureUSGovernmentCloud public AzureEnvironment getAzureEnvironment() { switch (azureEnvironment) { From 6033a51566fc06c1bfca51e3cf15b67727e6ec05 Mon Sep 17 00:00:00 2001 From: Jonathon Saunders Date: Tue, 17 Dec 2024 12:13:39 -0800 Subject: [PATCH 18/22] Update settings.gradle --- settings.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.gradle b/settings.gradle index 921d4d318..12ddd7120 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,6 +1,6 @@ rootProject.name = 'terra-landing-zone-service' include('service','library', 'scripts') -gradle.ext.releaseVersion = "0.0.367-DEV" +gradle.ext.releaseVersion = "0.0.367-SNAPSHOT" include 'client' From aa1e0ba4b6ef698420098cab0225da82da11f9dc Mon Sep 17 00:00:00 2001 From: Jonathon Saunders Date: Tue, 17 Dec 2024 12:16:18 -0800 Subject: [PATCH 19/22] Update CreateBatchLogSettingsStep.java --- .../create/resource/step/CreateBatchLogSettingsStep.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/src/main/java/bio/terra/landingzone/stairway/flight/create/resource/step/CreateBatchLogSettingsStep.java b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/resource/step/CreateBatchLogSettingsStep.java index a6c584d5a..0d651cf45 100644 --- a/library/src/main/java/bio/terra/landingzone/stairway/flight/create/resource/step/CreateBatchLogSettingsStep.java +++ b/library/src/main/java/bio/terra/landingzone/stairway/flight/create/resource/step/CreateBatchLogSettingsStep.java @@ -56,9 +56,9 @@ protected void createResource(FlightContext context, ArmManagers armManagers) { .define(batchLogSettingsName) .withResource(batchAccountId) .withLogAnalytics(logAnalyticsWorkspaceId) - // withLog("ServiceLogs", 0) // retention is handled by the log analytics workspace - .withLog("ServiceLog", 0) // temporary change for different logs in gov vs commercial - // .withLog("AuditLog", 0) + .withLog("ServiceLogs", 0) // retention is handled by the log analytics workspace + .withLog("ServiceLog", 0) + .withLog("AuditLog", 0) .create(); logger.info(RESOURCE_CREATED, getResourceType(), batchLogSettings.id(), getMRGName(context)); } From 7ed15c2a5fef075c3c2b8cb069a1cf30374c89f4 Mon Sep 17 00:00:00 2001 From: Jonathon Saunders Date: Tue, 17 Dec 2024 13:21:24 -0800 Subject: [PATCH 20/22] Update CreatePostgresDNSStepTest.java --- .../resource/step/postgres/CreatePostgresDNSStepTest.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/library/src/test/java/bio/terra/landingzone/stairway/flight/create/resource/step/postgres/CreatePostgresDNSStepTest.java b/library/src/test/java/bio/terra/landingzone/stairway/flight/create/resource/step/postgres/CreatePostgresDNSStepTest.java index 49794f0f1..e49c07ae2 100644 --- a/library/src/test/java/bio/terra/landingzone/stairway/flight/create/resource/step/postgres/CreatePostgresDNSStepTest.java +++ b/library/src/test/java/bio/terra/landingzone/stairway/flight/create/resource/step/postgres/CreatePostgresDNSStepTest.java @@ -8,6 +8,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import bio.terra.landingzone.common.utils.LandingZoneFlightBeanBag; import bio.terra.landingzone.library.landingzones.deployment.LandingZoneTagKeys; import bio.terra.landingzone.stairway.common.model.TargetManagedResourceGroup; import bio.terra.landingzone.stairway.flight.FlightTestUtils; @@ -41,6 +42,7 @@ public class CreatePostgresDNSStepTest extends BaseStepTest { @Mock private PrivateDnsZone.DefinitionStages.Blank mockDefine; @Mock private PrivateDnsZone.DefinitionStages.WithCreate mockWithCreate; @Mock private PrivateDnsZone mockPrivateDnsZone; + @Mock private LandingZoneFlightBeanBag landingZoneFlightBeanBag; @BeforeEach void setup() { @@ -52,6 +54,7 @@ void doStepSuccess() throws InterruptedException { final String resourceName = UUID.randomUUID().toString(); when(mockResourceNameProvider.getName(testStep.getResourceType())).thenReturn(resourceName); + when(mockFlightContext.getApplicationContext()).thenReturn(landingZoneFlightBeanBag); TargetManagedResourceGroup mrg = ResourceStepFixture.createDefaultMrg(); setupFlightContext( From f1bb6b09d82baa3a53efe315130b552afc17bdb7 Mon Sep 17 00:00:00 2001 From: Jonathon Saunders Date: Tue, 17 Dec 2024 14:01:32 -0800 Subject: [PATCH 21/22] Update CreatePostgresDNSStepTest.java --- .../step/postgres/CreatePostgresDNSStepTest.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/library/src/test/java/bio/terra/landingzone/stairway/flight/create/resource/step/postgres/CreatePostgresDNSStepTest.java b/library/src/test/java/bio/terra/landingzone/stairway/flight/create/resource/step/postgres/CreatePostgresDNSStepTest.java index e49c07ae2..66a34efa7 100644 --- a/library/src/test/java/bio/terra/landingzone/stairway/flight/create/resource/step/postgres/CreatePostgresDNSStepTest.java +++ b/library/src/test/java/bio/terra/landingzone/stairway/flight/create/resource/step/postgres/CreatePostgresDNSStepTest.java @@ -9,6 +9,7 @@ import static org.mockito.Mockito.when; import bio.terra.landingzone.common.utils.LandingZoneFlightBeanBag; +import bio.terra.landingzone.library.configuration.LandingZoneAzureConfiguration; import bio.terra.landingzone.library.landingzones.deployment.LandingZoneTagKeys; import bio.terra.landingzone.stairway.common.model.TargetManagedResourceGroup; import bio.terra.landingzone.stairway.flight.FlightTestUtils; @@ -21,6 +22,7 @@ import bio.terra.stairway.FlightMap; import bio.terra.stairway.StepResult; import bio.terra.stairway.StepStatus; +import com.azure.core.management.AzureEnvironment; import com.azure.resourcemanager.privatedns.models.PrivateDnsZone; import com.azure.resourcemanager.privatedns.models.PrivateDnsZones; import java.util.Map; @@ -42,7 +44,9 @@ public class CreatePostgresDNSStepTest extends BaseStepTest { @Mock private PrivateDnsZone.DefinitionStages.Blank mockDefine; @Mock private PrivateDnsZone.DefinitionStages.WithCreate mockWithCreate; @Mock private PrivateDnsZone mockPrivateDnsZone; - @Mock private LandingZoneFlightBeanBag landingZoneFlightBeanBag; + @Mock private LandingZoneFlightBeanBag mockLandingZoneFlightBeanBag; + @Mock private LandingZoneAzureConfiguration mockAzureConfiguration; + @BeforeEach void setup() { @@ -54,7 +58,9 @@ void doStepSuccess() throws InterruptedException { final String resourceName = UUID.randomUUID().toString(); when(mockResourceNameProvider.getName(testStep.getResourceType())).thenReturn(resourceName); - when(mockFlightContext.getApplicationContext()).thenReturn(landingZoneFlightBeanBag); + when(mockFlightContext.getApplicationContext()).thenReturn(mockLandingZoneFlightBeanBag); + when(mockLandingZoneFlightBeanBag.getAzureConfiguration()).thenReturn(mockAzureConfiguration); + when(mockAzureConfiguration.getAzureEnvironment()).thenReturn(AzureEnvironment.AZURE); TargetManagedResourceGroup mrg = ResourceStepFixture.createDefaultMrg(); setupFlightContext( From 3919e53c390e8ca74a080db2943df1141cfa8327 Mon Sep 17 00:00:00 2001 From: Jonathon Saunders Date: Tue, 17 Dec 2024 14:08:27 -0800 Subject: [PATCH 22/22] whitespace --- .../create/resource/step/postgres/CreatePostgresDNSStepTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/library/src/test/java/bio/terra/landingzone/stairway/flight/create/resource/step/postgres/CreatePostgresDNSStepTest.java b/library/src/test/java/bio/terra/landingzone/stairway/flight/create/resource/step/postgres/CreatePostgresDNSStepTest.java index 66a34efa7..1acdec4e9 100644 --- a/library/src/test/java/bio/terra/landingzone/stairway/flight/create/resource/step/postgres/CreatePostgresDNSStepTest.java +++ b/library/src/test/java/bio/terra/landingzone/stairway/flight/create/resource/step/postgres/CreatePostgresDNSStepTest.java @@ -47,7 +47,6 @@ public class CreatePostgresDNSStepTest extends BaseStepTest { @Mock private LandingZoneFlightBeanBag mockLandingZoneFlightBeanBag; @Mock private LandingZoneAzureConfiguration mockAzureConfiguration; - @BeforeEach void setup() { testStep = new CreatePostgresqlDNSStep(mockArmManagers, mockResourceNameProvider);