RecordSet |
## Example Usage
### Binding a DNS name to the ephemeral IP of a new instance:
```java
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.compute.Instance;
import com.pulumi.gcp.compute.InstanceArgs;
import com.pulumi.gcp.compute.inputs.InstanceBootDiskArgs;
import com.pulumi.gcp.compute.inputs.InstanceBootDiskInitializeParamsArgs;
import com.pulumi.gcp.compute.inputs.InstanceNetworkInterfaceArgs;
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) {
var frontendInstance = new Instance("frontendInstance", InstanceArgs.builder()
.machineType("g1-small")
.zone("us-central1-b")
.bootDisk(InstanceBootDiskArgs.builder()
.initializeParams(InstanceBootDiskInitializeParamsArgs.builder()
.image("debian-cloud/debian-11")
.build())
.build())
.networkInterfaces(InstanceNetworkInterfaceArgs.builder()
.network("default")
.accessConfigs()
.build())
.build());
var prod = new ManagedZone("prod", ManagedZoneArgs.builder()
.dnsName("prod.mydomain.com.")
.build());
var frontendRecordSet = new RecordSet("frontendRecordSet", RecordSetArgs.builder()
.name(prod.dnsName().applyValue(dnsName -> String.format("frontend.%s", dnsName)))
.type("A")
.ttl(300)
.managedZone(prod.name())
.rrdatas(frontendInstance.networkInterfaces().applyValue(networkInterfaces -> networkInterfaces[0].accessConfigs()[0].natIp()))
.build());
}
}
```
### Adding an A record
```java
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
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) {
var prod = new ManagedZone("prod", ManagedZoneArgs.builder()
.dnsName("prod.mydomain.com.")
.build());
var recordSet = new RecordSet("recordSet", RecordSetArgs.builder()
.name(prod.dnsName().applyValue(dnsName -> String.format("backend.%s", dnsName)))
.managedZone(prod.name())
.type("A")
.ttl(300)
.rrdatas("8.8.8.8")
.build());
}
}
```
### Adding an MX record
```java
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
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) {
var prod = new ManagedZone("prod", ManagedZoneArgs.builder()
.dnsName("prod.mydomain.com.")
.build());
var mx = new RecordSet("mx", RecordSetArgs.builder()
.name(prod.dnsName())
.managedZone(prod.name())
.type("MX")
.ttl(3600)
.rrdatas(
"1 aspmx.l.google.com.",
"5 alt1.aspmx.l.google.com.",
"5 alt2.aspmx.l.google.com.",
"10 alt3.aspmx.l.google.com.",
"10 alt4.aspmx.l.google.com.")
.build());
}
}
```
### Adding an SPF record
Quotes (`""`) must be added around your `rrdatas` for a SPF record.
|