Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Referenced landing zone updates. #521

Draft
wants to merge 7 commits into
base: bennett/azure-gov-update
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public void setManagedAppTenantId(String managedAppTenantId) {
this.managedAppTenantId = managedAppTenantId;
}


// AzureCloud or AzureUSGovernmentCloud
public AzureEnvironment getAzureEnvironment() {
switch (azureEnvironment) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ public List<Pair<Step, RetryRule>> 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 ReferencedAppInsightsStep(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 CreateLandingZoneFederatedIdentityStep(
armManagers, new KubernetesClientProviderImpl()),
RetryRules.cloud()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,15 @@ 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);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
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;

public class ReferencedAksStep extends SharedReferencedResourceStep {

Expand All @@ -12,4 +17,26 @@ 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,
LandingZoneResource.builder()
.resourceId(aks.id())
.resourceType(aks.type())
.tags(aks.tags())
.region(aks.regionName())
.resourceName(aks.name())
.build());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +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.stairway.FlightContext;

public class ReferencedManagedIdentityStep extends SharedReferencedResourceStep {
public ReferencedManagedIdentityStep(ArmManagers armManagers) {
super(armManagers);
}

@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);

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());
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Loading