gcp.compute.getZones
Explore with Pulumi AI
Provides access to available Google Compute zones in a region for a given project. See more about regions and zones in the upstream docs.
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.compute.ComputeFunctions;
import com.pulumi.gcp.compute.inputs.GetZonesArgs;
import com.pulumi.gcp.compute.InstanceGroupManager;
import com.pulumi.gcp.compute.InstanceGroupManagerArgs;
import com.pulumi.codegen.internal.KeyedValue;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var available = ComputeFunctions.getZones();
for (var i = 0; i < available.applyValue(getZonesResult -> getZonesResult.names()).length(); i++) {
new InstanceGroupManager("foo-" + i, InstanceGroupManagerArgs.builder()
.instanceTemplate(google_compute_instance_template.foobar().self_link())
.baseInstanceName(String.format("foobar-%s", range.value()))
.zone(available.applyValue(getZonesResult -> getZonesResult.names())[range.value()])
.targetSize(1)
.build());
}
}
}
Using getZones
Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.
function getZones(args: GetZonesArgs, opts?: InvokeOptions): Promise<GetZonesResult>
function getZonesOutput(args: GetZonesOutputArgs, opts?: InvokeOptions): Output<GetZonesResult>
def get_zones(project: Optional[str] = None,
region: Optional[str] = None,
status: Optional[str] = None,
opts: Optional[InvokeOptions] = None) -> GetZonesResult
def get_zones_output(project: Optional[pulumi.Input[str]] = None,
region: Optional[pulumi.Input[str]] = None,
status: Optional[pulumi.Input[str]] = None,
opts: Optional[InvokeOptions] = None) -> Output[GetZonesResult]
func GetZones(ctx *Context, args *GetZonesArgs, opts ...InvokeOption) (*GetZonesResult, error)
func GetZonesOutput(ctx *Context, args *GetZonesOutputArgs, opts ...InvokeOption) GetZonesResultOutput
> Note: This function is named GetZones
in the Go SDK.
public static class GetZones
{
public static Task<GetZonesResult> InvokeAsync(GetZonesArgs args, InvokeOptions? opts = null)
public static Output<GetZonesResult> Invoke(GetZonesInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetZonesResult> getZones(GetZonesArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
fn::invoke:
function: gcp:compute/getZones:getZones
arguments:
# arguments dictionary
The following arguments are supported:
- Project string
Project from which to list available zones. Defaults to project declared in the provider.
- Region string
Region from which to list available zones. Defaults to region declared in the provider.
- Status string
Allows to filter list of zones based on their current status. Status can be either
UP
orDOWN
. Defaults to no filtering (all available zones - bothUP
andDOWN
).
- Project string
Project from which to list available zones. Defaults to project declared in the provider.
- Region string
Region from which to list available zones. Defaults to region declared in the provider.
- Status string
Allows to filter list of zones based on their current status. Status can be either
UP
orDOWN
. Defaults to no filtering (all available zones - bothUP
andDOWN
).
- project String
Project from which to list available zones. Defaults to project declared in the provider.
- region String
Region from which to list available zones. Defaults to region declared in the provider.
- status String
Allows to filter list of zones based on their current status. Status can be either
UP
orDOWN
. Defaults to no filtering (all available zones - bothUP
andDOWN
).
- project string
Project from which to list available zones. Defaults to project declared in the provider.
- region string
Region from which to list available zones. Defaults to region declared in the provider.
- status string
Allows to filter list of zones based on their current status. Status can be either
UP
orDOWN
. Defaults to no filtering (all available zones - bothUP
andDOWN
).
- project str
Project from which to list available zones. Defaults to project declared in the provider.
- region str
Region from which to list available zones. Defaults to region declared in the provider.
- status str
Allows to filter list of zones based on their current status. Status can be either
UP
orDOWN
. Defaults to no filtering (all available zones - bothUP
andDOWN
).
- project String
Project from which to list available zones. Defaults to project declared in the provider.
- region String
Region from which to list available zones. Defaults to region declared in the provider.
- status String
Allows to filter list of zones based on their current status. Status can be either
UP
orDOWN
. Defaults to no filtering (all available zones - bothUP
andDOWN
).
getZones Result
The following output properties are available:
Package Details
- Repository
- Google Cloud (GCP) Classic pulumi/pulumi-gcp
- License
- Apache-2.0
- Notes
This Pulumi package is based on the
google-beta
Terraform Provider.