sparse-intern-71089
10/05/2020, 11:31 AMtall-librarian-49374
10/05/2020, 11:54 AMSecurityRule
is a resource while SecurityRuleArgs
is its input type, they aren’t the same thing. When building a list of args, you should pass args objects. E.g. this will compile:
var ruleArgs1 = new Pulumi.AzureNextGen.Network.Latest.SecurityRuleArgs
{
SecurityRuleName = "RDP_3389",
//...
};
var ruleArgs2 = new Pulumi.AzureNextGen.Network.Latest.SecurityRuleArgs
{
SecurityRuleName = "Port_6516",
//...
};
var securityRules = new List<Pulumi.AzureNextGen.Network.Latest.SecurityRuleArgs> { ruleArgs1, ruleArgs2 };
orange-dog-73995
10/05/2020, 12:00 PMtall-librarian-49374
10/05/2020, 12:09 PMargs
. If you choose the latter, you create several SecurityRule
resources but do not pass them to NSG.tall-librarian-49374
10/05/2020, 12:10 PMorange-dog-73995
10/05/2020, 12:19 PMtall-librarian-49374
10/05/2020, 12:22 PMName
in both cases, can’t you?orange-dog-73995
10/05/2020, 12:23 PMvar rule1Args = new Pulumi.AzureNextGen.Network.Latest.Inputs.SecurityRuleArgs
{
Access = "Allow", //Deny, Allow
//...
};
var rule2Args = new Pulumi.AzureNextGen.Network.Latest.Inputs.SecurityRuleArgs
{
Access = "Allow", //Deny, Allow
//...
};
var securityRulesArgs = new List<Pulumi.AzureNextGen.Network.Latest.Inputs.SecurityRuleArgs> { rule1Args, rule2Args };
var nsg = new NetworkSecurityGroup("nsg", new Pulumi.AzureNextGen.Network.Latest.NetworkSecurityGroupArgs
{
Location = _resourceGroup.Location,
ResourceGroupName = _resourceGroup.Name,
NetworkSecurityGroupName = "nsg",
SecurityRules = securityRulesArgs,
});orange-dog-73995
10/05/2020, 12:24 PMtall-librarian-49374
10/05/2020, 12:26 PMvar rule2Args = new Pulumi.AzureNextGen.Network.Latest.Inputs.SecurityRuleArgs
{
Access = "Allow", //Deny, Allow
Name = "myrule",
//...
};
orange-dog-73995
10/05/2020, 12:28 PM