TERRAFORM-绑定弹性公网IP:操作步骤

时间:2023-12-25 14:37:59

操作步骤

  1. 在main.tf文件中增加以下内容。

    resource "huaweicloud_vpc_eip" "myeip" {
      publicip {
        type = "5_bgp"
      }
      bandwidth {
        name        = "mybandwidth"
        size        = 8
        share_type  = "PER"
        charge_mode = "traffic"
      }
    }
    
    resource "huaweicloud_compute_eip_associate" "associated" {
      public_ip   = huaweicloud_vpc_eip.myeip.address
      instance_id = huaweicloud_compute_instance.myinstance.id
    }

  2. 运行 terraform plan 查看资源。
  3. 确认资源无误后,运行 terraform apply 开始创建。
support.huaweicloud.com/usermanual-terraform/terraform_0005.html