zenlayercloud

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 14, 2023 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Use this data source to query instances types.

Example Usage

```hcl data "zenlayercloud_bmc_instance_types" "foo" {

}

data "zenlayercloud_bmc_instance_types" "sel" {
  availability_zone    = "SEL-A"
  instance_charge_type = "PREPAID"
  exclude_sold_out     = true
}

```

Use this data source to query DDoS IP instances.

Example Usage

```hcl

data "zenlayercloud_bmc_ddos_ips" "foo" {
	availability_zone = "SEL-A"
}

```

Use this data source to query eip instances.

Example Usage

```hcl

data "zenlayercloud_bmc_eips" "foo" {
	availability_zone = "SEL-A"
}

```

Use this data source to query images.

Example Usage

```hcl

data "zenlayercloud_bmc_images" "foo" {
	catalog = "centos"
    instance_type_id = "S9I"
}

```

Use this data source to query bmc instances.

Example Usage

```hcl

data "zenlayercloud_bmc_instances" "foo" {
  availability_zone = "SEL-A"
}

```

Use this data source to query vpc subnets information.

Example Usage

```hcl

variable "availability_zone" {
  default = "SEL-A"
}
resource "zenlayercloud_bmc_subnet" "foo" {
  availability_zone = var.availability_zone
  name       		= "subnet_test"
  cidr_block 		= "10.0.0.0/16"
}
data "zenlayercloud_bmc_subnets" "id_subnets" {
  subnet_id = zenlayercloud_bmc_subnet.foo.id
}
data "zenlayercloud_bmc_subnets" "name_subnets" {
  subnet_name = zenlayercloud_bmc_subnet.foo.name
}

Use this data source to get the available regions for vpc.

Example Usage

```hcl

data "zenlayercloud_bmc_vpc_regions" "sel-region" {
  availability_zone = "SEL-A"
}

```

Use this data source to query vpc information.

Example Usage

```hcl data "zenlayercloud_bmc_vpc_regions" "region" { }

resource "zenlayercloud_bmc_vpc" "foo" {
  region     = data.zenlayercloud_bmc_vpc_regions.region.vpc_regions.0.region
  name       = "test_vpc"
  cidr_block = "10.0.0.0/16"
}

data "zenlayercloud_bmc_vpcs" "foo" { } ```

Use this data source to get all bmc available zones.

Example Usage

```hcl data "zenlayercloud_bmc_zones" "all" { }

data "zenlayercloud_bmc_zones" "sel" {
	name_regex = "SEL*"
}

```

The ZenlayerCloud provider is used to interact with many resources supported by [ZenlayerCloud](https://console.zenlayer.com). The provider needs to be configured with the proper credentials before it can be used.

Use the navigation on the left to read about the available resources.

Example Usage

```hcl

terraform {
  required_providers {
    zenlayercloud = {
      source = "zenlayer/zenlayercloud"
    }
  }
}

Configure the Zenlayer Cloud Provider

provider "zenlayercloud" {
  access_key_id       =  var.access_key_id
  access_key_password =  var.access_key_password
}

```

Resources List

Provider Data Sources

Bare Metal Cloud(BMC)

  Data Source
	zenlayercloud_bmc_zones
	zenlayercloud_bmc_instance_types
    zenlayercloud_bmc_images
	zenlayercloud_bmc_instances
	zenlayercloud_bmc_eips
	zenlayercloud_bmc_ddos_ips
	zenlayercloud_bmc_vpc_regions
	zenlayercloud_bmc_vpcs
	zenlayercloud_bmc_subnets

  Resource
	zenlayercloud_bmc_instance
	zenlayercloud_bmc_ddos_ip
	zenlayercloud_bmc_ddos_ip_association
	zenlayercloud_bmc_eip
	zenlayercloud_bmc_eip_association
	zenlayercloud_bmc_vpc
	zenlayercloud_bmc_subnet

Provides an DDoS IP resource.

Example Usage

```hcl

variable "availability_zone" {
  default = "SEL-A"
}
resource "zenlayercloud_bmc_ddos_ip" "foo" {
  availability_zone = var.availability_zone
}

```

Import

EIP can be imported using the id, e.g.

``` $ terraform import zenlayercloud_bmc_ddos_ip.foo 123123xxxx ```

Provides an DDoS IP resource associated with BMC instance.

Example Usage

```hcl

resource "zenlayercloud_bmc_ddos_ip_association" "foo" {
  ddos_ip_id      = "ddosIpIdxxxxxx"
  instance_id = "instanceIdxxxxxx"
}

```

Import

DDoS IP association can be imported using the id, e.g.

``` $ terraform import zenlayercloud_bmc_ddos_ip_association.bar ddosIpIdxxxxxx:instanceIdxxxxxxx ```

Provides an EIP resource.

Example Usage

```hcl

variable "availability_zone" {
  default = "SEL-A"
}
resource "zenlayercloud_bmc_eip" "foo" {
  availability_zone = var.availability_zone
}

```

Import

EIP can be imported using the id, e.g.

``` $ terraform import zenlayercloud_bmc_eip.foo 123123xxxx ```

Provides an eip resource associated with BMC instance.

Example Usage

```hcl

resource "zenlayercloud_bmc_eip_association" "foo" {
  eip_id      = "eipxxxxxx"
  instance_id = "instanceIdxxxxxx"
}

```

Import

Eip association can be imported using the id, e.g.

``` $ terraform import zenlayercloud_bmc_eip_association.bar eipIdxxxxxx:instanceIdxxxxxxx ```

Provides a BMC instance resource.

~> **NOTE:** You can launch an BMC instance for a private network via specifying parameter `subnet_id`.

~> **NOTE:** At present, 'PREPAID' instance cannot be deleted and must wait it to be outdated and released automatically.

Example Usage

```hcl

data "zenlayercloud_bmc_zones" "default" {

}

data "zenlayercloud_bmc_instance_types" "default" {
  availability_zone = data.zenlayercloud_bmc_zones.default.zones.0.id
}

Get a centos image which also supported to install on given instance type

data "zenlayercloud_bmc_images" "default" {
  catalog          = "centos"
  instance_type_id = data.zenlayercloud_bmc_instance_types.default.instance_types.0.id
}
resource "zenlayercloud_bmc_subnet" "default" {
  availability_zone = data.zenlayercloud_bmc_zones.default.zones.0.id
  name              = "test-subnet"
  cidr_block        = "10.0.10.0/24"
}

Create a web server

resource "zenlayercloud_bmc_instance" "web" {
  availability_zone    = data.zenlayercloud_bmc_zones.default.zones.0.id
  image_id             = data.zenlayercloud_bmc_images.default.images.0.image_id
  internet_charge_type = "ByBandwidth"
  instance_type_id     = data.zenlayercloud_bmc_instance_types.default.instance_types.0.id
  password             = "Example~123"
  instance_name        = "web"
  subnet_id            =  zenlayercloud_bmc_subnet.default.id
}

```

Import

BMC instance can be imported using the id, e.g.

``` terraform import zenlayercloud_bmc_instance.foo 123123xxx ```

Provide a resource to create a VPC subnet.

Example Usage

```hcl

variable "region" {
  default = "SEL1"
}
variable "availability_zone" {
  default = "SEL-A"
}
resource "zenlayercloud_bmc_vpc" "foo" {
  region	 = var.region
  name       = "test-vpc"
  cidr_block = "10.0.0.0/16"
}
resource "zenlayercloud_bmc_subnet" "subnet_with_vpc" {
  availability_zone = var.availability_zone
  name              = "test-subnet"
  vpc_id            = zenlayercloud_bmc_vpc.foo.id
  cidr_block        = "10.0.10.0/24"
}
resource "zenlayercloud_bmc_subnet" "subnet" {
  availability_zone = var.availability_zone
  name              = "test-subnet"
  cidr_block        = "10.0.10.0/24"
}

```

Import

Vpc subnet instance can be imported, e.g.

``` $ terraform import zenlayercloud_bmc_subnet.subnet subnet_id ```

Provide a resource to create a VPC.

Example Usage

```hcl data "zenlayercloud_bmc_vpc_regions" "default_region" {

}

resource "zenlayercloud_bmc_vpc" "foo" {
  region 	 = data.zenlayercloud_bmc_vpc_regions.default_region.regions.0.id
  cidr_block = "10.0.0.0/26"
}

```

Import

Vpc instance can be imported, e.g.

``` $ terraform import zenlayercloud_bmc_vpc.test vpc-id ```

Index

Constants

View Source
const (
	PROVIDER_WRITE_RETRY_TIMEOUT = "ZENLAYERCLOUD_WRITE_RETRY_TIMEOUT"
	PROVIDER_READ_RETRY_TIMEOUT  = "ZENLAYERCLOUD_READ_RETRY_TIMEOUT"
	PROVIDER_BMC_CREATE_TIMEOUT  = "ZENLAYERCLOUD_BMC_CREATE_TIMEOUT"
	PROVIDER_BMC_UPDATE_TIMEOUT  = "ZENLAYERCLOUD_BMC_UPDATE_TIMEOUT"
)
View Source
const (
	ServiceNotAvailable = "SERVICE_TEMPORARY_UNAVAILABLE"
	InternalServerError = "INTERNAL_SERVER_ERROR"
	ReadTimedOut        = "REQUEST_TIMED_OUT"
	ResourceNotFound    = "INVALID_RESOURCE_NOT_FOUND"
)
View Source
const (
	ResourceTypeInstance = "instance"
	ResourceTypeEip      = "eip"
	ResourceTypeDdosIp   = "ddos_ip"
	ResourceTypeSubnet   = "subnet"
	ResourceTypeCidrIPv4 = "cidr_ipv4"
	ResourceTypeCidrIPv6 = "cidr_ipv6"

	BmcChargeTypePostpaid                    = "POSTPAID"
	BmcChargeTypePrepaid                     = "PREPAID"
	BmcInternetChargeTypeBandwidth           = "ByBandwidth"
	BmcInternetChargeTypeTrafficPackage      = "ByTrafficPackage"
	BmcInternetChargeTypeInstanceBandwidth95 = "ByInstanceBandwidth95"
	BmcInternetChargeTypeClusterBandwidth95  = "ByClusterBandwidth95"

	BmcInstanceStatusPending       = "PENDING"
	BmcInstanceStatusCreating      = "CREATING"
	BmcInstanceStatusCreateFailed  = "CREATE_FAILED"
	BmcInstanceStatusInstalling    = "INSTALLING"
	BmcInstanceStatusInstallFailed = "INSTALL_FAILED"
	BmcInstanceStatusRunning       = "RUNNING"
	BMC_INSTANCE_STATUS_STOPPED    = "STOPPED"
	BmcInstanceStatusBooting       = "BOOTING"
	BmcInstanceStatusStopping      = "STOPPING"
	BmcInstanceStatusRecycle       = "RECYCLE"

	BmcSubnetStatusAvailable         = "AVAILABLE"
	BmcSubnetStatusCreating          = "CREATING"
	BmcSubnetStatusPending           = "PENDING"
	BmcSubnetStatusDeleting          = "DELETING"
	BmcSubnetStatusCreateFailed      = "CREATE_FAILED"
	BmcSubnetStatusAssociate         = "ASSOCIATING"
	BmcSubnetInstanceStatusBinding   = "BINDING"
	BmcSubnetInstanceStatusUnbinding = "UNBINDING"
	BmcSubnetInstanceStatusBound     = "BOUND"

	BmcVpcStatusCreating        = "CREATING"
	BmcVpcStatusCreateFailed    = "CREATE_FAILED"
	BmcVpcStatusCreateAvailable = "AVAILABLE"
	BmcVpcStatusDeleting        = "DELETING"

	BmcEipStatusCreating      = "CREATING"
	BmcEipStatusCreateFailed  = "CREATE_FAILED"
	BmcEipStatusAssociating   = "ASSOCIATING"
	BmcEipStatusUnAssociating = "UNASSOCIATING"
	BmcEipStatusAssociated    = "ASSOCIATED"
	BmcEipStatusAvailable     = "AVAILABLE"
	BmcEipStatusReleasing     = "RELEASING"
	BmcEipStatusRecycle       = "RECYCLE"
	BmcEipStatusRecycling     = "RECYCLING"

	ImageTypePublic = "PUBLIC_IMAGE"
	ImageTypeCustom = "CUSTOM_IMAGE"
)
View Source
const (
	PROVIDER_SECRET_KEY_ID       = "ZENLAYERCLOUD_ACCESS_KEY_ID"
	PROVIDER_SECRET_KEY_PASSWORD = "ZENLAYERCLOUD_ACCESS_KEY_PASSWORD"
	PROVIDER_CLIENT_TIMEOUT      = "ZENLAYERCLOUD_CLIENT_TIMEOUT"
	PROVIDER_SCHEME              = "ZENLAYERCLOUD_SCHEME"
	PROVIDER_DOMAIN              = "ZENLAYERCLOUD_DOMAIN"
)
View Source
const InstanceSubnetStatusNotBind = "NotBind"
View Source
const NetworkStatusFail = "Fail"
View Source
const NetworkStatusOK = "OK"
View Source
const NetworkStatusPending = "Pending"

Variables

Functions

func BuildDdosIpState

func BuildDdosIpState(bmcService BmcService, ddosIpId string, ctx context.Context, d *schema.ResourceData) *resource.StateChangeConf

func BuildEipState

func BuildEipState(bmcService BmcService, eipId string, ctx context.Context, d *schema.ResourceData) *resource.StateChangeConf

func Error

func Error(msg string, args ...interface{}) error

func IsContains

func IsContains(array interface{}, value interface{}) bool

func ParseResourceId

func ParseResourceId(id string, length int) (parts []string, err error)

func Provider

func Provider() *schema.Provider

func String

func String(s string) int

Types

type BmcService

type BmcService struct {
	// contains filtered or unexported fields
}

func (*BmcService) AssociateSubnetInstance

func (s *BmcService) AssociateSubnetInstance(ctx context.Context, instanceId string, subnetId string) error

func (*BmcService) DeleteInstance

func (s *BmcService) DeleteInstance(ctx context.Context, instanceId string) (err error)

func (*BmcService) DeleteSubnet

func (s *BmcService) DeleteSubnet(ctx context.Context, subnetId string) (err error)

func (*BmcService) DeleteVpc

func (s *BmcService) DeleteVpc(ctx context.Context, vpcId string) error

func (*BmcService) DescribeDdosIpAddressById

func (s *BmcService) DescribeDdosIpAddressById(ctx context.Context, ddosIpId string) (eip *bmc.DdosIpAddress, err error)

func (*BmcService) DescribeDdosIpAddressesByFilter

func (s *BmcService) DescribeDdosIpAddressesByFilter(filter *DDosIpFilter) (ddosIpAddress []*bmc.DdosIpAddress, err error)

func (*BmcService) DescribeEipAddressById

func (s *BmcService) DescribeEipAddressById(ctx context.Context, eipId string) (eip *bmc.EipAddress, err error)

func (*BmcService) DescribeEipAddressesByFilter

func (s *BmcService) DescribeEipAddressesByFilter(filter *EipFilter) (eipAddresses []*bmc.EipAddress, err error)

func (*BmcService) DescribeInstanceById

func (s *BmcService) DescribeInstanceById(ctx context.Context, instanceId string) (instance *bmc.InstanceInfo, err error)

func (*BmcService) DescribeInstanceInternetStatus

func (s *BmcService) DescribeInstanceInternetStatus(ctx context.Context, instanceId string) (*bmc.InstanceInternetStatus, error)

func (*BmcService) DescribeInstancesByFilter

func (s *BmcService) DescribeInstancesByFilter(instanceFilter *InstancesFilter) (instances []*bmc.InstanceInfo, err error)

func (*BmcService) DescribeSubnetById

func (s *BmcService) DescribeSubnetById(ctx context.Context, subnetId string) (subnet *bmc.Subnet, err error)

func (*BmcService) DescribeSubnets

func (s *BmcService) DescribeSubnets(ctx context.Context, filter *SubnetFilter) (subnets []*bmc.Subnet, err error)

func (*BmcService) DescribeVpcById

func (s *BmcService) DescribeVpcById(ctx context.Context, vpcId string) (vpc *bmc.VpcInfo, err error)

func (*BmcService) DescribeVpcsByFilter

func (s *BmcService) DescribeVpcsByFilter(ctx context.Context, filter *VpcFilter) (vpcs []*bmc.VpcInfo, err error)

func (*BmcService) DescribeZones

func (s *BmcService) DescribeZones(ctx context.Context) (zones []*bmc.ZoneInfo, err error)

func (*BmcService) DestroyInstance

func (s *BmcService) DestroyInstance(ctx context.Context, instanceId string) (err error)

func (*BmcService) DisassociateSubnetInstance

func (s *BmcService) DisassociateSubnetInstance(ctx context.Context, instanceId string, subnetId string) error

func (*BmcService) InstanceDdosIpStateRefreshFunc

func (s *BmcService) InstanceDdosIpStateRefreshFunc(ctx context.Context, eipId string) resource.StateRefreshFunc

func (*BmcService) InstanceEipStateRefreshFunc

func (s *BmcService) InstanceEipStateRefreshFunc(ctx context.Context, eipId string) resource.StateRefreshFunc

func (*BmcService) InstanceNetworkStateRefreshFunc

func (s *BmcService) InstanceNetworkStateRefreshFunc(ctx context.Context, instanceId string, condition NetworkStateCondition) resource.StateRefreshFunc

func (*BmcService) InstanceStateRefreshFunc

func (s *BmcService) InstanceStateRefreshFunc(ctx context.Context, instanceId string, failStates []string) resource.StateRefreshFunc

func (*BmcService) InstanceSubnetStateRefreshFunc

func (s *BmcService) InstanceSubnetStateRefreshFunc(ctx context.Context, instanceId string, subnetId string) resource.StateRefreshFunc

func (*BmcService) ModifyDdosIpResourceGroup

func (s *BmcService) ModifyDdosIpResourceGroup(ctx context.Context, ddpsIp string, resourceGroupId string) error

func (*BmcService) ModifyEipResourceGroup

func (s *BmcService) ModifyEipResourceGroup(ctx context.Context, eipId string, resourceGroupId string) error

func (*BmcService) ModifyInstanceName

func (s *BmcService) ModifyInstanceName(ctx context.Context, instanceId string, instanceName string) error

func (*BmcService) ModifyInstanceResourceGroup

func (s *BmcService) ModifyInstanceResourceGroup(ctx context.Context, instanceId string, resourceGroupId string) error

func (*BmcService) ModifySubnetName

func (s *BmcService) ModifySubnetName(ctx context.Context, subnetId string, subnetName string) error

func (*BmcService) ModifySubnetResourceGroupById

func (s *BmcService) ModifySubnetResourceGroupById(ctx context.Context, subnetId string, resourceGroupId string) error

func (*BmcService) ModifyVpcName

func (s *BmcService) ModifyVpcName(ctx context.Context, vpcId string, vpcName string) error

func (*BmcService) ModifyVpcResourceGroup

func (s *BmcService) ModifyVpcResourceGroup(ctx context.Context, vpcId string, resourceGroupId string) error

func (*BmcService) ReleaseDDoSIpAddressById

func (s *BmcService) ReleaseDDoSIpAddressById(ctx context.Context, ddosIpId string) (err error)

func (*BmcService) ReleaseEipAddressById

func (s *BmcService) ReleaseEipAddressById(ctx context.Context, eipId string) (err error)

func (*BmcService) SubnetStateRefreshFunc

func (s *BmcService) SubnetStateRefreshFunc(ctx context.Context, subnetId string, failStates []string) resource.StateRefreshFunc

func (*BmcService) TerminateDDoSIpAddress

func (s *BmcService) TerminateDDoSIpAddress(ctx context.Context, ddosIpId string) (err error)

func (*BmcService) TerminateEipAddress

func (s *BmcService) TerminateEipAddress(ctx context.Context, eipId string) (err error)

func (*BmcService) VpcStateRefreshFunc

func (s *BmcService) VpcStateRefreshFunc(ctx context.Context, vpcId string, failStates []string) resource.StateRefreshFunc

type DDosIpFilter

type DDosIpFilter struct {
	IpIds           []string
	InstanceId      *string
	ZoneId          *string
	Ip              *string
	DdosIpStatus    *string
	ResourceGroupId *string
}

type EipFilter

type EipFilter struct {
	EipIds          []string
	InstanceId      *string
	ZoneId          *string
	Ip              *string
	EipStatus       *string
	ResourceGroupId *string
}

type GoRoutineLimit

type GoRoutineLimit struct {
	Count int
	Chan  chan struct{}
}

func NewGoRoutine

func NewGoRoutine(num int) *GoRoutineLimit

func (*GoRoutineLimit) Run

func (g *GoRoutineLimit) Run(f func())

type InstancesFilter

type InstancesFilter struct {
	InstancesIds    []string
	ZoneId          *string
	InstanceTypeId  *string
	InstanceName    *string
	Hostname        *string
	ImageId         *string
	SubnetId        *string
	InstanceStatus  *string
	ResourceGroupId *string
	PublicIpv4      *string
	PrivateIpv4     *string
}

type NetworkStateCondition

type NetworkStateCondition interface {
	// contains filtered or unexported methods
}

type SubnetFilter

type SubnetFilter struct {
	VpcId           string
	SubnetId        string
	SubnetName      string
	CidrBlock       string
	ZoneId          string
	ResourceGroupId string
}

type VpcFilter

type VpcFilter struct {
	VpcId     *string
	CidrBlock *string

	ResourceGroupId *string
	// contains filtered or unexported fields
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL