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

ウェブアクセラレータ対応 #523

Merged
merged 4 commits into from Oct 31, 2019

Conversation

yamamoto-febc
Copy link
Member

@yamamoto-febc yamamoto-febc commented Oct 30, 2019

fixed #256

ウェブアクセラレータ対応を行う。

  • sakuracloud_webaccel: データソースのみ
  • sakuracloud_webaccel_certificate: 証明書リソース

Note: sakuracloud_webaccel_certificateでのimportはサポートしない。これは証明書取得APIのレスポンスにKeyが含まれないことからimportしてもplan時に差分が発生してしまうため。

sakuracloud_webaccel データソース

data sakuracloud_webaccel "example" {
  domain = "www.example.com"
  # または
  # name = "example"
}
$ terraform show
data "sakuracloud_webaccel" "example" {
    cname_record_value = "xxxxxx.user.webaccel.jp."
    domain             = "www.example.com"
    domain_type        = "own_domain"
    has_certificate    = true
    id                 = "xxx"
    name               = "example"
    origin             = "192.0.2.1"
    site_id            = "xxx"
    status             = "enabled"
    subdomain          = "xxxxx.user.webaccel.jp"
    txt_record_value   = "webaccel=xxxxx.user.webaccel.jp"
}

ドメイン利用時のサイト有効化に必要なDNSレコード登録用の値を参照可能になっている。

data sakuracloud_webaccel "example" {
  domain = "www.example.com"
}

data sakuracloud_dns "zone" {
  name_selectors = ["example.com"]
}

# webaccelデータソースの値を参照してDNSレコード登録
resource "sakuracloud_dns_record" "webaccel" {
  dns_id = sakuracloud_dns.zone.id
  name   = "www"
  type   = "CNAME"
  value  = data.sakuracloud_webaccel.example.cname_record_value
}

sakuracloud_webaccel_certificateリソース

data sakuracloud_webaccel "site" {
  name = "example"
}

resource sakuracloud_webaccel_certificate "example" {
  site_id           = data.sakuracloud_webaccel.site.id
  certificate_chain = file("crt")
  private_key       = file("key")
}
$ terraform show

# sakuracloud_webaccel_certificate.example:
resource "sakuracloud_webaccel_certificate" "example" {
    certificate_chain   = (sensitive value)
    dns_names           = [
        "www.example.com",
    ]
    id                  = "xxx"
    issuer_common_name  = "Let's Encrypt Authority X3"
    not_after           = "2020-01-28T13:12:47+09:00"
    not_before          = "2019-10-30T13:12:47+09:00"
    serial_number       = "AA:BB:CC:..."
    sha256_fingerprint  = "AA:BB:CC:..."
    site_id             = "xxx"
    subject_common_name = "www.example.com"
}

(Updated: #525によるフィールド名変更)

@yamamoto-febc yamamoto-febc marked this pull request as ready for review October 31, 2019 01:07
@yamamoto-febc yamamoto-febc merged commit f7b7c0c into sacloud:master Oct 31, 2019
@yamamoto-febc yamamoto-febc deleted the webaccel branch October 31, 2019 01:19
@yamamoto-febc
Copy link
Member Author

#525 によりフィールド名を変更(key => private_key)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ウェブアクセラレータ対応
1 participant