https://pulumi.com logo
Join the conversationJoin Slack
Channels
announcements
automation-api
aws
azure
blog-posts
built-with-pulumi
cloudengineering
cloudengineering-support
content-share
contribex
contribute
docs
dotnet
finops
general
getting-started
gitlab
golang
google-cloud
hackathon-03-19-2020
hacktoberfest
install
java
jobs
kubernetes
learn-pulumi-events
linen
localstack
multi-language-hackathon
office-hours
oracle-cloud-infrastructure
plugin-framework
pulumi-cdk
pulumi-crosscode
pulumi-deployments
pulumi-kubernetes-operator
pulumi-service
pulumiverse
python
registry
status
testingtesting123
testingtesting321
typescript
welcome
workshops
yaml
Powered by Linen
dotnet
  • b

    broad-belgium-4685

    05/06/2020, 1:45 AM
    Hi all, has anyone implemented unit tests against a stack with required config values? How are you setting/mocking config values for the tests?
    w
    • 2
    • 1
  • w

    wooden-room-54680

    05/09/2020, 3:18 PM
    I'm trying to create a resource that depends on an
    Output<ImmutableArray<T>>
    , if I try to use Linq it doesn't create the resources. I have a workaround where I don't use Linq, but is there a better way to write this? I put my use case here https://gist.github.com/fracek/a94ff73d42b8f1aa180abe885982f7a4
  • t

    tall-librarian-49374

    05/09/2020, 7:34 PM
    General guidance is to avoid defining resources inside
    Apply
    calls. I think they should still be created but you may not see them in preview. A solution with a outside
    Apply
    would be preferred.
  • w

    wooden-room-54680

    05/09/2020, 8:20 PM
    I see, so the best way is to define a list/array outside the
    Apply
    and Add the resources inside the
    Apply
    ?
  • t

    tall-librarian-49374

    05/10/2020, 6:48 AM
    Code inside Apply won't run until the Output is resolved which may not happen during preview. So, whatever you do inside Apply may not be visible. If you can, do not new-up resources there.
    👍 2
  • a

    adventurous-garage-59192

    05/11/2020, 4:24 AM
    Is there a way to explicitly mark an output as secret? I'm generating a connection string with
    Output.Format
    with a couple of sensitive values. In the old async stack system I used
    Output.CreateSecret()
    successfully, but I discovered in the new stack model that it wraps the output I give it, resulting in a signature of
    Output<Output<string>>
    , so I'm guessing it was never supposed to work that way.
    t
    • 2
    • 1
  • a

    adventurous-garage-59192

    05/11/2020, 4:32 AM
    I did try specifying
    AdditionalSecretOutputs
    on the resource property I wanted hidden, but that didn't do anything and I still got a plaintext string as the output.
  • m

    millions-journalist-34868

    05/11/2020, 12:06 PM
    It might be a stupid question, but how do you pass GetClientConfig in your stack ? I used to have everything in Program.cs before Pulumi 2.0. Now I have seen that in all the samples the infrastructure is defined in the constructors of classes that inherit from Stack. However I can't call InvokeAsync from GetClientConfig in constructors and if I call it in my Main method of Program.cs I don't know how to pass it to the stack constructor. Any idea how to do that ? It seems pretty basic but I can't find how to handle this.
    a
    • 2
    • 1
  • p

    plain-tiger-79744

    05/11/2020, 3:51 PM
    Hi! Is there any guidance on how to overcome the chicken-and-egg-problem that you need a storage account (pulumi state) and an Azure Key Vault (secrets provider) to use Pulumi? Right now I use the Azure CLI in order to create those resources, but it would be nice if I could use Pulumi instead. 🤔
    f
    m
    • 3
    • 6
  • m

    mysterious-australia-14256

    05/16/2020, 10:12 AM
    Hi. I have creates an Azure App Service using C# and specified the following (abbreviated) args
    var webApp = new AppService(name, new AppServiceArgs
    {
        ClientAffinityEnabled = false,
        HttpsOnly = true,
    }
    I then wanted to create a deployment slot with the same setting. I was hoping to be able to pass the webApp in and read the settings in its AppServiceArgs and use them to apply to the SlotArgs (to ensure that they ended up identical) e.g.
    var webAppSlot = new Slot(name, new SlotArgs
    {
        ClientAffinityEnabled = webApp.ClientAffinityEnabled,
        HttpsOnly = webApp.HttpsOnly,
    }
    This seems to work for the ClientAffinityEnabled setting but for the HttpsOnly setting I get an error... Cannot implicitly convert type 'Pulumi.Output<bool?>' to 'Pulumi.Input<bool>' Why are ClientAffinityEnabled and HttpsOnly behaving differently and is there a way to be able to read the HttpsOnly setting from the webApp and apply it to the slot App? Thanks Alan
    t
    • 2
    • 3
  • m

    mysterious-australia-14256

    05/17/2020, 8:33 PM
    I'm hoping someone with more knowledge on reflection can help me here... I'm trying use reflection in order to loop through all of the properties in a Pulumi.Azure.AppService.Inputs.AppServiceArgs object and copy them to a Pulumi.Azure.AppService.Inputs.SlotArgs object. I can manage the first level of boolean and string values like this (source is the AppServiceArgs object and target is the SlotArgs object)
    private static void CopyArgs(Object source, Object target)
    {
        foreach (var sourceProp in source.GetType().GetProperties())
        {
            var targetProp = target.GetType().GetProperty(sourceProp.Name);
    
            switch (sourceProp.PropertyType.ToString())
            {
                case "Pulumi.Input`1[System.Boolean]": 
                case "Pulumi.Input`1[System.String]": 
                    if (targetProp != null) targetProp.SetValue(child, sourceProp.GetValue(parent), null);
                    break;
                default:
                    break;
            }
        }
    }
    The problem comes when handling more complex types such as the SiteConfig which is of Type Pulumi.Azure.AppService.Inputs.AppServiceSiteConfigArgs in the parent object That is wrapped as a Pulumi.Input which means I need to call Apply to get at the contents I can manage that adding another case like this that determines the Types of the new, next level objects (e,g, the AppServiceSiteConfigArgs and SlotSiteConfigArgs in the case of SiteConfig) and then recursively calls the CopyArgs method with them as arguments...
    case "Pulumi.Input`1[Pulumi.Azure.AppService.Inputs.AppServiceSiteConfigArgs]":
                    var newSource = (Input<AppServiceSiteConfigArgs>)sourceProp.GetValue(source)!;
                    if (newSource != null)
                    {
                        newSource.Apply(x => 
                        {
                            var newTargetProp = target.GetType().GetProperty(sourceProp.Name);
                            if (newTargetProp != null) 
                            {
                                var newTarget = (Input<SlotSiteConfigArgs>)newTargetProp.GetValue(target)!;
                                if (newTarget != null)
                                {
                                    newTarget.Apply(y => 
                                    {
                                        CopyArgs(x, y);
                                        return y;
                                    });
                                }
                            }
                            return x;
                        });
                    }
                    break;
    The problem with the above is that I have hard coded in casts for (Input<AppServiceSiteConfigArgs>) and (Input<SlotSiteConfigArgs>) which means I would need a new case for each potential type. What I'd really like to do is to be able to determine the types by reflection (so I can create newSource and newTarget in the above without the fixed casts) and call the appropriate Apply methods, presumably using an Invoke command. Unfortunately I haven't been able to work out how to do that and successfully. It seems quite complicated with the mix of generics and extension methods :( If anyone has any tips they would be greatly appreciated! Thanks Alan
    t
    n
    • 3
    • 2
  • w

    wet-noon-14291

    05/21/2020, 7:14 PM
    Is it possible to build the pulumi project first and then just run the pre-compiled version or do I have to run
    pulumi up
    with the raw source available?
    t
    • 2
    • 2
  • w

    wet-noon-14291

    05/26/2020, 6:58 AM
    How do I something similar to
    getStack
    in dotnet? I can't find.
    t
    • 2
    • 2
  • w

    wet-noon-14291

    05/26/2020, 7:57 AM
    @tall-librarian-49374, what is the best way to create a
    InputUnion
    in F#? I'm using
    InputUnion.op_Implicit(80)
    , and that isn't pretty 🙂
    t
    • 2
    • 10
  • l

    limited-carpenter-34991

    05/27/2020, 2:34 PM
    If i use
    var resourceGroup = ResourceGroup.Get("resourceGBla", "/subscriptions/4711/resourceGroups/resourceGBla")
    and use it for a storage account, ResourceGroupName = resourceGroup.Name or ResourceGroupName = resourceGroup.Name.ToString() , it doesn't work. If i read in an existing resource, it is then possible to import the resource inside the stack ?
    t
    • 2
    • 4
  • l

    limited-carpenter-34991

    05/28/2020, 11:20 AM
    Is Pulumi.Azure.Core.GetClientConfig still WIP as documented with "Comming soon" ?
    t
    • 2
    • 5
  • l

    limited-carpenter-34991

    05/28/2020, 11:58 AM
    Does anyone know, how a client secret from a service principal can be created ?
    var servicePrincipal = new ServicePrincipal("sp-superUser", new ServicePrincipalArgs
    {
      ApplicationId = application.ApplicationId,
    });
    t
    • 2
    • 5
  • q

    quick-motorcycle-17856

    05/28/2020, 12:55 PM
    Hi, any guideline on how to use OutputTypeAttribute for a custom output class? I tried some things but I always end with a serialization error if I use Output<MyCustomOutput>...
    t
    • 2
    • 2
  • f

    fresh-summer-65887

    05/28/2020, 8:32 PM
    Is the best approach today to writing integration / acceptance tests in .NET is to shell out to pulumi.exe?
    t
    • 2
    • 2
  • f

    fast-dinner-32080

    05/28/2020, 10:12 PM
    We are moving to using istioctl to install onto our Kubernetes clusters but this requires running that cli tool to generate the manifests so they can be created using pulumi. 1. pulumi runs istioctl manifest genetate 2. pulumi creates/updates resources. Right now the .net provider cannot run cli commands since dynamic providers are not yet supported. Is there an update when that will be supported or will we have to manually generate them for now?
  • p

    plain-tiger-79744

    06/03/2020, 5:14 PM
    How can I run async code once that is not supported by Pulumi? I would like to use Azure Key Vault (AKV) client to import a key from another AKV (based on a given certificate).
    await akvClient.ImportKeyAsync("***.<http://vault.azure.net|vault.azure.net>", "MyKey", existingJsonWebkey);
    t
    • 2
    • 14
  • l

    limited-carpenter-34991

    06/09/2020, 9:19 AM
    Hi there, how can i check or convert the output<string> to not have a warning
    Nullability of reference types in value of type 'Output<string?>' doesn't match target type 'Output<string>'.
  • s

    shy-garage-48328

    06/09/2020, 3:13 PM
    @tall-librarian-49374 Do you have a good F# example of spinning up an AWS EC2 instance, I can't get my head around how to fetch the appropriate ami
    t
    • 2
    • 4
  • l

    limited-carpenter-34991

    06/10/2020, 7:58 PM
    Is there a way to deploy ef core migrations during a pulumi progamm? I want to deploy database changes after azure sql database initialization inside my stack.
    b
    • 2
    • 7
  • b

    boundless-tailor-35598

    06/19/2020, 9:53 AM
    I'm looking to create an EC2 instance per availability zone. I thought there used to be a C# demo that did this, but cannot find it. I check the examples project on github, but it is not there. Can anyone point me in the right direction for the code to loop through each availability zone in a given region?
  • b

    broad-dog-22463

    06/19/2020, 9:55 AM
    Maybe something like this will work
  • b

    broad-dog-22463

    06/19/2020, 9:55 AM
    var azs = Pulumi.Aws.GetAvailabilityZones.InvokeAsync(new Pulumi.Aws.GetAvailabilityZonesArgs()).Result;
    var hostnames = new List<Input<string>>();
    var ips = new List<Input<string>>();
    foreach (var az in azs.Names)
    {
        var server = new Pulumi.Aws.Ec2.Instance($"web-server-{az}", new Pulumi.Aws.Ec2.InstanceArgs
        {
            InstanceType = "t2.micro",
            VpcSecurityGroupIds = {group.Id},
            UserData = userData,
            Ami = ami.Apply(a => a.Id),
            AvailabilityZone = az,
        });
    
        hostnames.Add(server.PublicDns);
        ips.Add(server.PublicIp);
    }
  • b

    boundless-tailor-35598

    06/19/2020, 9:55 AM
    That's awesome. Thanks Paul!
  • b

    broad-dog-22463

    06/19/2020, 9:56 AM
    You will need to modify it of course
  • b

    boundless-tailor-35598

    06/19/2020, 9:56 AM
    sure, but that snippet has exactly what I was looking for.
    👍 1
Powered by Linen
Title
b

boundless-tailor-35598

06/19/2020, 9:56 AM
sure, but that snippet has exactly what I was looking for.
👍 1
View count: 2