Skip to content

Instantly share code, notes, and snippets.

@hrmsk66
Created January 10, 2024 12:10
Show Gist options
  • Save hrmsk66/c14a73caea37f044e42e68b0d93b375a to your computer and use it in GitHub Desktop.
Save hrmsk66/c14a73caea37f044e42e68b0d93b375a to your computer and use it in GitHub Desktop.
Importing a TLS Subscription

Importing a TLS Subscription

1. Find the ID of the Target TLS Subscription

curl -s https://api.fastly.com/tls/subscriptions -Hfastly-key:<api-key> | jq '.data[] | select(.type == "tls_subscription" and any(.relationships.tls_domains.data[]; .id == "certtest1.hkakehas.tokyo")).id'

2. Create TF Files

provider.tf

terraform {
  required_providers {
    fastly  = {
      source  = "fastly/fastly"
      version = "~> 5.6.0"
    }
  }
}

main.tf

resource "fastly_tls_subscription" "subscription" {}

3. Run terraform init and terraform import

terraform init
terraform import fastly_tls_subscription.subscription <id>

4. Run terraform show

terraform show -no-color > main.tf

5. Run terraform plan and Remove Unconfigurable Attribute

Run terraform plan. The error message will indicate which attributes aren't needed. Remove these from the main.tf file. After these adjustments, your main.tf should look like this:

# fastly_tls_subscription.subscription:
resource "fastly_tls_subscription" "subscription" {
    certificate_authority   = "certainly"
    common_name             = "certtest1.hkakehas.tokyo"
    configuration_id        = "OcHCmthRJZ0L8pxTIqKxaA"
    domains                 = [
        "certtest1.hkakehas.tokyo",
        "certtest2.hkakehas.tokyo",
    ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment