worried-knife-31967
03/08/2021, 10:01 PMprotected readonly ImmutableDictionary<string, object>.Builder OutputBuilder = ImmutableDictionary.CreateBuilder<string, object>();
OutputBuilder.Add(location, Output.Create(ImmutableDictionary.CreateBuilder<string, object>()
.Append(new KeyValuePair<string, object>("GatewayUrl", apim.GatewayUrl))
.Append(new KeyValuePair<string, object>("ResourceGroup", resourceGroup.Name))
.Append(new KeyValuePair<string, object>("ServiceName", apim.Name))
.ToImmutableDictionary()));
then to consume it...
public static class OutputExtensions
{
public static Output<string> RequireSubDictionaryOutput(this StackReference stackReference, string outputName, string mainKey, string subKey)
{
return stackReference.RequireOutput(outputName).Apply<string>(_ => {
var mainArray = (ImmutableDictionary<string, object>)((ImmutableDictionary<string, object>)_)[mainKey];
return mainArray[subKey]?.ToString() ?? "";
});
}
}
Then used:
var apimResourceGroup = sharedStack.RequireSubDictionaryOutput("Gateways", location, "ResourceGroup");
var apimServiceName = sharedStack.RequireSubDictionaryOutput("Gateways", location, "ServiceName");
Like I said... very hacky...
The usecase is that the "shared" stack outputs multiple API-Management services, one for each region, then the service stacks need to add themselves to each of the regions. That requires them to know the RG and ServiceName of them.No matter how you like to participate in developer communities, Pulumi wants to meet you there. If you want to meet other Pulumi users to share use-cases and best practices, contribute code or documentation, see us at an event, or just tell a story about something cool you did with Pulumi, you are part of our community.
Powered by