Giter Site home page Giter Site logo

ucloud / terraform-provider-ucloud Goto Github PK

View Code? Open in Web Editor NEW
66.0 15.0 23.0 14.71 MB

Terraform is an awesome tool to implement Infrastructure as Code and GitOps

Home Page: https://www.terraform.io/docs/providers/ucloud/

License: Mozilla Public License 2.0

Makefile 0.33% Go 99.27% Shell 0.40%
ucloud terraform-provider terraform

terraform-provider-ucloud's People

Contributors

asaiun avatar cgriggs01 avatar fioncat avatar imjoey avatar lazzurs avatar nfagerlund avatar paultyng avatar radeksimko avatar schnell18 avatar shawnmssu avatar tombuildsstuff avatar ucloud-bot avatar wangrzneu avatar yufeiminds avatar zzxwill avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

terraform-provider-ucloud's Issues

Unreasonablef forces replacement argument of ucloud_vpc.

I am gong to change the service name which is part of the name, tag, remark of many other products.
I found lots of unexpectedforces replacement arguments when I terraform plan:

  • ucloud_vpc
    • name
    • tag
  • ucloud_subnet (because of the ucloud_vpc is forces replacement)
  • ucloud_instance (because of the subnet_id is forces replacement)

It looks like I have to recreate all of my resources even if I just want to change thename ortag of ucloud_vpc.

Datasource ucloud_instance_types is not supported.

It is not recommended that hard coded the instance-type in the IaC code. I always filter instance type by cpu and memory (aws, alicloud or tencentcloud) by datasource which is not supported by ucloud.

TestAccUCloudCubePod_basic failed

git version: 256bac0
Run test TestAccUCloudCubePod_basic after environment variables properly set, the test failed with following output:

time="2021-05-26T10:31:44+08:00" level=debug msg="[2a39391a-d9c2-4d7a-ac78-c38f4a87f17e] https://api.ucloud.cn?Action=DescribeVPC Action=DescribeVPC&Limit=100&Offset=0&ProjectId=org-xehypo&PublicKey=JInqRnkSY8eAmxKFRxW9kVANYThbzxJKNMEWhQ54N&Region=hk&Signature=31f01e334210679ae8e4923a2836b310c4b310d7"
time="2021-05-26T10:31:44+08:00" level=debug msg="[2a39391a-d9c2-4d7a-ac78-c38f4a87f17e] {"Action":"DescribeVPCResponse","DataSet":[{"CreateTime":1562309255,"IPv6Network":"","Name":"DefaultVPC","Network":["10.8.0.0/16","10.7.0.0/16"],"NetworkInfo":[{"Network":"10.8.0.0/16","SubnetCount":1},{"Network":"10.7.0.0/16","SubnetCount":1}],"OperatorName":"","Remark":"","SubnetCount":2,"Tag":"Default","TunnelId":68123391,"UpdateTime":1562309256,"VPCId":"uvnet-ecrfor2j"},{"CreateTime":1562046410,"IPv6Network":"","Name":"DefaultVPC","Network":["10.8.0.0/16","10.7.0.0/16"],"NetworkInfo":[{"Network":"10.8.0.0/16","SubnetCount":1},{"Network":"10.7.0.0/16","SubnetCount":1}],"OperatorName":"","Remark":"","SubnetCount":2,"Tag":"Default","TunnelId":68118106,"UpdateTime":1562046411,"VPCId":"uvnet-vjyd5t1n"}],"RetCode":0,"TotalCount":2} - 200"
time="2021-05-26T10:31:44+08:00" level=info msg="[2a39391a-d9c2-4d7a-ac78-c38f4a87f17e] do DescribeVPC successful!"
time="2021-05-26T10:31:44+08:00" level=debug msg="[78178e47-fa21-488d-a6c3-0af5cfdb3303] https://api.ucloud.cn?Action=DescribeSubnet Action=DescribeSubnet&Limit=100&Offset=0&ProjectId=org-xehypo&PublicKey=JInqRnkSY8eAmxKFRxW9kVANYThbzxJKNMEWhQ54N&Region=hk&Signature=4c6c89a500e87918518068c31ffc95c0272c50e4&VPCId=uvnet-ecrfor2j"
time="2021-05-26T10:31:44+08:00" level=debug msg="[78178e47-fa21-488d-a6c3-0af5cfdb3303] {"Action":"DescribeSubnetResponse","DataSet":[{"CreateTime":1562309253,"Gateway":"10.8.0.1","HasNATGW":false,"Name":"DefaultNetwork","Netmask":"16","Remark":"","RouteTableId":"routetable-1bgca25e","Subnet":"10.8.0.0","SubnetId":"subnet-i1yvk2eu","SubnetName":"DefaultNetwork","SubnetType":0,"Tag":"Default","VPCId":"uvnet-ecrfor2j","VPCName":"DefaultVPC","VRouterId":"Default_VRouter","Zone":"hk-01"},{"CreateTime":1562309255,"Gateway":"10.7.0.1","HasNATGW":false,"Name":"DefaultNetwork","Netmask":"16","Remark":"","RouteTableId":"routetable-1bgca25e","Subnet":"10.7.0.0","SubnetId":"subnet-oaglnnnh","SubnetName":"DefaultNetwork","SubnetType":0,"Tag":"Default","VPCId":"uvnet-ecrfor2j","VPCName":"DefaultVPC","VRouterId":"Default_VRouter","Zone":"hk-02"}],"RetCode":0,"TotalCount":4} - 200"
time="2021-05-26T10:31:44+08:00" level=info msg="[78178e47-fa21-488d-a6c3-0af5cfdb3303] do DescribeSubnet successful!"
time="2021-05-26T10:31:44+08:00" level=debug msg="[f8e7152d-10f6-4f94-a238-833f9ed75490] https://api.ucloud.cn?Action=CreateCubePod Action=CreateCubePod&ChargeType=Month&Name=tf-acc-cube-pod-basic&Pod=YXBpVmVyc2lvbjogdjFiZXRhMQpraW5kOiBQb2QKc3BlYzoKICBjb250YWluZXJzOgogICAgLSBuYW1lOiBjdWJlMDEKICAgICAgaW1hZ2U6ICd1aHViLnNlcnZpY2UudWNsb3VkLmNuL2xpYnJhcnkvbmdpbng6MS4xOC4wJwogICAgICByZXNvdXJjZXM6CiAgICAgICAgbGltaXRzOgogICAgICAgICAgbWVtb3J5OiAxMDI0TWkKICAgICAgICAgIGNwdTogMTAwMG0KICAgICAgdm9sdW1lTW91bnRzOiBbXQogIHZvbHVtZXM6IFtdCiAgcmVzdGFydFBvbGljeTogQWx3YXlz&ProjectId=org-xehypo&PublicKey=JInqRnkSY8eAmxKFRxW9kVANYThbzxJKNMEWhQ54N&Quantity=1&Region=hk&Signature=262c111c7568ded916fe8c3593a9d45eac158398&SubnetId=subnet-i1yvk2eu&Tag=tf-acc&VPCId=uvnet-ecrfor2j&Zone=hk-01"
time="2021-05-26T10:31:44+08:00" level=debug msg="[f8e7152d-10f6-4f94-a238-833f9ed75490] {"RetCode":240,"Message":"Permission error [Product]"}\n - 200"
time="2021-05-26T10:31:44+08:00" level=info msg="[f8e7152d-10f6-4f94-a238-833f9ed75490] do CreateCubePod successful!"

Even though UCloud api complained about "Permission error" with RetCode 240, UCloud tf provider output "do CreateCubePod successful!".

The root cause was in ucloud-sdk-go project, let's see CreateCubePodResponse definition:

type CreateCubePodResponse struct {
	response.CommonBase

	// 操作名称
	Action string

	// cube的资源Id
	CubeId string

	// base64编码的yaml
	Pod string

	// 返回码
	 RetCode int
}

CreateCubePodResponse struct embedded a response.CommonBase, whose definition is:

type CommonBase struct {
	Action  string
	RetCode int
	Message string

	requestUUID string

	request request.Common
}

Both structs have field named "RetCode int". When client unmarshal http response in InvokeActionWithPatcher func in client.go:

if err == nil {
		// use patch object to resolve the http response body
		// in general, it will be fix common server error before server bug fix is released.
		body := httpResp.GetBody()

		for _, patch := range patches {
			body = patch.Patch(body)
		}

		err = c.unmarshalHTTPResponse(body, resp)
	}

        // try to get request uuid
	if httpResp != nil {
		requestUUID := httpResp.GetHeaders().Get(headerKeyRequestUUID)
		resp.SetRequestUUID(requestUUID)
	}

	// use response middle to build and convert response when response has been created.
	// such as retry, report traceback, print log and etc.
	for _, handler := range c.responseHandlers {
		resp, err = handler(c, req, resp, err)
	}

The "240" RetCode in http response was actually written into CreateCubePodResponse's RetCode, not it's CommonBase's RetCode. Then when client try to check error from unmarshaled resp with responseHandlers, the handler func's signature is :

type ResponseHandler func(c *Client, req request.Common, resp response.Common, err error) (response.Common, error)

That meant we sent the embedded response.CommonBase with 0 RetCode into response handler and left 240 RetCode outside in CreateCubePodResponse.

After deletion of RetCode in CreateCubePodResponse, now we can see client return err as we expected:

DEBU[2021-05-26T11:19:54+08:00] [9f70eec0-810f-4271-9652-bc404afa8d37] https://api.ucloud.cn?Action=CreateCubePod Action=CreateCubePod&ChargeType=Month&Name=tf-acc-cube-pod-basic&Pod=YXBpVmVyc2lvbjogdjFiZXRhMQpraW5kOiBQb2QKc3BlYzoKICBjb250YWluZXJzOgogICAgLSBuYW1lOiBjdWJlMDEKICAgICAgaW1hZ2U6ICd1aHViLnNlcnZpY2UudWNsb3VkLmNuL2xpYnJhcnkvbmdpbng6MS4xOC4wJwogICAgICByZXNvdXJjZXM6CiAgICAgICAgbGltaXRzOgogICAgICAgICAgbWVtb3J5OiAxMDI0TWkKICAgICAgICAgIGNwdTogMTAwMG0KICAgICAgdm9sdW1lTW91bnRzOiBbXQogIHZvbHVtZXM6IFtdCiAgcmVzdGFydFBvbGljeTogQWx3YXlz&ProjectId=org-xehypo&PublicKey=JInqRnkSY8eAmxKFRxW9kVANYThbzxJKNMEWhQ54N&Quantity=1&Region=hk&Signature=508f708ceaaa7026c083fd0184be3c70fcff56df&SubnetId=subnet-eyqkr1km&Tag=tf-acc&VPCId=uvnet-vjyd5t1n&Zone=hk-01
DEBU[2021-05-26T11:19:54+08:00] [9f70eec0-810f-4271-9652-bc404afa8d37] {"RetCode":240,"Message":"Permission error [Product]"}

Now the problem is, what's the meaning of "Permission error [Product]"?

ucloud_lb imported properties not matched with default values

I imported an existing ULB into terraform for evaluation, here's my config for it:

resource "ucloud_lb" "ulb-01" {
  name          = "ulb-01"
  tag           = "ulb"
}

Because imported charge_type and internal are empty "", while their default values are "month" and false, terraform will always recreate the resource, which is not desired:

Terraform will perform the following actions:

-/+ ucloud_lb.ulb-01 (new resource required)
      id:          "ulb-abcdef" => <computed> (forces new resource)
      charge_type: "" => "month" (forces new resource)
      create_time: "2016-11-18T14:05:01+08:00" => <computed>
      expire_time: "1970-01-01T08:00:00+08:00" => <computed>
      internal:    "" => "false" (forces new resource)
      ip_set.#:    "1" => <computed>
      name:        "ulb-01" => "ulb-01"
      private_ip:  "" => <computed>
      remark:      "" => <computed>
      subnet_id:   "" => <computed>
      tag:         "ulb" => "ulb"
      vpc_id:      "uvnet-v5qggb" => <computed>

Plan: 1 to add, 0 to change, 1 to destroy.

区域指定华北2 报错返回区域不可用

ucloud_instance.example: Creating...

│ Error: error on creating instance, api:
│ [server.RetCodeError] 230 Params [Zone] not available

│ with ucloud_instance.example,
│ on main.tf line 26, in resource "ucloud_instance" "example":
│ 26: resource "ucloud_instance" "example" {


Releasing state lock. This may take a few moments...

Parameter duration does not take effect

  • duration - (Optional) The duration that you will buy the instance (Default: 1). The value is 0 when pay by month and the instance will be vaild till the last day of that month. It is not required when dynamic (pay by hour).

Create a server according to the instructions, set "duration"=0, prompt Error: expected duration to be in the range (1 - 9), got 0

`ucloud_uk8s_node.boot_disk_type` is not optional

While creating an ucloud_uk8s_node resource, if I don't specify the boot_disk_type, the provider will choose cloud_ssd, as the documentation says. But actually I received this error message:


Error: error on creating uk8s cluster, api:
[server.RetCodeError] 94003 

After consulting UCloud technicians, it appears to be the problem of missing BootDiskType.. So I supplied boot_disk_type = "cloud_rssd" which worked. Maybe the documentation should be updated?

520 Lack of balance

I met the following issue after applying the sample code of web-server

ucloud_eip.default: Creating...
ucloud_disk.default: Creating...
ucloud_instance.web: Creating...
ucloud_eip.default: Creation complete after 3s [id=eip-addp3wvh]
ucloud_disk.default: Creation complete after 3s [id=bs-mwuwkcqt]

Error: error on creating instance, api:
[server.RetCodeError] 520 Lack of balance

  on main.tf line 23, in resource "ucloud_instance" "web":
  23: resource "ucloud_instance" "web" {

my terraform version is

$ terraform -version
Terraform v0.12.21
+ provider.ucloud v1.16.0

Your version of Terraform is out of date! The latest version
is 0.12.23. You can update by downloading from https://www.terraform.io/downloads.html

I don't know what's wrong here, wait for your help. thanks.

ucloud_lb_listener import raises "[server.RetCodeError] 210 Missing params [ULBId]"

$ terraform import "ucloud_lb_listener.vserver-01" vserver-uvwxyz
ucloud_lb_listener.vserver-01: Importing from ID "vserver-uvwxyz"...
ucloud_lb_listener.vserver-01: Import complete!
  Imported ucloud_lb_listener (ID: vserver-uvwxyz)
ucloud_lb_listener.vserver-01: Refreshing state... (ID: vserver-uvwxyz)

Error: ucloud_lb_listener.vserver-01 (import id: vserver-uvwxyz): 1 error(s) occurred:

* import ucloud_lb_listener.vserver-01 result: vserver-uvwxyz: ucloud_lb_listener.vserver-01: error on reading lb listener "vserver-uvwxyz", api:
[server.RetCodeError] 210 Missing params [ULBId]

[PROPOSAL] Switch to Go Modules

As part of the preparation for Terraform v0.12, we would like to migrate all providers to use Go Modules. We plan to continue checking dependencies into vendor/ to remain compatible with existing tooling/CI for a period of time, however go modules will be used for management. Go Modules is the official solution for the go programming language, we understand some providers might not want this change yet, however we encourage providers to begin looking towards the switch as this is how we will be managing all Go projects in the future. Would maintainers please react with 👍 for support, or 👎 if you wish to have this provider omitted from the first wave of pull requests. If your provider is in support, we would ask that you avoid merging any pull requests that mutate the dependencies while the Go Modules PR is open (in fact a total codefreeze would be even more helpful), otherwise we will need to close that PR and re-run go mod init. Once merged, dependencies can be added or updated as follows:

$ GO111MODULE=on go get github.com/some/module@master
$ GO111MODULE=on go mod tidy
$ GO111MODULE=on go mod vendor

GO111MODULE=on might be unnecessary depending on your environment, this example will fetch a module @ master and record it in your project's go.mod and go.sum files. It's a good idea to tidy up afterward and then copy the dependencies into vendor/. To remove dependencies from your project, simply remove all usage from your codebase and run:

$ GO111MODULE=on go mody tidy
$ GO111MODULE=on go mod vendor

Thank you sincerely for all your time, contributions, and cooperation!

go v1.11 or v1.12

Hello!
I stumbled upon this repository, and was going through the readme, and saw that for building 1.12 is required, but for development it says it could be built using 1.11+, is this just a piece of documentation that hasn't been updated?

Thanks

Feature Request: UFS mounting point resource

Hiii,
I noticed while there is a nice and working ucloud_ufs_volume resource, there isn't a corresponding resource for the ufs mounting point. The resource would be very useful because an UFS volume itself isn't immediately usable without the mounting point attached to it...

foreach not supported by resource ucloud_security_group.

I have my own security group rule defined as a map in variables file, just like:

xxx_sg_rules = {
    beijing = [
      {
        "priority"    = "medium"
        "type"        = "ingress"
        "ip_protocol" = "icmp"
        "port_range"  = "1-65535"
        "source"      = "0.0.0.0/0"
        "policy"      = "accept"
        "description" = "ICMP"
      },
     {
     ........
     }
...

i'm trying to define rules in ucloud_security_group like:

foreach rule in xxx_sg_rules.beijing:
rules {
 port_range = rule.port_range
 .....
}

and got some errors, it seems like ucloud doesn't support foreach and for yet.

I'm using count as an alternative for now, if someone else has the same problem with me could have a try. (As ucloud_instance doesn't support bind mutiple security_group, this solution doesn't work, see #76)

ucloud_disk: when using rssd, the rdma cluster is missing

When using the ucloud_disk resource to create the rssd disk, terraform is missing the rdma information of the rssd disk, and the backend will randomly assign a rdma cluster to it.

In this way, the rdma cluster of uhost may be inconsistent with that of udisk, and an error will be reported when binding the disk:

Error: error on creating disk attachment, api:
[server.RetCodeError] 17218 uhost error, Error: Command failed: add_udisk.py failed

Now we have 2 solutions:

  • Add a field to ucloud_disk so that user can specify rdma_cluster_id.
  • Forbid users to create rssd disks in this way, forcing them to use data_disk in ucloud_instance.

Failed to set up VPC peering connection

I hit the following issue when applying vpc resource in https://github.com/ucloud/terraform-provider-ucloud/tree/master/examples/vpc.

➜  vpc git:(master) t apply -auto-approve

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # ucloud_udpn_connection.default will be created
  + resource "ucloud_udpn_connection" "default" {
      + bandwidth   = 2
      + charge_type = "month"
      + create_time = (known after apply)
      + expire_time = (known after apply)
      + id          = (known after apply)
      + peer_region = "cn-sh2"
    }

  # ucloud_vpc.bar will be created
  + resource "ucloud_vpc" "bar" {
      + cidr_blocks  = [
          + "10.10.0.0/16",
        ]
      + create_time  = (known after apply)
      + id           = (known after apply)
      + name         = "tf-example-vpc-02"
      + network_info = (known after apply)
      + remark       = (known after apply)
      + tag          = "tf-example"
      + update_time  = (known after apply)
    }

  # ucloud_vpc.foo will be created
  + resource "ucloud_vpc" "foo" {
      + cidr_blocks  = [
          + "192.168.0.0/16",
        ]
      + create_time  = (known after apply)
      + id           = (known after apply)
      + name         = "tf-example-vpc-01"
      + network_info = (known after apply)
      + remark       = (known after apply)
      + tag          = "tf-example"
      + update_time  = (known after apply)
    }

  # ucloud_vpc_peering_connection.connection will be created
  + resource "ucloud_vpc_peering_connection" "connection" {
      + id              = (known after apply)
      + peer_project_id = (known after apply)
      + peer_region     = "cn-sh2"
      + peer_vpc_id     = (known after apply)
      + vpc_id          = (known after apply)
    }

Plan: 4 to add, 0 to change, 0 to destroy.
ucloud_vpc.bar: Creating...
ucloud_vpc.foo: Creating...
ucloud_udpn_connection.default: Creating...
ucloud_vpc.foo: Creation complete after 5s [id=uvnet-mcyi4jhk]
ucloud_vpc.bar: Creation complete after 5s [id=uvnet-ev1ce1bd]
ucloud_udpn_connection.default: Still creating... [10s elapsed]
ucloud_udpn_connection.default: Still creating... [20s elapsed]
ucloud_udpn_connection.default: Still creating... [30s elapsed]
ucloud_udpn_connection.default: Still creating... [40s elapsed]
ucloud_udpn_connection.default: Still creating... [50s elapsed]
ucloud_udpn_connection.default: Still creating... [1m0s elapsed]
ucloud_udpn_connection.default: Still creating... [1m10s elapsed]
ucloud_udpn_connection.default: Still creating... [1m20s elapsed]
ucloud_udpn_connection.default: Still creating... [1m30s elapsed]
ucloud_udpn_connection.default: Still creating... [1m40s elapsed]
ucloud_udpn_connection.default: Still creating... [1m50s elapsed]
ucloud_udpn_connection.default: Still creating... [2m0s elapsed]
ucloud_udpn_connection.default: Still creating... [2m10s elapsed]
ucloud_udpn_connection.default: Still creating... [2m20s elapsed]
ucloud_udpn_connection.default: Still creating... [2m30s elapsed]
ucloud_udpn_connection.default: Still creating... [2m40s elapsed]
ucloud_udpn_connection.default: Still creating... [2m50s elapsed]
╷
│ Error: error on waiting for udpn connection "" complete creating, couldn't find resource (21 retries)
│
│   with ucloud_udpn_connection.default,
│   on main.tf line 11, in resource "ucloud_udpn_connection" "default":
│   11: resource "ucloud_udpn_connection" "default" {
│
╵

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.