https://pulumi.com logo
p

purple-train-14007

04/15/2021, 6:05 PM
So I have some Subnets built and a SecurityGroup. I dont see anywhere in the docs for NSG stating how you go about attaching this to a subnet. Here is my code so far
Copy code
const USNetWork = new azure_native.network.VirtualNetwork(usNetName, {
    resourceGroupName: RG,
    location: "WestUS",
    virtualNetworkName: usNetName,
    addressSpace: {
        addressPrefixes: [usAddr],
    },

});

const domainSubnetUSA = new azure_native.network.Subnet(usADDSSubnetName, {
    resourceGroupName: RG,
    subnetName: usADDSSubnetName,
    virtualNetworkName: USNetWork.name,
    addressPrefix: usADDSSubnetaddr,
  });

  const meshSubnetUSA = new azure_native.network.Subnet(usMESHSubnetName, {
    resourceGroupName: RG,
    subnetName: usMESHSubnetName,
    virtualNetworkName: USNetWork.name,
    addressPrefix: usMESHSubnetaddr,
  });

  const InboundSGUSA = new azure_native.network.NetworkSecurityGroup("InboundSG", {
    location: "WestUS",
    networkSecurityGroupName: "Test",
    resourceGroupName: RG,
    securityRules: [allowPSRM,allowRDP],
});
l

little-cartoon-10569

04/15/2021, 6:09 PM
Does
meshSubnetUSA.networkSecurityGroup = InboudSGUSA
work?
p

purple-train-14007

04/15/2021, 6:13 PM
It looks like subnet.networkSecurityGroup is readOnly.
Subnet.networkSecurityGroup: pulumi.Output<azure_native.types.output.network.NetworkSecurityGroupResponse
so it wont let me do that no.
I just looked through github to see how others are doing it and I dont see them attaching them to anything. People are just making the SG and thats it
c

cool-fireman-90027

04/15/2021, 7:28 PM
Here is an example: azure-networksg-ts
p

purple-train-14007

04/15/2021, 7:31 PM
Thanks a lot Tushar