@@ -23,12 +23,14 @@ func init() {
2323 vpcpeeringrouteCreateCmd .Flags ().String ("name" , "" , "VPC Peering Route name (required)" )
2424 vpcpeeringrouteCreateCmd .Flags ().String ("local-network" , "" , "Local network address in CIDR notation (required)" )
2525 vpcpeeringrouteCreateCmd .Flags ().String ("remote-network" , "" , "Remote network address in CIDR notation (required)" )
26+ vpcpeeringrouteCreateCmd .Flags ().String ("region" , "" , "Region code (required)" )
2627 vpcpeeringrouteCreateCmd .Flags ().String ("billing-period" , "Hour" , "Billing period: Hour, Month, Year" )
2728 vpcpeeringrouteCreateCmd .Flags ().StringSlice ("tags" , []string {}, "Tags (comma-separated)" )
2829 vpcpeeringrouteCreateCmd .Flags ().BoolP ("verbose" , "v" , false , "Show detailed debug information" )
2930 vpcpeeringrouteCreateCmd .MarkFlagRequired ("name" )
3031 vpcpeeringrouteCreateCmd .MarkFlagRequired ("local-network" )
3132 vpcpeeringrouteCreateCmd .MarkFlagRequired ("remote-network" )
33+ vpcpeeringrouteCreateCmd .MarkFlagRequired ("region" )
3234
3335 vpcpeeringrouteGetCmd .Flags ().String ("project-id" , "" , "Project ID (uses context if not specified)" )
3436
@@ -107,6 +109,7 @@ with --remote-network. Both values should be valid CIDR blocks.
107109Billing period: Hour (default), Month, or Year.` ,
108110 Example : ` acloud network vpcpeeringroute create <vpc-id> <peering-id> \
109111 --name my-route \
112+ --region ITBG-Bergamo \
110113 --local-network 10.0.0.0/24 \
111114 --remote-network 10.1.0.0/24` ,
112115 Args : cobra .ExactArgs (2 ),
@@ -115,6 +118,7 @@ Billing period: Hour (default), Month, or Year.`,
115118 peeringID := args [1 ]
116119
117120 name , _ := cmd .Flags ().GetString ("name" )
121+ region , _ := cmd .Flags ().GetString ("region" )
118122 localNetwork , _ := cmd .Flags ().GetString ("local-network" )
119123 remoteNetwork , _ := cmd .Flags ().GetString ("remote-network" )
120124 billingPeriod , _ := cmd .Flags ().GetString ("billing-period" )
@@ -133,9 +137,12 @@ Billing period: Hour (default), Month, or Year.`,
133137
134138 // Build the create request
135139 req := types.VPCPeeringRouteRequest {
136- Metadata : types.ResourceMetadataRequest {
137- Name : name ,
138- Tags : tags ,
140+ Metadata : types.RegionalResourceMetadataRequest {
141+ ResourceMetadataRequest : types.ResourceMetadataRequest {
142+ Name : name ,
143+ Tags : tags ,
144+ },
145+ Location : types.LocationRequest {Value : region },
139146 },
140147 Properties : types.VPCPeeringRoutePropertiesRequest {
141148 LocalNetworkAddress : localNetwork ,
@@ -375,27 +382,36 @@ var vpcpeeringrouteUpdateCmd = &cobra.Command{
375382 return fmt .Errorf ("cannot update VPC peering route while it is in 'InCreation' state. Please wait until the VPC peering route is fully created" )
376383 }
377384
385+ // Preserve the region from the current resource for the update request.
386+ var regionValue string
387+ if current .Metadata .LocationResponse != nil {
388+ regionValue = current .Metadata .LocationResponse .Value
389+ }
390+
378391 // Build update request by merging user input with current values
379392 req := types.VPCPeeringRouteRequest {
380- Metadata : types.ResourceMetadataRequest {
381- Name : func () string {
382- if name != "" {
383- return name
384- }
385- if current .Metadata .Name != nil {
386- return * current .Metadata .Name
387- }
388- return ""
389- }(),
390- Tags : func () []string {
391- if cmd .Flags ().Changed ("tags" ) {
392- return tags
393- }
394- if current .Metadata .Tags != nil {
395- return current .Metadata .Tags
396- }
397- return []string {}
398- }(),
393+ Metadata : types.RegionalResourceMetadataRequest {
394+ ResourceMetadataRequest : types.ResourceMetadataRequest {
395+ Name : func () string {
396+ if name != "" {
397+ return name
398+ }
399+ if current .Metadata .Name != nil {
400+ return * current .Metadata .Name
401+ }
402+ return ""
403+ }(),
404+ Tags : func () []string {
405+ if cmd .Flags ().Changed ("tags" ) {
406+ return tags
407+ }
408+ if current .Metadata .Tags != nil {
409+ return current .Metadata .Tags
410+ }
411+ return []string {}
412+ }(),
413+ },
414+ Location : types.LocationRequest {Value : regionValue },
399415 },
400416 Properties : types.VPCPeeringRoutePropertiesRequest {
401417 LocalNetworkAddress : func () string {
0 commit comments