Skip to content

Commit 2a64205

Browse files
committed
azure: Disallow cross subscription encryption sets
Since CAPZ does not support using encryption sets in a subscription not in the current subscription, adding a validation to return error if the subscriptions don't match.
1 parent b0514c8 commit 2a64205

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

pkg/asset/installconfig/azure/client.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,9 @@ func (c *Client) GetVirtualMachineSku(ctx context.Context, name, region string)
318318

319319
// GetDiskEncryptionSet retrieves the specified disk encryption set.
320320
func (c *Client) GetDiskEncryptionSet(ctx context.Context, subscriptionID, groupName, diskEncryptionSetName string) (*azenc.DiskEncryptionSet, error) {
321+
if c.ssn.Credentials.SubscriptionID != subscriptionID {
322+
return nil, fmt.Errorf("different subscription from resource group subscription. CAPZ does not support cross subscription encryption sets")
323+
}
321324
client := azenc.NewDiskEncryptionSetsClientWithBaseURI(c.ssn.Environment.ResourceManagerEndpoint, subscriptionID)
322325
client.Authorizer = c.ssn.Authorizer
323326
ctx, cancel := context.WithTimeout(ctx, 30*time.Second)
@@ -327,7 +330,6 @@ func (c *Client) GetDiskEncryptionSet(ctx context.Context, subscriptionID, group
327330
if err != nil {
328331
return nil, fmt.Errorf("failed to get disk encryption set: %w", err)
329332
}
330-
331333
return &diskEncryptionSet, nil
332334
}
333335

0 commit comments

Comments
 (0)