Tag Azure resources with UID

This commit is contained in:
katexochen 2022-08-29 11:55:46 +02:00 committed by Paul Meyer
parent 69abe17c96
commit 1861dc2744
5 changed files with 74 additions and 25 deletions

View file

@ -40,6 +40,7 @@ func (c *Client) CreateVirtualNetwork(ctx context.Context) error {
ctx, c.resourceGroup, createNetworkInput.name,
armnetwork.VirtualNetwork{
Name: to.Ptr(createNetworkInput.name), // this is supposed to be read-only
Tags: map[string]*string{"uid": to.Ptr(c.uid)},
Location: to.Ptr(createNetworkInput.location),
Properties: &armnetwork.VirtualNetworkPropertiesFormat{
AddressSpace: &armnetwork.AddressSpace{
@ -101,6 +102,7 @@ func (c *Client) CreateSecurityGroup(ctx context.Context, input NetworkSecurityG
ctx, c.resourceGroup, createNetworkSecurityGroupInput.name,
armnetwork.SecurityGroup{
Name: to.Ptr(createNetworkSecurityGroupInput.name),
Tags: map[string]*string{"uid": to.Ptr(c.uid)},
Location: to.Ptr(createNetworkSecurityGroupInput.location),
Properties: &armnetwork.SecurityGroupPropertiesFormat{
SecurityRules: createNetworkSecurityGroupInput.rules,
@ -125,6 +127,7 @@ func (c *Client) createPublicIPAddress(ctx context.Context, name string) (*armne
poller, err := c.publicIPAddressesAPI.BeginCreateOrUpdate(
ctx, c.resourceGroup, name,
armnetwork.PublicIPAddress{
Tags: map[string]*string{"uid": to.Ptr(c.uid)},
Location: to.Ptr(c.location),
SKU: &armnetwork.PublicIPAddressSKU{
Name: to.Ptr(armnetwork.PublicIPAddressSKUNameStandard),