witty-planet-6803
07/14/2025, 5:44 PMusing Pulumi;
using Pulumi.AzureNative.Storage;
using AzureNative = Pulumi.AzureNative;
namespace MyComponents;
public class MyStorageAccount : ComponentResource
{
[Output("storageAccountId")]
public Output<string> StorageAccountId { get; private set; }
public MyStorageAccount(string name, MyStorageAccountResourceArgs args, ComponentResourceOptions? opts = null)
: base("pkg:index:MyStorageAccount", name, opts)
{
var storageAccountArgs = new StorageAccountArgs
{
AccountName = name, // Ensure 'name' is valid for Azure Storagesss
EnableHttpsTrafficOnly = true,
ResourceGroupName = args.ResourceGroupName,
Sku = new AzureNative.Storage.Inputs.SkuArgs
{
Name = SkuName.Standard_LRS,
},
Kind = Kind.StorageV2,
Location = args.Location,
};
var storageAccount = new StorageAccount(name, storageAccountArgs);
StorageAccountId = storageAccount.Id;
this.RegisterOutputs(new Dictionary<string, object?>
{
["storageAccountId"] = storageAccount.Id,
});
}
}
using Pulumi;
namespace MyComponents;
public class MyStorageAccountResourceArgs : Pulumi.ResourceArgs
{
[Input("location", required: true)]
public Input<string> Location { get; set; } = null!;
[Input("resourceGroupName", required: true)]
public Input<string> ResourceGroupName { get; set; } = null!;
}
The entire project can be found in this public repo https://github.com/Brutiquzz/pulumicomponents/blob/main/MyStorageAccount.cs
I then package it:
git commit -m "v0.0.5"
git tag v0.0.5
git push origin v0.0.5
pulumi package publish github.com/Brutiquzz/pulumicomponents@v0.0.5
// This succeeds
I then created a template
using Brutiquzz.Pulumicomponents;
using Pulumi;
public class MyStack : Pulumi.Stack
{
public MyStack()
{
var config = new Pulumi.Config();
var region = config.Require("region");
var args = new MyStorageAccountArgs()
{
Location = region,
ResourceGroupName = "brutiquzz1234"
};
var storageAccount = new MyStorageAccount("brutiquzz1234", args, null);
this.StorageAccountId = storageAccount.StorageAccountId;
}
[Output("storageAccountId")] public Output<string> StorageAccountId { get; set; }
}
using System.Threading.Tasks;
public class Program
{
private static async Task<int> Main(string[] args)
{
return await Pulumi.Deployment.RunAsync<MyStack>();
}
}
the project can be found in this public repo https://github.com/Brutiquzz/pulumiexperiment/blob/main/MyPulumiTemplate/MyStack.cs
I then do
pulumi new <https://github.com/Brutiquzz/pulumiexperiment/MyPulumiTemplate> // succeeds
When the project and stack is created I do pulumi up
and now i get the error which I can't figure out whats the problem ?
Anyone here who can spot something I can't ? 🙂echoing-dinner-19531
07/14/2025, 5:46 PMnew StorageAccount(
This should work regardless, but might be that your not setting the ResourceOptions.parent value when making the StorageAccount to tie it to the componentwitty-planet-6803
07/14/2025, 7:14 PMwitty-planet-6803
07/14/2025, 7:33 PMechoing-dinner-19531
07/14/2025, 7:51 PM