Author : MD TAREQ HASSAN | Updated : 2021/10/29
Using String Literal
var resourceGroup = new ResourceGroup("DemoResourceGroup", new ResourceGroupArgs
{
ResourceGroupName = "DemoRg",
Location = "japaneast",
Tags = {
["CreatedBy"] = "Pulumi",
["Scope"] = "Demo"
}
});
Using Values from Stack Settings File
- Get stack configuration values from Stack Settings File
- Use stack configuration values to create Resource Group
Pulumi.Xxx.yaml
config:
Xxx:ResourceGroupLocationKey: japaneast
Xxx:ResourceGroupNameKey: DemoRg
Xxx:ResourceGroupTagsKey:
CreatedBy: Pulumi
Scope: Demo
# ... ... ...
//
// Config namespace: Xxx
//
var config = new Config("Xxx");
var resourceGroupName = config.Require("ResourceGroupNameKey");
var resourceGroupLocation = config.Require("ResourceGroupLocationKey");
var resourceGroupTags = config.RequireObject<Dictionary<string, string>>("ResourceGroupTagsKey");
//
// Create Resource Group
//
var resourceGroup = new ResourceGroup("resourceGroup", new ResourceGroupArgs
{
ResourceGroupName = resourceGroupName,
Location = resourceGroupLocation
Tags = resourceGroupTags
});
// ... ... ...