Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Invalid resource type #1

Closed
lyc0221 opened this issue May 20, 2020 · 3 comments
Closed

Error: Invalid resource type #1

lyc0221 opened this issue May 20, 2020 · 3 comments

Comments

@lyc0221
Copy link

lyc0221 commented May 20, 2020

Error: Invalid resource type

  on ../../modules/huaweicloud-cdn-domain/main.tf line 2, in resource "huaweicloud_cdn_domain_v1" "this":
   2: resource "huaweicloud_cdn_domain_v1" "this" {

The provider provider.huaweicloud does not support resource type
"huaweicloud_cdn_domain_v1".

Terraform v0.12.24
provider.huaweicloud v1.14.0

main.tf

module "cdn" {
  source  ="../../modules/huaweicloud-cdn-domain"

  name    = var. name
  type    = var.type
  sources = var.sources
}

variables.tf

variable "huaweicloud_access_key" {
}

variable "huaweicloud_secret_key" {
}

variable "name" {
  description = "The acceleration domain name. Changing this parameter will create a new resource."
  default     = "www.steptomoney.cn"
}

variable "type" {
  description = "The service type. The valid values are 'web', 'download' and 'video'. Changing this parameter will create a new resource."
  default     = "web"
}

variable "sources" {
  # origin - (Required) The domain name or IP address of the origin server.
  # origin_type - (Required) The origin server type. The valid values are 'ipaddr', 'domain', and 'obs_bucket'.
  # active - (Optional) Whether an origin server is active or standby (1: active; 0: standby). The default value is 1.

  description = "An array of one or more objects specifies the domain name of the origin server."
  default     = [
    {
      "origin": "api.steptomoney.cn",
      "origin_type": "domain",
      "active": 1
    }
  ]
}

../../modules/huaweicloud-cdn-domain/main.tf

# Create CDN
resource "huaweicloud_cdn_domain_v1" "this" {
  name   = var.name
  type   = var.type

  sources {
    origin      = var.sources[0]["origin"]
    origin_type = var.sources[0]["origin_type"]
    active      = var.sources[0]["active"]
  }
}

If ../../modules/huaweicloud-cdn-domain/main.tf was configured like this, it will crash.

# Create CDN
resource "huaweicloud_cdn_domain_v1" "this" {
  name   = var.name
  type   = var.type

  dynamic "sources" {
    iterator = item
    for_each = var.sources
    
    content {
      origin      = item.value["origin"]
      origin_type = item.value["origin_type"]
      active      = item.value["active"]
    }
  }
}

crash.log

@lyc0221
Copy link
Author

lyc0221 commented May 22, 2020

@niuzhenguo can you help me resolve this ? thanks!

@niuzhenguo
Copy link
Contributor

@lyc0221 Sorry, will fix on provider side.

@niuzhenguo
Copy link
Contributor

@lyc0221 lyc0221 closed this as completed May 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants