This message was deleted.
# azure
s
This message was deleted.
g
Thanks @worried-knife-31967 that's useful, I wonder if it should be Input<T> tho? I'm trying out now with Input<T> being passed in the constructor of my component resource and it appears to be working
But it's a good idea to encapsulate all potential dependencies following that pattern, certainly makes the constructor less messy
w
if it's a hardcoded value, sure... it's a
resourceGroup.Name
as a reference to the original object, so that you get automatic dependency graph. I'm not sure if it converts automatically?
g
A snippet of what I mean:
Copy code
public class NewApp : ComponentResource 
{
    public Input<string>? ResourceGroup;
    public Input<string> ResourceGroupName;
    public NewApp(string name, Input<string>? group, ComponentResourceOptions opts) : base("NewAppType", name, opts)
    {

        var azureConfig = new Pulumi.Config("azure");
        var location = azureConfig.Require("location");

        if(group != null) {
            ResourceGroupName = group;
        }
        else {
            var resourceGroup = new AzureNextGen.Resources.Latest.ResourceGroup("rg-test-dev3", new AzureNextGen.Resources.Latest.ResourceGroupArgs {
            Location = location,
            ResourceGroupName = "rg-test-dev3"
        });

            ResourceGroupName = resourceGroup.Name;
        }
...
l
I was also wondering on the best practices to pass resources around. I figured out that
Input<XxxResourceType>
actually works, i.e.
Copy code
/// <summary>
    /// Resource group.
    /// </summary>
    [Input ("resourceGroup", required: true)]
    public ResourceGroup ResourceGroup { get; set; } = null!;
g
@little-vegetable-79574 That's pretty much what I've been using too 🙂