Google Cloud Classic v8.9.3 published on Monday, Nov 18, 2024 by Pulumi
gcp.compute.getAddresses
Explore with Pulumi AI
List IP addresses in a project. For more information see the official API list and aggregated list documentation.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const test = gcp.compute.getAddresses({
filter: "name:test-*",
});
const prod = new gcp.dns.ManagedZone("prod", {
name: "prod-zone",
dnsName: "prod.mydomain.com.",
});
const frontend = new gcp.dns.RecordSet("frontend", {
name: pulumi.interpolate`frontend.${prod.dnsName}`,
type: "A",
ttl: 300,
managedZone: prod.name,
rrdatas: test.then(test => test.addresses.map(__item => __item.address)),
});
import pulumi
import pulumi_gcp as gcp
test = gcp.compute.get_addresses(filter="name:test-*")
prod = gcp.dns.ManagedZone("prod",
name="prod-zone",
dns_name="prod.mydomain.com.")
frontend = gcp.dns.RecordSet("frontend",
name=prod.dns_name.apply(lambda dns_name: f"frontend.{dns_name}"),
type="A",
ttl=300,
managed_zone=prod.name,
rrdatas=[__item.address for __item in test.addresses])
package main
import (
"fmt"
"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/compute"
"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/dns"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
test, err := compute.GetAddresses(ctx, &compute.GetAddressesArgs{
Filter: pulumi.StringRef("name:test-*"),
}, nil)
if err != nil {
return err
}
prod, err := dns.NewManagedZone(ctx, "prod", &dns.ManagedZoneArgs{
Name: pulumi.String("prod-zone"),
DnsName: pulumi.String("prod.mydomain.com."),
})
if err != nil {
return err
}
var splat0 []*string
for _, val0 := range test.Addresses {
splat0 = append(splat0, val0.Address)
}
_, err = dns.NewRecordSet(ctx, "frontend", &dns.RecordSetArgs{
Name: prod.DnsName.ApplyT(func(dnsName string) (string, error) {
return fmt.Sprintf("frontend.%v", dnsName), nil
}).(pulumi.StringOutput),
Type: pulumi.String("A"),
Ttl: pulumi.Int(300),
ManagedZone: prod.Name,
Rrdatas: splat0,
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
var test = Gcp.Compute.GetAddresses.Invoke(new()
{
Filter = "name:test-*",
});
var prod = new Gcp.Dns.ManagedZone("prod", new()
{
Name = "prod-zone",
DnsName = "prod.mydomain.com.",
});
var frontend = new Gcp.Dns.RecordSet("frontend", new()
{
Name = prod.DnsName.Apply(dnsName => $"frontend.{dnsName}"),
Type = "A",
Ttl = 300,
ManagedZone = prod.Name,
Rrdatas = test.Apply(getAddressesResult => getAddressesResult.Addresses).Select(__item => __item.Address).ToList(),
});
});
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.GetAddressesArgs;
import com.pulumi.gcp.dns.ManagedZone;
import com.pulumi.gcp.dns.ManagedZoneArgs;
import com.pulumi.gcp.dns.RecordSet;
import com.pulumi.gcp.dns.RecordSetArgs;
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 test = ComputeFunctions.getAddresses(GetAddressesArgs.builder()
.filter("name:test-*")
.build());
var prod = new ManagedZone("prod", ManagedZoneArgs.builder()
.name("prod-zone")
.dnsName("prod.mydomain.com.")
.build());
var frontend = new RecordSet("frontend", RecordSetArgs.builder()
.name(prod.dnsName().applyValue(dnsName -> String.format("frontend.%s", dnsName)))
.type("A")
.ttl(300)
.managedZone(prod.name())
.rrdatas(test.applyValue(getAddressesResult -> getAddressesResult.addresses()).stream().map(element -> element.address()).collect(toList()))
.build());
}
}
Coming soon!
Using getAddresses
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 getAddresses(args: GetAddressesArgs, opts?: InvokeOptions): Promise<GetAddressesResult>
function getAddressesOutput(args: GetAddressesOutputArgs, opts?: InvokeOptions): Output<GetAddressesResult>
def get_addresses(filter: Optional[str] = None,
project: Optional[str] = None,
region: Optional[str] = None,
opts: Optional[InvokeOptions] = None) -> GetAddressesResult
def get_addresses_output(filter: Optional[pulumi.Input[str]] = None,
project: Optional[pulumi.Input[str]] = None,
region: Optional[pulumi.Input[str]] = None,
opts: Optional[InvokeOptions] = None) -> Output[GetAddressesResult]
func GetAddresses(ctx *Context, args *GetAddressesArgs, opts ...InvokeOption) (*GetAddressesResult, error)
func GetAddressesOutput(ctx *Context, args *GetAddressesOutputArgs, opts ...InvokeOption) GetAddressesResultOutput
> Note: This function is named GetAddresses
in the Go SDK.
public static class GetAddresses
{
public static Task<GetAddressesResult> InvokeAsync(GetAddressesArgs args, InvokeOptions? opts = null)
public static Output<GetAddressesResult> Invoke(GetAddressesInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetAddressesResult> getAddresses(GetAddressesArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
fn::invoke:
function: gcp:compute/getAddresses:getAddresses
arguments:
# arguments dictionary
The following arguments are supported:
- Filter string
- A filter expression that filters resources listed in the response. The expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either "=", "!=", ">", "<", "<=", ">=" or ":". For example, if you are filtering Compute Engine instances, you can exclude instances named "example-instance" by specifying "name != example-instance". The ":" operator can be used with string fields to match substrings. For non-string fields it is equivalent to the "=" operator. The ":" comparison can be used to test whether a key has been defined. For example, to find all objects with "owner" label use: """ labels.owner: """ You can also filter nested fields. For example, you could specify "scheduling.automaticRestart = false" to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: """ (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") """ By default, each expression is an "AND" expression. However, you can include "AND" and "OR" expressions explicitly. For example: """ (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true)
- Project string
- The google project in which addresses are listed. Defaults to provider's configuration if missing.
- Region string
- Region that should be considered to search addresses. All regions are considered if missing.
- Filter string
- A filter expression that filters resources listed in the response. The expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either "=", "!=", ">", "<", "<=", ">=" or ":". For example, if you are filtering Compute Engine instances, you can exclude instances named "example-instance" by specifying "name != example-instance". The ":" operator can be used with string fields to match substrings. For non-string fields it is equivalent to the "=" operator. The ":" comparison can be used to test whether a key has been defined. For example, to find all objects with "owner" label use: """ labels.owner: """ You can also filter nested fields. For example, you could specify "scheduling.automaticRestart = false" to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: """ (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") """ By default, each expression is an "AND" expression. However, you can include "AND" and "OR" expressions explicitly. For example: """ (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true)
- Project string
- The google project in which addresses are listed. Defaults to provider's configuration if missing.
- Region string
- Region that should be considered to search addresses. All regions are considered if missing.
- filter String
- A filter expression that filters resources listed in the response. The expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either "=", "!=", ">", "<", "<=", ">=" or ":". For example, if you are filtering Compute Engine instances, you can exclude instances named "example-instance" by specifying "name != example-instance". The ":" operator can be used with string fields to match substrings. For non-string fields it is equivalent to the "=" operator. The ":" comparison can be used to test whether a key has been defined. For example, to find all objects with "owner" label use: """ labels.owner: """ You can also filter nested fields. For example, you could specify "scheduling.automaticRestart = false" to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: """ (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") """ By default, each expression is an "AND" expression. However, you can include "AND" and "OR" expressions explicitly. For example: """ (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true)
- project String
- The google project in which addresses are listed. Defaults to provider's configuration if missing.
- region String
- Region that should be considered to search addresses. All regions are considered if missing.
- filter string
- A filter expression that filters resources listed in the response. The expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either "=", "!=", ">", "<", "<=", ">=" or ":". For example, if you are filtering Compute Engine instances, you can exclude instances named "example-instance" by specifying "name != example-instance". The ":" operator can be used with string fields to match substrings. For non-string fields it is equivalent to the "=" operator. The ":" comparison can be used to test whether a key has been defined. For example, to find all objects with "owner" label use: """ labels.owner: """ You can also filter nested fields. For example, you could specify "scheduling.automaticRestart = false" to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: """ (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") """ By default, each expression is an "AND" expression. However, you can include "AND" and "OR" expressions explicitly. For example: """ (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true)
- project string
- The google project in which addresses are listed. Defaults to provider's configuration if missing.
- region string
- Region that should be considered to search addresses. All regions are considered if missing.
- filter str
- A filter expression that filters resources listed in the response. The expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either "=", "!=", ">", "<", "<=", ">=" or ":". For example, if you are filtering Compute Engine instances, you can exclude instances named "example-instance" by specifying "name != example-instance". The ":" operator can be used with string fields to match substrings. For non-string fields it is equivalent to the "=" operator. The ":" comparison can be used to test whether a key has been defined. For example, to find all objects with "owner" label use: """ labels.owner: """ You can also filter nested fields. For example, you could specify "scheduling.automaticRestart = false" to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: """ (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") """ By default, each expression is an "AND" expression. However, you can include "AND" and "OR" expressions explicitly. For example: """ (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true)
- project str
- The google project in which addresses are listed. Defaults to provider's configuration if missing.
- region str
- Region that should be considered to search addresses. All regions are considered if missing.
- filter String
- A filter expression that filters resources listed in the response. The expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either "=", "!=", ">", "<", "<=", ">=" or ":". For example, if you are filtering Compute Engine instances, you can exclude instances named "example-instance" by specifying "name != example-instance". The ":" operator can be used with string fields to match substrings. For non-string fields it is equivalent to the "=" operator. The ":" comparison can be used to test whether a key has been defined. For example, to find all objects with "owner" label use: """ labels.owner: """ You can also filter nested fields. For example, you could specify "scheduling.automaticRestart = false" to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: """ (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") """ By default, each expression is an "AND" expression. However, you can include "AND" and "OR" expressions explicitly. For example: """ (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true)
- project String
- The google project in which addresses are listed. Defaults to provider's configuration if missing.
- region String
- Region that should be considered to search addresses. All regions are considered if missing.
getAddresses Result
The following output properties are available:
Supporting Types
GetAddressesAddress
- Address string
- The IP address (for example
1.2.3.4
). - Address
Type string - The IP address type, can be
EXTERNAL
orINTERNAL
. - Description string
- The IP address description.
- Labels Dictionary<string, string>
- A map containing IP labels.
- Name string
- The IP address name.
- Region string
- Region that should be considered to search addresses. All regions are considered if missing.
- Self
Link string - The URI of the created resource.
- Status string
- Indicates if the address is used. Possible values are: RESERVED or IN_USE.
- Address string
- The IP address (for example
1.2.3.4
). - Address
Type string - The IP address type, can be
EXTERNAL
orINTERNAL
. - Description string
- The IP address description.
- Labels map[string]string
- A map containing IP labels.
- Name string
- The IP address name.
- Region string
- Region that should be considered to search addresses. All regions are considered if missing.
- Self
Link string - The URI of the created resource.
- Status string
- Indicates if the address is used. Possible values are: RESERVED or IN_USE.
- address String
- The IP address (for example
1.2.3.4
). - address
Type String - The IP address type, can be
EXTERNAL
orINTERNAL
. - description String
- The IP address description.
- labels Map<String,String>
- A map containing IP labels.
- name String
- The IP address name.
- region String
- Region that should be considered to search addresses. All regions are considered if missing.
- self
Link String - The URI of the created resource.
- status String
- Indicates if the address is used. Possible values are: RESERVED or IN_USE.
- address string
- The IP address (for example
1.2.3.4
). - address
Type string - The IP address type, can be
EXTERNAL
orINTERNAL
. - description string
- The IP address description.
- labels {[key: string]: string}
- A map containing IP labels.
- name string
- The IP address name.
- region string
- Region that should be considered to search addresses. All regions are considered if missing.
- self
Link string - The URI of the created resource.
- status string
- Indicates if the address is used. Possible values are: RESERVED or IN_USE.
- address str
- The IP address (for example
1.2.3.4
). - address_
type str - The IP address type, can be
EXTERNAL
orINTERNAL
. - description str
- The IP address description.
- labels Mapping[str, str]
- A map containing IP labels.
- name str
- The IP address name.
- region str
- Region that should be considered to search addresses. All regions are considered if missing.
- self_
link str - The URI of the created resource.
- status str
- Indicates if the address is used. Possible values are: RESERVED or IN_USE.
- address String
- The IP address (for example
1.2.3.4
). - address
Type String - The IP address type, can be
EXTERNAL
orINTERNAL
. - description String
- The IP address description.
- labels Map<String>
- A map containing IP labels.
- name String
- The IP address name.
- region String
- Region that should be considered to search addresses. All regions are considered if missing.
- self
Link String - The URI of the created resource.
- status String
- Indicates if the address is used. Possible values are: RESERVED or IN_USE.
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.