Mencadangkan alamat IP eksternal statis

Anda dapat mereservasi alamat IP eksternal statis. Anda juga dapat mencantumkan dan merilis alamat IP eksternal statis yang dicadangkan. Untuk menetapkan alamat IP eksternal statis ke instance virtual machine (VM), lihat Mengonfigurasi alamat IP eksternal statis.

Alamat IP eksternal dapat bersifat statis atau sementara. Jika VM memerlukan alamat IP eksternal tetap yang tidak berubah, Anda dapat mendapatkan alamat IP eksternal statis. Anda dapat mencadangkan alamat IP eksternal baru atau mempromosikan alamat IP eksternal sementara yang sudah ada.

Jika Anda memerlukan alamat IP internal statis, lihat Mencadangkan alamat IP internal statis.

Sebelum memulai

  • Baca tentang alamat IP.
  • Baca kuota dan batas untuk alamat IP eksternal statis.
  • Baca tentang harga alamat IP eksternal.
  • Siapkan autentikasi jika Anda belum melakukannya. Autentikasi adalah proses yang digunakan untuk memverifikasi identitas Anda agar dapat mengakses layanan dan API Google Cloud. Untuk menjalankan kode atau contoh dari lingkungan pengembangan lokal, Anda dapat mengautentikasi sebagai berikut.

    Select the tab for how you plan to use the samples on this page:

    Console

    When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.

    gcloud

    Install the Google Cloud CLI, then initialize it by running the following command:

    gcloud init

    Terraform

    Untuk menggunakan contoh Terraform di halaman ini dalam lingkungan pengembangan lokal, instal dan lakukan inisialisasi gcloud CLI, lalu siapkan Kredensial Default Aplikasi dengan kredensial pengguna Anda.

    1. Install the Google Cloud CLI.
    2. To initialize the gcloud CLI, run the following command:

      gcloud init
    3. If you're using a local shell, then create local authentication credentials for your user account:

      gcloud auth application-default login

      You don't need to do this if you're using Cloud Shell.

    Untuk informasi selengkapnya, lihat Menyiapkan autentikasi untuk lingkungan pengembangan lokal dalam dokumentasi autentikasi Google Cloud.

    REST

    Untuk menggunakan contoh REST API di halaman ini dalam lingkungan pengembangan lokal, gunakan kredensial yang Anda berikan ke gcloud CLI.

      Install the Google Cloud CLI, then initialize it by running the following command:

      gcloud init

    Untuk informasi selengkapnya, lihat Melakukan autentikasi untuk menggunakan REST dalam dokumentasi autentikasi Google Cloud.

Peran yang diperlukan

Untuk mendapatkan izin yang diperlukan untuk memesan dan mengelola alamat IP statis, minta administrator untuk memberi Anda peran IAM Compute Network Admin (roles/compute.networkAdmin) di project Anda. Untuk mengetahui informasi selengkapnya tentang cara memberikan peran, lihat Mengelola akses ke project, folder, dan organisasi.

Peran bawaan ini berisi izin yang diperlukan untuk memesan dan mengelola alamat IP statis. Untuk melihat izin yang benar-benar diperlukan, luaskan bagian Izin yang diperlukan:

Izin yang diperlukan

Izin berikut diperlukan untuk mencadangkan dan mengelola alamat IP statis:

  • compute.addresses.create di alamat IP
  • compute.addresses.createInternal di alamat IP
  • compute.networks.list di jaringan
  • compute.subnetworks.use di subnet
  • compute.subnetworks.list di subnet

Anda mungkin juga bisa mendapatkan izin ini dengan peran khusus atau peran bawaan lainnya.

Tentang alamat IP eksternal statis

Alamat IP eksternal statis adalah alamat IP yang dicadangkan untuk resource Anda sampai Anda memutuskan untuk merilisnya. Jika memiliki alamat IP yang diandalkan pelanggan atau pengguna untuk mengakses layanan Anda, Anda dapat mencadangkan alamat IP tersebut sehingga hanya resource Anda yang dapat menggunakannya. Anda juga dapat mempromosikan alamat IP eksternal sementara menjadi alamat IP eksternal statis.

Untuk mengetahui informasi selengkapnya, lihat Alamat IP.

Tabel berikut mencantumkan alamat IP eksternal statis yang didukung oleh Google Cloud.

Jenis alamat IP Resource Rentang IP Asal Dikaitkan dengan
Alamat IPv4 eksternal regional VM dan load balancer regional /32 Kumpulan alamat IP eksternal Google Project
Alamat IPv6 eksternal regional VM dan load balancer regional yang didukung /96 Rentang alamat IPv6 eksternal subnet Subnet
Alamat IPv4 eksternal global Load balancer global /32 Kumpulan alamat IP eksternal Google Project
Alamat IPv6 eksternal global Load balancer global /64 Kumpulan alamat IP eksternal Google Project

Untuk mengetahui daftar load balancer regional dan global, lihat Ringkasan jenis load balancer.

Batasan

  • Hanya satu resource dalam satu waktu yang dapat menggunakan alamat IP eksternal statis.

  • Tidak ada cara untuk memeriksa apakah alamat IP bersifat statis atau sementara setelah ditetapkan ke resource. Anda dapat membandingkan alamat IP dengan daftar alamat IP eksternal statis yang dicadangkan untuk project tersebut. Gunakan sub-perintah gcloud compute addresses list untuk melihat daftar alamat IP eksternal statis yang tersedia untuk project.

  • Setiap VM dapat memiliki beberapa antarmuka jaringan, dan setiap antarmuka dapat memiliki alamat IP berikut yang ditetapkan:

    • Alamat IPv4 internal (wajib)
    • Alamat IPv4 eksternal
    • Rentang alamat IPv6 /96, baik internal maupun eksternal, tetapi tidak keduanya
  • Anda tidak dapat mengubah nama alamat IP statis.

  • Alamat IP eksternal yang ditetapkan berada di host fisik yang sama dengan VM dan berada di region yang sama dengan VM untuk semua tujuan, termasuk perutean, latensi, dan harga. Hal ini berlaku terlepas dari informasi pencarian geolokasi internet.

Catatan: Antarmuka jaringan dapat menerima traffic dari beberapa aturan penerusan, yang mungkin menyalurkan alamat IP eksternal lainnya. Sejumlah alamat IP eksternal dapat mereferensikan antarmuka jaringan melalui aturan penerusan ini, tetapi setiap antarmuka jaringan hanya dapat ditetapkan satu alamat IPv4 eksternal dan satu rentang alamat IPv6 /96 eksternal.

Untuk mengetahui informasi selengkapnya tentang aturan penerusan dan load balancing, baca dokumentasi load balancing.

Mereservasi alamat IP eksternal statis baru

Setelah memesan alamat, tetapkan alamat tersebut ke VM baru saat membuatnya atau ke VM yang ada.

Konsol

  1. Di Konsol Google Cloud, buka halaman IP addresses.

    Buka alamat IP

  2. Klik Reserve external static IP address.
  3. Di kolom Name, masukkan nama alamat IP.
  4. Tentukan apakah tingkat layanan jaringan adalah Premium atau Standard. Pemesanan alamat statis IPv6 hanya didukung pada paket Premium.
  5. Tentukan apakah alamat tersebut adalah alamat IPv4 atau IPv6.
  6. Tentukan apakah alamat IP ini adalah Regional atau Global.
    • Jika Anda mencadangkan alamat IP statis untuk load balancer global, pilih Global lalu klik Reserve.
    • Jika Anda mencadangkan alamat IP statis untuk VM atau untuk load balancer regional, pilih Regional, lalu pilih region tempat pembuatan alamat.
  7. Jika Anda mencadangkan alamat IPv6 eksternal regional, pilih juga hal berikut:

    • Network: jaringan VPC
    • Subnetwork: subnet tempat untuk menetapkan alamat IPv6 regional statis
    • Endpoint type: pilih VM instance atau Network Load Balancer
  8. Opsional: Jika Anda mencadangkan alamat IP eksternal statis untuk VM, maka dalam daftar Attached to, pilih VM yang akan dipasang dengan alamat IP.

  9. Klik Reserve untuk mereservasi alamat IP.

gcloud

Untuk mencadangkan alamat IP eksternal statis, gunakan perintah gcloud compute addresses create.

Gunakan petunjuk berikut untuk memesan alamat IPv4 atau IPv6 eksternal statis:

Alamat IP global

Untuk mencadangkan alamat IP global:
  gcloud compute addresses create ADDRESS_NAME \
      --global \
      --ip-version [IPV4 | IPV6]
  

Alamat IPv4 eksternal regional

Untuk mencadangkan alamat IPv4 eksternal regional:
   gcloud compute addresses create ADDRESS_NAME \
       --region=REGION
   

Alamat IPv6 eksternal regional

Untuk mencadangkan alamat IPv6 eksternal regional:
   gcloud compute addresses create ADDRESS_NAME \
       --region=REGION \
       --subnet=SUBNET_NAME \
       --ip-version=IPV6 \
       --endpoint-type=[VM | NETLB]
   

Ganti kode berikut:

  • ADDRESS_NAME: nama yang ingin Anda kaitkan dengan alamat ini.
  • REGION: untuk alamat IP eksternal regional, tentukan region tempat Anda ingin mencadangkan alamat ini. Region ini harus merupakan region yang sama dengan resource tempat Anda ingin tambahkan alamat IP.
  • SUBNET_NAME: untuk alamat IPv6 eksternal regional, tentukan subnet tempat alamat IPv6 regional statis ditetapkan. Subnet harus memiliki rentang alamat IPv6 eksternal yang ditetapkan.
  • [IPV4 | IPV6]: untuk alamat IP global, tentukan versi IP, baik IPv4 maupun IPv6. Untuk alamat IPv6 eksternal regional, tentukan IPv6. Rentang IPv6 /96 ditetapkan dari subnet yang ditentukan.
  • VM | NETLB: untuk alamat IPv6 eksternal regional, tentukan jenis endpoint; baik VM maupun load balancer jaringan.

Untuk melihat hasilnya, gunakan perintah gcloud compute addresses describe:

gcloud compute addresses describe ADDRESS_NAME

Terraform

Anda dapat menggunakan resource google_compute_address untuk membuat alamat IP eksternal regional.

resource "google_compute_address" "default" {
  name   = "my-test-static-ip-address"
  region = "us-central1"
}

Contoh berikut menunjukkan cara menggunakan resource google_compute_global_address untuk membuat alamat IPv6 eksternal global:

resource "google_compute_global_address" "default" {
  project      = var.project_id # Replace this with your service project ID in quotes
  name         = "ipv6-address"
  address_type = "EXTERNAL"
  ip_version   = "IPV6"
}

API

  • Untuk membuat alamat IPv4 regional, panggil metode addresses.insert regional:

    POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/addresses
    

    Isi permintaan Anda harus berisi informasi berikut:

    {
      "name": "ADDRESS_NAME"
    }
    

    Ganti kode berikut:

    • PROJECT_ID: project ID untuk permintaan ini
    • REGION: nama region untuk permintaan ini
    • ADDRESS_NAME: nama yang ingin Anda kaitkan dengan alamat
  • Untuk alamat IPv4 statis global, panggil metode globalAddresses.insert:

    POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/global/addresses
    

    Isi permintaan Anda harus berisi informasi berikut:

    {
      "name": "ADDRESS_NAME"
    }
    
  • Untuk alamat IPv6 statis global, panggil metode globalAddresses.insert:

    POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/global/addresses
    

    Isi permintaan Anda harus berisi informasi berikut:

    {
      "name": "ADDRESS_NAME",
      "ipVersion": "IPV6"
    }
    

    Untuk melihat hasilnya, gunakan metode addresses.get.

  • Untuk alamat IPv6 statis regional, panggil metode addresses.insert:

    POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/addresses
    

    Isi permintaan Anda harus berisi informasi berikut:

    {
      "name": "ADDRESS_NAME",
      "ipVersion": "IPV6",
      "ipv6EndpointType": "VM|LB",
      "networkTier": "PREMIUM",
      "subnetwork": "SUBNET"
    }
    

    Ganti SUBNET dengan subnet untuk project ini.

    Untuk melihat hasilnya, gunakan metode addresses.get.

Go

import (
	"context"
	"fmt"
	"io"

	compute "cloud.google.com/go/compute/apiv1"
	"cloud.google.com/go/compute/apiv1/computepb"
)

// reserveNewRegionalExternal reserves a new regional external IP address in Google Cloud Platform.
func reserveNewRegionalExternal(w io.Writer, projectID, region, addressName string, isPremium bool) (*computepb.Address, error) {
	// projectID := "your_project_id"
	// region := "europe-central2"
	// addressName := "your_address_name"
	// isPremium := true
	ctx := context.Background()

	networkTier := computepb.AccessConfig_STANDARD.String()
	if isPremium {
		networkTier = computepb.AccessConfig_PREMIUM.String()
	}

	address := &computepb.Address{
		Name:        &addressName,
		NetworkTier: &networkTier,
	}

	client, err := compute.NewAddressesRESTClient(ctx)
	if err != nil {
		return nil, fmt.Errorf("NewAddressesRESTClient: %w", err)
	}
	defer client.Close()

	req := &computepb.InsertAddressRequest{
		Project:         projectID,
		Region:          region,
		AddressResource: address,
	}

	op, err := client.Insert(ctx, req)
	if err != nil {
		return nil, fmt.Errorf("unable to reserve regional address: %w", err)
	}

	err = op.Wait(ctx)
	if err != nil {
		return nil, fmt.Errorf("waiting for the regional address reservation operation to complete: %w", err)
	}

	addressResult, err := client.Get(ctx, &computepb.GetAddressRequest{
		Project: projectID,
		Region:  region,
		Address: addressName,
	})
	if err != nil {
		return nil, fmt.Errorf("unable to get reserved regional address: %w", err)
	}

	fmt.Fprintf(w, "Regional address %v reserved: %v", addressName, addressResult.GetAddress())

	return addressResult, err
}

// reserveNewGlobalExternal reserves a new global external IP address in Google Cloud Platform.
func reserveNewGlobalExternal(w io.Writer, projectID, addressName string, isV6 bool) (*computepb.Address, error) {
	// projectID := "your_project_id"
	// addressName := "your_address_name"
	// isV6 := false
	ctx := context.Background()
	ipVersion := computepb.Address_IPV4.String()
	if isV6 {
		ipVersion = computepb.Address_IPV6.String()
	}

	address := &computepb.Address{
		Name:      &addressName,
		IpVersion: &ipVersion,
	}

	client, err := compute.NewGlobalAddressesRESTClient(ctx)
	if err != nil {
		return nil, fmt.Errorf("NewGlobalAddressesRESTClient: %w", err)
	}
	defer client.Close()

	req := &computepb.InsertGlobalAddressRequest{
		Project:         projectID,
		AddressResource: address,
	}

	op, err := client.Insert(ctx, req)
	if err != nil {
		return nil, fmt.Errorf("unable to reserve global address: %w", err)
	}

	err = op.Wait(ctx)
	if err != nil {
		return nil, fmt.Errorf("waiting for the global address reservation operation to complete: %w", err)
	}

	addressResult, err := client.Get(ctx, &computepb.GetGlobalAddressRequest{
		Project: projectID,
		Address: addressName,
	})
	if err != nil {
		return nil, fmt.Errorf("unable to get reserved global address: %w", err)
	}

	fmt.Fprintf(w, "Global address %v reserved: %v", addressName, addressResult.GetAddress())

	return addressResult, nil
}

Java


import com.google.cloud.compute.v1.Address;
import com.google.cloud.compute.v1.Address.AddressType;
import com.google.cloud.compute.v1.Address.IpVersion;
import com.google.cloud.compute.v1.Address.NetworkTier;
import com.google.cloud.compute.v1.AddressesClient;
import com.google.cloud.compute.v1.GlobalAddressesClient;
import com.google.cloud.compute.v1.InsertAddressRequest;
import com.google.cloud.compute.v1.InsertGlobalAddressRequest;
import com.google.common.collect.Lists;
import java.io.IOException;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class ReserveNewExternalAddress {

  public static void main(String[] args)
          throws IOException, ExecutionException, InterruptedException, TimeoutException {
    // TODO(developer): Replace these variables before running the sample.
    // Project ID or project number of the Google Cloud project you want to use.
    String projectId = "your-project-id";
    // Address name you want to use.
    String addressName = "your-address-name";
    // 'IPV4' or 'IPV6' depending on the IP version. IPV6 if True. Option only for global regions.
    boolean ipV6 = false;
    // 'STANDARD' or 'PREMIUM' network tier. Standard option available only in regional ip.
    boolean isPremium = false;
    // region (Optional[str]): The region to reserve the IP address in, if regional.
    // Must be None if global.
    String region = null;

    reserveNewExternalIpAddress(projectId, addressName, ipV6, isPremium, region);
  }

  // Reserves a new external IP address in the specified project and region.
  public static List<Address> reserveNewExternalIpAddress(String projectId, String addressName,
                                                          boolean ipV6, boolean isPremium,
                                                          String region)
          throws IOException, ExecutionException, InterruptedException, TimeoutException {

    String ipVersion = ipV6 ? IpVersion.IPV6.name() : IpVersion.IPV4.name();
    String networkTier = !isPremium && region != null
            ? NetworkTier.STANDARD.name() : NetworkTier.PREMIUM.name();

    Address.Builder address = Address.newBuilder()
            .setName(addressName)
            .setAddressType(AddressType.EXTERNAL.name())
            .setNetworkTier(networkTier);

    // Use global client if no region is specified
    if (region == null) {
      // Initialize client that will be used to send requests. This client only needs to be created
      // once, and can be reused for multiple requests.
      try (GlobalAddressesClient client = GlobalAddressesClient.create()) {
        address.setIpVersion(ipVersion);

        InsertGlobalAddressRequest addressRequest = InsertGlobalAddressRequest.newBuilder()
                .setProject(projectId)
                .setRequestId(UUID.randomUUID().toString())
                .setAddressResource(address.build())
                .build();

        client.insertCallable().futureCall(addressRequest).get(30, TimeUnit.SECONDS);

        return Lists.newArrayList(client.list(projectId).iterateAll());
      }
    } else {
      // Initialize client that will be used to send requests. This client only needs to be created
      // once, and can be reused for multiple requests.
      try (AddressesClient client = AddressesClient.create()) {
        address.setRegion(region);

        InsertAddressRequest addressRequest = InsertAddressRequest.newBuilder()
                .setProject(projectId)
                .setRequestId(UUID.randomUUID().toString())
                .setAddressResource(address.build())
                .setRegion(region)
                .build();

        client.insertCallable().futureCall(addressRequest).get(30, TimeUnit.SECONDS);

        return Lists.newArrayList(client.list(projectId, region).iterateAll());
      }
    }
  }
}

Python

from typing import Optional

from google.cloud.compute_v1.services.addresses.client import AddressesClient
from google.cloud.compute_v1.services.global_addresses import GlobalAddressesClient
from google.cloud.compute_v1.types import Address


def reserve_new_external_ip_address(
    project_id: str,
    address_name: str,
    is_v6: bool = False,
    is_premium: bool = False,
    region: Optional[str] = None,
):
    """
    Reserves a new external IP address in the specified project and region.

    Args:
    project_id (str): Your Google Cloud project ID.
    address_name (str): The name for the new IP address.
    is_v6 (bool): 'IPV4' or 'IPV6' depending on the IP version. IPV6 if True.
    is_premium (bool): 'STANDARD' or 'PREMIUM' network tier. Standard option available only in regional ip.
    region (Optional[str]): The region to reserve the IP address in, if regional. Must be None if global.

    Returns:
    None
    """

    ip_version = "IPV6" if is_v6 else "IPV4"
    network_tier = "STANDARD" if not is_premium and region else "PREMIUM"

    address = Address(
        name=address_name,
        address_type="EXTERNAL",
        network_tier=network_tier,
    )
    if not region:  # global IP address
        client = GlobalAddressesClient()
        address.ip_version = ip_version
        operation = client.insert(project=project_id, address_resource=address)
    else:  # regional IP address
        address.region = region
        client = AddressesClient()
        operation = client.insert(
            project=project_id, region=region, address_resource=address
        )

    operation.result()

    print(f"External IP address '{address_name}' reserved successfully.")

Mempromosikan alamat IP eksternal sementara

Jika VM Anda memiliki alamat IP eksternal sementara dan Anda ingin menetapkan alamat IP ke project secara permanen, promosikan alamat IP eksternal sementara menjadi alamat IP eksternal statis. Mempromosikan alamat IP eksternal sementara menjadi dicadangkan tidak menyebabkan Google Cloud menghapus paket yang dikirim ke VM. Termasuk paket yang dikirim ke VM secara langsung atau melalui load balancer.

Konsol

  1. Buka halaman Alamat IP.

    Buka alamat IP

  2. Klik Alamat IP eksternal.
  3. Opsional: Di kolom Filter, telusuri alamat IP sementara yang ingin Anda promosikan.
  4. Pada menu Tindakan lainnya () di alamat IP yang ingin dipromosikan, pilih Promosikan ke alamat IP statis.
  5. Masukkan nama untuk alamat IP statis baru, lalu klik Cadangkan.

gcloud

Gunakan petunjuk berikut untuk mempromosikan alamat IPv4 atau IPv6 eksternal statis:

  • Untuk mempromosikan alamat IPv4 eksternal sementara menjadi alamat IPv4 eksternal statis, berikan alamat IP eksternal sementara menggunakan flag --addresses dengan perintah compute addresses create. Gunakan flag region untuk mempromosikan alamat IP regional sementara atau flag global untuk mempromosikan alamat IP global sementara.

    gcloud compute addresses create ADDRESS_NAME --addresses=IP_ADDRESS \
        [--region=REGION | --global]
    

    Ganti kode berikut:

    • ADDRESS_NAME: nama yang ingin Anda kaitkan dengan alamat ini.
    • IP_ADDRESS: alamat IP yang ingin Anda promosikan.
    • REGION: region tempat alamat IP regional berada.
  • Untuk mempromosikan alamat IPv6 eksternal regional sementara menjadi alamat IPv6 eksternal regional statis, berikan alamat IP eksternal sementara menggunakan flag --addresses dengan perintah gcloud compute addresses create.

    gcloud compute addresses create ADDRESS_NAME \
      --region=REGION \
      --addresses=IPV6_ADDRESS \
      --prefix-length=96
    

    Ganti kode berikut:

    • ADDRESS_NAME: nama untuk resource alamat IP.
    • REGION: region untuk resource alamat IPv6.
    • IPV6_ADDRESS: alamat IPv6 yang Anda promosikan.

API

Untuk mempromosikan alamat IP regional sementara, panggil metode addresses.insert:

POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/addresses

Untuk mempromosikan alamat IP global sementara, buat permintaan POST ke URI berikut:

POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/global/addresses

Tentukan nilai untuk kolom yang wajib diisi dari isi permintaan:

  • Untuk alamat IPv4, isi permintaan harus berisi kolom berikut:

    {
      "name": "ADDRESS_NAME",
      "address": "IPV4_ADDRESS"
      "addressType": "EXTERNAL"
    }
    
  • Untuk alamat IPv6, isi permintaan harus berisi kolom berikut:

    {
      "name": "ADDRESS_NAME",
      "address": "IPV6_ADDRESS"
      "prefixLength": 96
      "addressType": "EXTERNAL"
    }
    

    Ganti kode berikut:

    • ADDRESS_NAME: nama yang ingin Anda kaitkan dengan alamat ini
    • IPV4_ADDRESS|IPV6_ADDRESS: alamat IPv4 atau IPv6 yang ingin Anda promosikan
    • REGION: region tempat alamat IPv4 atau IPv6 berada
    • PROJECT_ID: project ID untuk permintaan ini

Go

import (
	"context"
	"fmt"
	"io"

	compute "cloud.google.com/go/compute/apiv1"
	computepb "cloud.google.com/go/compute/apiv1/computepb"
	"google.golang.org/protobuf/proto"
)

// promoteEphemeralAddress promotes an ephemeral IP address to a reserved static external IP address.
func promoteEphemeralAddress(w io.Writer, projectID, region, ephemeralIP, addressName string) error {
	// projectID := "your_project_id"
	// region := "europe-central2"
	// ephemeral_ip := "214.123.100.121"
	ctx := context.Background()

	client, err := compute.NewAddressesRESTClient(ctx)
	if err != nil {
		return fmt.Errorf("NewAddressesRESTClient: %w", err)
	}
	defer client.Close()

	addressResource := &computepb.Address{
		Name:        proto.String(addressName),
		AddressType: proto.String("EXTERNAL"),
		Address:     proto.String(ephemeralIP),
	}

	req := &computepb.InsertAddressRequest{
		Project:         projectID,
		Region:          region,
		AddressResource: addressResource,
	}

	op, err := client.Insert(ctx, req)
	if err != nil {
		return fmt.Errorf("failed to insert address promoted: %v", err)
	}

	// Wait for the operation to complete
	err = op.Wait(ctx)
	if err != nil {
		return fmt.Errorf("failed to complete promotion operation: %v", err)
	}

	fmt.Fprintf(w, "Ephemeral IP %s address promoted successfully", ephemeralIP)
	return nil
}

Java


import com.google.cloud.compute.v1.Address;
import com.google.cloud.compute.v1.Address.AddressType;
import com.google.cloud.compute.v1.AddressesClient;
import com.google.cloud.compute.v1.InsertAddressRequest;
import com.google.common.collect.Lists;
import java.io.IOException;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class PromoteEphemeralIp {

  public static void main(String[] args)
          throws IOException, ExecutionException, InterruptedException, TimeoutException {
    // TODO(developer): Replace these variables before running the sample.
    // Project ID or project number of the Google Cloud project you want to use.
    String projectId = "your-project-id";
    // Region where the VM and IP is located.
    String region = "your-region-id";
    // Ephemeral IP address to promote.
    String ephemeralIp = "your-ephemeralIp";
    // Name of the address to assign.
    String addressName = "your-addressName";

    promoteEphemeralIp(projectId, region, ephemeralIp, addressName);
  }

  // Promote ephemeral IP found on the instance to a static IP.
  public static List<Address> promoteEphemeralIp(String projectId, String region,
                                                 String ephemeralIp, String addressName)
          throws IOException, ExecutionException, InterruptedException, TimeoutException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests.
    try (AddressesClient client = AddressesClient.create()) {
      Address addressResource = Address.newBuilder()
              .setName(addressName)
              .setRegion(region)
              .setAddressType(AddressType.EXTERNAL.name())
              .setAddress(ephemeralIp)
              .build();

      InsertAddressRequest addressRequest = InsertAddressRequest.newBuilder()
              .setRegion(region)
              .setProject(projectId)
              .setAddressResource(addressResource)
              .setRequestId(UUID.randomUUID().toString())
              .build();

      client.insertCallable().futureCall(addressRequest).get(30, TimeUnit.SECONDS);

      return Lists.newArrayList(client.list(projectId, region).iterateAll());
    }
  }
}

Python

import uuid

from google.cloud.compute_v1 import AddressesClient
from google.cloud.compute_v1.types import Address


def promote_ephemeral_ip(project_id: str, ephemeral_ip: str, region: str):
    """
    Promote ephemeral IP found on the instance to a static IP.

    Args:
        project_id (str): Project ID.
        ephemeral_ip (str): Ephemeral IP address to promote.
        region (str): Region where the VM and IP is located.
    """
    addresses_client = AddressesClient()

    # Create a new static IP address using existing ephemeral IP
    address_resource = Address(
        name=f"ip-reserved-{uuid.uuid4()}",  # new name for promoted IP address
        region=region,
        address_type="EXTERNAL",
        address=ephemeral_ip,
    )
    operation = addresses_client.insert(
        project=project_id, region=region, address_resource=address_resource
    )
    operation.result()

    print(f"Ephemeral IP {ephemeral_ip} has been promoted to a static IP.")

Alamat IP eksternal tetap terpasang ke VM bahkan setelah dipromosikan ke alamat IP eksternal statis. Jika Anda perlu menetapkan alamat IP eksternal statis yang baru dipromosikan ke resource lain, batalkan penetapan alamat IP eksternal statis dari VM yang ada.

Mencantumkan alamat IP eksternal statis

Untuk mencantumkan alamat IP eksternal statis yang telah dicadangkan untuk project Anda, ikuti langkah-langkah berikut.

Konsol

  1. Di Konsol Google Cloud, buka halaman IP addresses.

    Buka IP addresses

  2. Klik Alamat IP eksternal.

gcloud

Gunakan perintah gcloud compute addresses list:

  • Untuk menampilkan semua alamat IP, gunakan perintah berikut:

    gcloud compute addresses list
  • Untuk menampilkan daftar semua alamat IP global, gunakan perintah berikut:

    gcloud compute addresses list --global
  • Untuk menampilkan daftar semua alamat IP regional di region tertentu, gunakan perintah berikut:

    gcloud compute addresses list \
        --regions=REGION
    

    Ganti REGION dengan region yang alamatnya ingin Anda cantumkan. Anda dapat mencantumkan alamat beberapa region dengan menentukan nama region yang dipisahkan koma:

    gcloud compute addresses list \
        --regions=REGION1,REGION2,..REGION_n_
    

API

  • Untuk mencantumkan alamat IPv4 atau IPv6 regional, panggil metode addresses.list:

    GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/addresses
    

    Ganti kode berikut:

    • PROJECT_ID: project ID untuk permintaan ini
    • REGION: nama region untuk permintaan ini
  • Untuk menampilkan daftar semua alamat di semua region, panggil metode addresses.aggregatedList:

    GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/aggregated/addresses
    
  • Untuk mencantumkan alamat IPv4 atau IPv6 global, panggil metode globalAddresses.list:

    GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/global/addresses
    

    Ganti kode berikut:

    PROJECT_ID: project ID untuk permintaan ini

Go

import (
	"context"
	"fmt"
	"io"

	compute "cloud.google.com/go/compute/apiv1"
	"google.golang.org/api/iterator"

	"cloud.google.com/go/compute/apiv1/computepb"
)

// listRegionalExternal retrieves list external IP addresses in Google Cloud Platform region.
func listRegionalExternal(w io.Writer, projectID, region string) ([]*computepb.Address, error) {
	// projectID := "your_project_id"
	// region := "europe-west3"

	ctx := context.Background()
	// Create the service client.
	addressesClient, err := compute.NewAddressesRESTClient(ctx)
	if err != nil {
		return nil, err
	}
	defer addressesClient.Close()

	// Build the request.
	req := &computepb.ListAddressesRequest{
		Project: projectID,
		Region:  region,
	}

	// List the addresses.
	it := addressesClient.List(ctx, req)

	// Iterate over the results.
	var addresses []*computepb.Address
	for {
		address, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			return nil, err
		}
		addresses = append(addresses, address)
	}

	// Print the addresses.
	fmt.Fprint(w, "Fetched addresses: \n")
	for _, address := range addresses {
		fmt.Fprintf(w, "%s\n", *address.Name)
	}

	return addresses, nil
}

// listGlobalExternal retrieves list external global IP addresses in Google Cloud Platform.
func listGlobalExternal(w io.Writer, projectID string) ([]*computepb.Address, error) {
	// projectID := "your_project_id"

	ctx := context.Background()
	// Create the service client.
	addressesClient, err := compute.NewGlobalAddressesRESTClient(ctx)
	if err != nil {
		return nil, err
	}
	defer addressesClient.Close()

	// Build the request.
	req := &computepb.ListGlobalAddressesRequest{
		Project: projectID,
	}

	// List the addresses.
	it := addressesClient.List(ctx, req)

	// Iterate over the results.
	var addresses []*computepb.Address
	for {
		address, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			return nil, err
		}
		addresses = append(addresses, address)
	}

	// Print the addresses.
	fmt.Fprint(w, "Fetched addresses: \n")
	for _, address := range addresses {
		fmt.Fprintf(w, "%s\n", *address.Name)
	}

	return addresses, nil
}

Java


import com.google.cloud.compute.v1.Address;
import com.google.cloud.compute.v1.AddressesClient;
import com.google.cloud.compute.v1.GlobalAddressesClient;
import com.google.cloud.compute.v1.ListAddressesRequest;
import com.google.cloud.compute.v1.ListGlobalAddressesRequest;
import com.google.common.collect.Lists;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;

public class ListStaticExternalIp {

  public static void main(String[] args)
          throws IOException, ExecutionException, InterruptedException, TimeoutException {
    // TODO(developer): Replace these variables before running the sample.
    // Project ID or project number of the Google Cloud project you want to use.
    String projectId = "your-project-id";
    // Region where the VM and IP is located.
    String region = "your-region-id";

    listStaticExternalIp(projectId, region);
  }

  // Lists all static external IP addresses, either regional or global.
  public static List<Address> listStaticExternalIp(String projectId, String region)
          throws IOException {
    // Use regional client if a region is specified
    if (region != null) {
      // Initialize client that will be used to send requests. This client only needs to be created
      // once, and can be reused for multiple requests.
      try (AddressesClient client = AddressesClient.create()) {
        ListAddressesRequest request = ListAddressesRequest.newBuilder()
                .setProject(projectId)
                .setRegion(region)
                .build();

        return Lists.newArrayList(client.list(request).iterateAll());
      }
    } else {
      // Initialize client that will be used to send requests. This client only needs to be created
      // once, and can be reused for multiple requests.
      try (GlobalAddressesClient client = GlobalAddressesClient.create()) {
        ListGlobalAddressesRequest request = ListGlobalAddressesRequest.newBuilder()
                .setProject(projectId)
                .build();

        return Lists.newArrayList(client.list(request).iterateAll());
      }
    }
  }
}

Python

from typing import List, Optional

from google.cloud.compute_v1.services.addresses.client import AddressesClient
from google.cloud.compute_v1.services.global_addresses import GlobalAddressesClient
from google.cloud.compute_v1.types import Address


def list_static_ip_addresses(
    project_id: str, region: Optional[str] = None
) -> List[Address]:
    """
    Lists all static external IP addresses, either regional or global.

    Args:
    project_id (str): project ID.
    region (Optional[str]): The region of the IP addresses if regional. None if global.

    Returns:
    List[Address]: A list of Address objects containing details about the requested IPs.
    """
    if region:
        # Use regional client if a region is specified
        client = AddressesClient()
        addresses_iterator = client.list(project=project_id, region=region)
    else:
        # Use global client if no region is specified
        client = GlobalAddressesClient()
        addresses_iterator = client.list(project=project_id)

    return list(addresses_iterator)  # Convert the iterator to a list to return

Menjelaskan alamat IP eksternal statis

Untuk mendapatkan informasi tentang alamat IP eksternal statis, ikuti langkah-langkah berikut.

Konsol

  1. Di Konsol Google Cloud, buka halaman IP addresses.

    Buka IP addresses

  2. Klik Alamat IP eksternal.

  3. Klik alamat IP yang ingin Anda dapatkan informasinya lebih lanjut.

gcloud

Gunakan perintah gcloud compute addresses describe. Ganti ADDRESS_NAME dengan nama alamat IP eksternal yang ingin Anda deskripsikan.

  • Untuk alamat IPv4 atau IPv6 global, gunakan perintah berikut:

    gcloud compute addresses describe ADDRESS_NAME --global
  • Untuk alamat IPv4 atau IPv6 regional, gunakan perintah berikut:

    gcloud compute addresses describe ADDRESS_NAME --region=REGION

API

  • Untuk mendeskripsikan alamat IPv4 atau IPv6 regional, panggil metode addresses.get:

    GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/addresses/ADDRESS_NAME
    

    Ganti kode berikut:

    • PROJECT_ID: project ID untuk permintaan
    • REGION: nama region untuk permintaan ini
    • ADDRESS_NAME: nama alamat IP
  • Untuk mendeskripsikan alamat IPv4 atau IPv6 global, panggil metode globalAddresses.get:

    GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/global/addresses/ADDRESS_NAME
    

    Ganti kode berikut:

    • PROJECT_ID: project ID untuk permintaan
    • ADDRESS_NAME: nama alamat IP

Go

import (
	"context"
	"fmt"
	"io"

	compute "cloud.google.com/go/compute/apiv1"
	"cloud.google.com/go/compute/apiv1/computepb"
)

// getExternalAddress retrieves the external IP address of the given address.
func getRegionalExternal(w io.Writer, projectID, region, addressName string) (*computepb.Address, error) {
	// projectID := "your_project_id"
	// region := "europe-west3"
	// addressName := "your_address_name"

	ctx := context.Background()
	addressesClient, err := compute.NewAddressesRESTClient(ctx)
	if err != nil {
		return nil, fmt.Errorf("NewAddressesRESTClient: %w", err)
	}
	defer addressesClient.Close()

	req := &computepb.GetAddressRequest{
		Project: projectID,
		Region:  region,
		Address: addressName,
	}

	address, err := addressesClient.Get(ctx, req)
	if err != nil {
		return nil, fmt.Errorf("unable to get address: %w", err)
	}

	fmt.Fprintf(w, "Regional address %s has external IP address: %s\n", addressName, address.GetAddress())

	return address, nil
}

func getGlobalExternal(w io.Writer, projectID, addressName string) (*computepb.Address, error) {

	ctx := context.Background()
	globalAddressesClient, err := compute.NewGlobalAddressesRESTClient(ctx)
	if err != nil {
		return nil, fmt.Errorf("NewGlobalAddressesRESTClient: %w", err)
	}
	defer globalAddressesClient.Close()

	req := &computepb.GetGlobalAddressRequest{
		Project: projectID,
		Address: addressName,
	}

	address, err := globalAddressesClient.Get(ctx, req)
	if err != nil {
		return nil, fmt.Errorf("unable to get address: %w", err)
	}

	fmt.Fprintf(w, "Global address %s has external IP address: %s\n", addressName, address.GetAddress())

	return address, nil
}

Java


import com.google.cloud.compute.v1.Address;
import com.google.cloud.compute.v1.AddressesClient;
import com.google.cloud.compute.v1.GetAddressRequest;
import com.google.cloud.compute.v1.GetGlobalAddressRequest;
import com.google.cloud.compute.v1.GlobalAddressesClient;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;

public class GetStaticIpAddress {

  public static void main(String[] args)
          throws IOException, ExecutionException, InterruptedException, TimeoutException {
    // TODO(developer): Replace these variables before running the sample.
    // Project ID or project number of the Google Cloud project you want to use.
    String projectId = "your-project-id";
    // Region where the VM and IP is located.
    String region = "your-region-id";
    // Name of the address to assign.
    String addressName = "your-addressName";

    getStaticIpAddress(projectId, region, addressName);
  }

  // Retrieves a static external IP address, either regional or global.
  public static Address getStaticIpAddress(String projectId, String region, String addressName)
          throws IOException {
    // Use regional client if a region is specified
    if (region != null) {
      // Initialize client that will be used to send requests. This client only needs to be created
      // once, and can be reused for multiple requests.
      try (AddressesClient client = AddressesClient.create()) {
        GetAddressRequest request = GetAddressRequest.newBuilder()
                .setProject(projectId)
                .setRegion(region)
                .setAddress(addressName)
                .build();

        return client.get(request);
      }
    } else {
      // Initialize client that will be used to send requests. This client only needs to be created
      // once, and can be reused for multiple requests.
      try (GlobalAddressesClient client = GlobalAddressesClient.create()) {
        GetGlobalAddressRequest request = GetGlobalAddressRequest.newBuilder()
                .setProject(projectId)
                .setAddress(addressName)
                .build();

        return client.get(request);
      }
    }
  }
}

Python

from typing import Optional

from google.cloud.compute_v1.services.addresses.client import AddressesClient
from google.cloud.compute_v1.services.global_addresses import GlobalAddressesClient
from google.cloud.compute_v1.types import Address


def get_static_ip_address(
    project_id: str, address_name: str, region: Optional[str] = None
) -> Address:
    """
    Retrieves a static external IP address, either regional or global.

    Args:
    project_id (str): project ID.
    address_name (str): The name of the IP address.
    region (Optional[str]): The region of the IP address if it's regional. None if it's global.

    Raises: google.api_core.exceptions.NotFound: in case of address not found

    Returns:
    Address: The Address object containing details about the requested IP.
    """
    if region:
        # Use regional client if a region is specified
        client = AddressesClient()
        address = client.get(project=project_id, region=region, address=address_name)
    else:
        # Use global client if no region is specified
        client = GlobalAddressesClient()
        address = client.get(project=project_id, address=address_name)

    return address

Merilis alamat IP eksternal statis

Jika tidak lagi memerlukan alamat IPv4 atau IPv6 eksternal statis, Anda dapat melepas alamat IP dengan menghapus resource alamat IP.

Jika menggunakan konsol Google Cloud, Anda dapat melepas alamat IP statis hanya jika tidak digunakan oleh resource lain.

Jika menggunakan gcloud CLI atau API, Anda dapat melepaskan alamat IP, terlepas dari apakah alamat itu sedang digunakan oleh resource lain atau tidak.

  • Jika alamat IP tidak digunakan oleh suatu resource, alamat IP tersebut akan dikembalikan ke kumpulan alamat IP eksternal yang tersedia.

  • Jika alamat IP digunakan oleh suatu resource, alamat IP tersebut akan tetap terpasang ke resource tersebut hingga resource dihapus.

Konsol

  1. Di Konsol Google Cloud, buka halaman IP addresses.

    Buka IP addresses

  2. Klik Alamat IP eksternal.

  3. Opsional: Di kolom Filter, masukkan static, lalu pilih Static : Type dari menu drop-down.

  4. Pilih alamat IP eksternal statis yang ingin Anda rilis.

  5. Klik Release static address.

    Jika Anda tidak melihat opsi ini, klik menu Tindakan lainnya () di panel menu atas, lalu pilih Lepaskan alamat statis dari daftar.

gcloud

Gunakan perintah compute addresses delete:

gcloud compute addresses delete ADDRESS_NAME

Ganti ADDRESS_NAME dengan nama alamat IPv4 atau IPv6 yang akan dirilis.

API

  • Untuk merilis alamat IPv4 atau IPv6 regional, panggil metode addresses.delete:

    DELETE https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/addresses/ADDRESS_NAME
    

    Ganti kode berikut:

    • PROJECT_ID: project ID untuk permintaan ini
    • REGION: nama region untuk permintaan ini
    • ADDRESS_NAME: nama alamat IP
  • Untuk merilis alamat IPv4 atau IPv6 global, panggil metode globalAddresses.delete:

    DELETE https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/global/addresses/ADDRESS_NAME
    

    Ganti kode berikut:

    • ADDRESS_NAME: nama alamat IP
    • PROJECT_ID: project ID untuk permintaan ini

Go

import (
	"context"
	"fmt"
	"io"

	compute "cloud.google.com/go/compute/apiv1"
	"cloud.google.com/go/compute/apiv1/computepb"
)

// releaseRegionalStaticExternal releases a static regional external IP address.
func releaseRegionalStaticExternal(w io.Writer, projectID, region, addressName string) error {
	// projectID := "your_project_id"
	// region := "us-central1"
	// addressName := "your_address_name"

	ctx := context.Background()
	addressesClient, err := compute.NewAddressesRESTClient(ctx)
	if err != nil {
		return fmt.Errorf("NewAddressesRESTClient: %w", err)
	}
	defer addressesClient.Close()

	req := &computepb.DeleteAddressRequest{
		Project: projectID,
		Region:  region,
		Address: addressName,
	}

	op, err := addressesClient.Delete(ctx, req)
	if err != nil {
		return fmt.Errorf("unable to release static external IP address: %w", err)
	}

	if err = op.Wait(ctx); err != nil {
		return fmt.Errorf("unable to wait for the operation: %w", err)
	}

	fmt.Fprintf(w, "Static external IP address released\n")

	return nil
}

// releaseGlobalStaticExternal releases a static global external IP address.
func releaseGlobalStaticExternal(w io.Writer, projectID, addressName string) error {
	// projectID := "your_project_id"
	// addressName := "your_address_name"

	ctx := context.Background()
	addressesClient, err := compute.NewGlobalAddressesRESTClient(ctx)
	if err != nil {
		return fmt.Errorf("NewGlobalAddressesRESTClient: %w", err)
	}
	defer addressesClient.Close()

	req := &computepb.DeleteGlobalAddressRequest{
		Project: projectID,
		Address: addressName,
	}

	op, err := addressesClient.Delete(ctx, req)
	if err != nil {
		return fmt.Errorf("unable to release static external IP address: %w", err)
	}

	if err = op.Wait(ctx); err != nil {
		return fmt.Errorf("unable to wait for the operation: %w", err)
	}

	fmt.Fprintf(w, "Static external IP address released\n")

	return nil
}

Java


import com.google.cloud.compute.v1.AddressesClient;
import com.google.cloud.compute.v1.DeleteAddressRequest;
import com.google.cloud.compute.v1.DeleteGlobalAddressRequest;
import com.google.cloud.compute.v1.GlobalAddressesClient;
import com.google.cloud.compute.v1.Operation;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class ReleaseStaticAddress {

  public static void main(String[] args)
          throws IOException, ExecutionException, InterruptedException, TimeoutException {
    // TODO(developer): Replace these variables before running the sample.
    // Project ID or project number of the Google Cloud project you want to use.
    String projectId = "your-project-id";
    // The region to reserve the IP address in, if regional. Must be None if global
    String region = "your-region =";
    // Name of the address to release.
    String addressName = "your-addressName";

    releaseStaticAddress(projectId, addressName, region);
  }

  // Releases a static external IP address that is currently reserved.
  // This action requires that the address is not being used by any forwarding rule.
  public static void releaseStaticAddress(String projectId, String addressName, String region)
          throws IOException, ExecutionException, InterruptedException, TimeoutException {
    Operation operation;
    // Use global client if no region is specified
    if (region == null) {
      // Initialize client that will be used to send requests. This client only needs to be created
      // once, and can be reused for multiple requests.
      try (GlobalAddressesClient client = GlobalAddressesClient.create()) {
        DeleteGlobalAddressRequest request = DeleteGlobalAddressRequest.newBuilder()
                .setProject(projectId)
                .setAddress(addressName)
                .build();

        operation = client.deleteCallable().futureCall(request).get(30, TimeUnit.SECONDS);
      }
    } else {
      // Initialize client that will be used to send requests. This client only needs to be created
      // once, and can be reused for multiple requests.
      try (AddressesClient client = AddressesClient.create()) {
        DeleteAddressRequest request = DeleteAddressRequest.newBuilder()
                .setProject(projectId)
                .setRegion(region)
                .setAddress(addressName)
                .build();

        operation = client.deleteCallable().futureCall(request).get(30, TimeUnit.SECONDS);
      }
    }
    if (operation.hasError()) {
      System.out.printf("Can't release external IP address '%s'. Caused by : %s",
              addressName, operation.getError());
    }
    System.out.printf("External IP address '%s' released successfully.", addressName);
  }
}

Python

from typing import Optional

from google.cloud.compute_v1.services.addresses.client import AddressesClient
from google.cloud.compute_v1.services.global_addresses import GlobalAddressesClient


def release_external_ip_address(
    project_id: str,
    address_name: str,
    region: Optional[str] = None,
) -> None:
    """
    Releases a static external IP address that is currently reserved.
    This action requires that the address is not being used by any forwarding rule.

    Args:
        project_id (str): project ID.
        address_name (str): name of the address to release.
        region (Optional[str]): The region to reserve the IP address in, if regional. Must be None if global.


    """
    if not region:  # global IP address
        client = GlobalAddressesClient()
        operation = client.delete(project=project_id, address=address_name)
    else:  # regional IP address
        client = AddressesClient()
        operation = client.delete(
            project=project_id, region=region, address=address_name
        )

    operation.result()
    print(f"External IP address '{address_name}' released successfully.")

Langkah selanjutnya