terraform {
required_providers {
packetfabric = {
# source = "PacketFabric/packetfabric"
# version = "0.2.0"
source = "terraform.local/PacketFabric/packetfabric"
version = "~> 0.0.0"
}
google = {
source = "hashicorp/google"
version = "4.30.0"
}
}
}
provider "packetfabric" {
host = var.pf_api_server
token = var.pf_api_key
}
# Make sure you enabled Compute Engine API
provider "google" {
project = var.gcp_project_id
credentials = file(var.gcp_credentials)
region = var.gcp_region1
zone = var.gcp_zone1
}
# create random name to use to name objects
resource "random_pet" "name" {}
resource "google_compute_network" "vpc_1" {
provider = google
name = "${var.tag_name}-${random_pet.name.id}"
auto_create_subnetworks = false
}
resource "google_compute_subnetwork" "subnet_1" {
provider = google
name = "${var.tag_name}-${random_pet.name.id}"
ip_cidr_range = var.subnet_cidr1
region = var.gcp_region1
network = google_compute_network.vpc_1.id
}
output "google_compute_network" {
value = google_compute_network.vpc_1
}
# From the Google side: Create a Google Cloud Router with ASN 16550.
resource "google_compute_router" "router_1" {
provider = google
name = "${var.tag_name}-${random_pet.name.id}"
network = google_compute_network.vpc_1.id
bgp {
# You must select or create a Cloud Router with its Google ASN set to 16550. This is a Google requirement for all Partner Interconnects.
asn = var.peer_asn
advertise_mode = "CUSTOM"
advertised_groups = ["ALL_SUBNETS"]
}
}
# From the Google side: Create a VLAN attachment.
resource "google_compute_interconnect_attachment" "interconnect_1" {
provider = google
name = "${var.tag_name}-${random_pet.name.id}"
region = var.gcp_region1
description = "Interconnect to PacketFabric Network"
type = "PARTNER"
admin_enabled = true # From the Google side: Accept (automatically) the connection.
router = google_compute_router.router_1.id
}
# From the PacketFabric side: Create a GCP Hosted Connection
resource "packetfabric_cs_google_hosted_connection" "pf_cs_conn1" {
provider = packetfabric
description = "${var.tag_name}-${random_pet.name.id}"
account_uuid = var.pf_account_uuid
port = var.pf_port_circuit_id
speed = var.pf_cs_speed
google_pairing_key = google_compute_interconnect_attachment.interconnect_1.pairing_key
google_vlan_attachment_name = "${var.tag_name}-${random_pet.name.id}"
pop = var.pf_cs_pop1
vlan = var.pf_cs_vlan1
}
output "packetfabric_cs_google_hosted_connection" {
value = packetfabric_cs_google_hosted_connection.pf_cs_conn1
sensitive = true
}
random_pet.name: Refreshing state... [id=fancy-quagga]
google_compute_network.vpc_1: Refreshing state... [id=projects/prefab-setting-357415/global/networks/demo-pf-google-fancy-quagga]
data.google_compute_router.router_1: Reading...
google_compute_subnetwork.subnet_1: Refreshing state... [id=projects/prefab-setting-357415/regions/us-west1/subnetworks/demo-pf-google-fancy-quagga]
google_compute_router.router_1: Refreshing state... [id=projects/prefab-setting-357415/regions/us-west1/routers/demo-pf-google-fancy-quagga]
data.google_compute_router.router_1: Read complete after 0s [id=demo-pf-google-fancy-quagga]
google_compute_interconnect_attachment.interconnect_1: Refreshing state... [id=projects/prefab-setting-357415/regions/us-west1/interconnectAttachments/demo-pf-google-fancy-quagga]
packetfabric_cs_google_hosted_connection.pf_cs_conn1: Refreshing state... [id=c983e47c-f2f8-4f22-9f32-5f809d69f281]
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the
following symbols:
- destroy
Terraform will perform the following actions:
# google_compute_interconnect_attachment.interconnect_1 will be destroyed
- resource "google_compute_interconnect_attachment" "interconnect_1" {
- admin_enabled = true -> null
- bandwidth = "BPS_50M" -> null
- cloud_router_ip_address = "169.254.172.153/29" -> null
- creation_timestamp = "2022-08-19T12:47:16.927-07:00" -> null
- customer_router_ip_address = "169.254.172.154/29" -> null
- description = "Interconnect to PacketFabric Network" -> null
- edge_availability_domain = "AVAILABILITY_DOMAIN_1" -> null
- encryption = "NONE" -> null
- id = "projects/prefab-setting-357415/regions/us-west1/interconnectAttachments/demo-pf-google-fancy-quagga" -> null
- ipsec_internal_addresses = [] -> null
- name = "demo-pf-google-fancy-quagga" -> null
- pairing_key = "087e4c80-3a23-4248-8794-ade960d5deff/us-west1/any" -> null
- private_interconnect_info = [] -> null
- project = "prefab-setting-357415" -> null
- region = "https://www.googleapis.com/compute/v1/projects/prefab-setting-357415/regions/us-west1" -> null
- router = "https://www.googleapis.com/compute/v1/projects/prefab-setting-357415/regions/us-west1/routers/demo-pf-google-fancy-quagga" -> null
- self_link = "https://www.googleapis.com/compute/v1/projects/prefab-setting-357415/regions/us-west1/interconnectAttachments/demo-pf-google-fancy-quagga" -> null
- state = "ACTIVE" -> null
- type = "PARTNER" -> null
- vlan_tag8021q = 107 -> null
}
# google_compute_network.vpc_1 will be destroyed
- resource "google_compute_network" "vpc_1" {
- auto_create_subnetworks = false -> null
- delete_default_routes_on_create = false -> null
- enable_ula_internal_ipv6 = false -> null
- id = "projects/prefab-setting-357415/global/networks/demo-pf-google-fancy-quagga" -> null
- mtu = 0 -> null
- name = "demo-pf-google-fancy-quagga" -> null
- project = "prefab-setting-357415" -> null
- routing_mode = "REGIONAL" -> null
- self_link = "https://www.googleapis.com/compute/v1/projects/prefab-setting-357415/global/networks/demo-pf-google-fancy-quagga" -> null
}
# google_compute_router.router_1 will be destroyed
- resource "google_compute_router" "router_1" {
- creation_timestamp = "2022-08-19T12:45:08.494-07:00" -> null
- encrypted_interconnect_router = false -> null
- id = "projects/prefab-setting-357415/regions/us-west1/routers/demo-pf-google-fancy-quagga" -> null
- name = "demo-pf-google-fancy-quagga" -> null
- network = "https://www.googleapis.com/compute/v1/projects/prefab-setting-357415/global/networks/demo-pf-google-fancy-quagga" -> null
- project = "prefab-setting-357415" -> null
- region = "us-west1" -> null
- self_link = "https://www.googleapis.com/compute/v1/projects/prefab-setting-357415/regions/us-west1/routers/demo-pf-google-fancy-quagga" -> null
- bgp {
- advertise_mode = "CUSTOM" -> null
- advertised_groups = [
- "ALL_SUBNETS",
] -> null
- asn = 16550 -> null
- keepalive_interval = 20 -> null
}
}
# google_compute_subnetwork.subnet_1 will be destroyed
- resource "google_compute_subnetwork" "subnet_1" {
- creation_timestamp = "2022-08-19T12:45:09.406-07:00" -> null
- gateway_address = "10.5.1.1" -> null
- id = "projects/prefab-setting-357415/regions/us-west1/subnetworks/demo-pf-google-fancy-quagga" -> null
- ip_cidr_range = "10.5.1.0/24" -> null
- name = "demo-pf-google-fancy-quagga" -> null
- network = "https://www.googleapis.com/compute/v1/projects/prefab-setting-357415/global/networks/demo-pf-google-fancy-quagga" -> null
- private_ip_google_access = false -> null
- private_ipv6_google_access = "DISABLE_GOOGLE_ACCESS" -> null
- project = "prefab-setting-357415" -> null
- purpose = "PRIVATE" -> null
- region = "us-west1" -> null
- secondary_ip_range = [] -> null
- self_link = "https://www.googleapis.com/compute/v1/projects/prefab-setting-357415/regions/us-west1/subnetworks/demo-pf-google-fancy-quagga" -> null
- stack_type = "IPV4_ONLY" -> null
}
# packetfabric_cs_google_hosted_connection.pf_cs_conn1 will be destroyed
- resource "packetfabric_cs_google_hosted_connection" "pf_cs_conn1" {
- account_uuid = "24a0aef3-2784-48dc-9a8e-52d44d6da646" -> null
- description = "demo-pf-google-fancy-quagga" -> null
- google_pairing_key = "087e4c80-3a23-4248-8794-ade960d5deff/us-west1/any" -> null
- google_vlan_attachment_name = "demo-pf-google-fancy-quagga" -> null
- id = "c983e47c-f2f8-4f22-9f32-5f809d69f281" -> null
- pop = "SFO1" -> null
- port = "PF-AP-WDC1-1726464" -> null
- speed = "50Mbps" -> null
- vlan = 105 -> null
}
# random_pet.name will be destroyed
- resource "random_pet" "name" {
- id = "fancy-quagga" -> null
- length = 2 -> null
- separator = "-" -> null
}
Plan: 0 to add, 0 to change, 6 to destroy.
Changes to Outputs:
- google_compute_network = {
- auto_create_subnetworks = false
- delete_default_routes_on_create = false
- description = ""
- enable_ula_internal_ipv6 = false
- gateway_ipv4 = ""
- id = "projects/prefab-setting-357415/global/networks/demo-pf-google-fancy-quagga"
- internal_ipv6_range = ""
- mtu = 0
- name = "demo-pf-google-fancy-quagga"
- project = "prefab-setting-357415"
- routing_mode = "REGIONAL"
- self_link = "https://www.googleapis.com/compute/v1/projects/prefab-setting-357415/global/networks/demo-pf-google-fancy-quagga"
- timeouts = null
} -> null
- google_compute_router = {
- bgp = [
- {
- advertise_mode = "CUSTOM"
- advertised_groups = [
- "ALL_SUBNETS",
]
- advertised_ip_ranges = []
- asn = 16550
- keepalive_interval = 20
},
]
- creation_timestamp = "2022-08-19T12:45:08.494-07:00"
- description = ""
- encrypted_interconnect_router = false
- id = "demo-pf-google-fancy-quagga"
- name = "demo-pf-google-fancy-quagga"
- network = "https://www.googleapis.com/compute/v1/projects/prefab-setting-357415/global/networks/demo-pf-google-fancy-quagga"
- project = "prefab-setting-357415"
- region = "us-west1"
- self_link = "https://www.googleapis.com/compute/v1/projects/prefab-setting-357415/regions/us-west1/routers/demo-pf-google-fancy-quagga"
} -> null
- packetfabric_cs_google_hosted_connection = (sensitive value)
packetfabric_cs_google_hosted_connection.pf_cs_conn1: Destroying... [id=c983e47c-f2f8-4f22-9f32-5f809d69f281]
google_compute_subnetwork.subnet_1: Destroying... [id=projects/prefab-setting-357415/regions/us-west1/subnetworks/demo-pf-google-fancy-quagga]
google_compute_subnetwork.subnet_1: Still destroying... [id=projects/prefab-setting-357415/regions/...ubnetworks/demo-pf-google-fancy-quagga, 10s elapsed]
google_compute_subnetwork.subnet_1: Destruction complete after 11s
╷
│ Warning: Value for undeclared variable
│
│ The root module does not declare a variable named "subscription_id" but a value was found in file "secret.tfvars". If you
│ meant to use this value, add a "variable" block to the configuration.
│
│ To silence these warnings, use TF_VAR_... environment variables to provide certain "global" settings to all configurations
│ in your organization. To reduce the verbosity of these warnings, use the -compact-warnings option.
╵
╷
│ Warning: Value for undeclared variable
│
│ The root module does not declare a variable named "tenant_id" but a value was found in file "secret.tfvars". If you meant
│ to use this value, add a "variable" block to the configuration.
│
│ To silence these warnings, use TF_VAR_... environment variables to provide certain "global" settings to all configurations
│ in your organization. To reduce the verbosity of these warnings, use the -compact-warnings option.
╵
╷
│ Warning: Values for undeclared variables
│
│ In addition to the other similar warnings shown, 14 other variable(s) defined without being declared.
╵
╷
│ Error: Plugin did not respond
│
│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ApplyResourceChange call. The plugin
│ logs may contain more details.
╵
Stack trace from the terraform-provider-packetfabric plugin:
panic: runtime error: index out of range [0] with length 0
goroutine 37 [running]:
github.com/PacketFabric/terraform-provider-packetfabric/internal/packetfabric.(*PFClient).DeleteBackbone(0xc0003c65a0, {0xc000126f60, 0x24})
/working/terraform-provider-packetfabric/internal/packetfabric/cloud_service.go:149 +0x44c
github.com/PacketFabric/terraform-provider-packetfabric/internal/provider.resourceBackboneDelete({0xd5d7e8?, 0xc0003c72c0?}, 0xd5d820?, {0xc32be0?, 0xc0003c65a0}, 0x1176592e000?)
/working/terraform-provider-packetfabric/internal/provider/resource_backbone.go:179 +0xc5
github.com/PacketFabric/terraform-provider-packetfabric/internal/provider.resourceGoogleReqHostConnDelete({0xd5d7e8?, 0xc0003c72c0?}, 0x7f05ef764108?, {0xc32be0?, 0xc0003c65a0?})
/working/terraform-provider-packetfabric/internal/provider/resource_google_request_hosted_conn.go:105 +0x55
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).delete(0xc000125a40, {0xd5d820, 0xc0003fe660}, 0xd?, {0xc32be0, 0xc0003c65a0})
/root/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:758 +0x12e
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc000125a40, {0xd5d820, 0xc0003fe660}, 0xc00041fee0, 0xc00009b300, {0xc32be0, 0xc0003c65a0})
/root/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:806 +0x5fa
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc000242420, {0xd5d778?, 0xc000443840?}, 0xc0003fc370)
/root/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:1021 +0xe3c
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc000252aa0, {0xd5d820?, 0xc0003e1e60?}, 0xc0003d68c0)
/root/go/pkg/mod/github.com/hashicorp/[email protected]/tfprotov5/tf5server/server.go:812 +0x515
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0xc095a0?, 0xc000252aa0}, {0xd5d820, 0xc0003e1e60}, 0xc0003c6ba0, 0x0)
/root/go/pkg/mod/github.com/hashicorp/[email protected]/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:385 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0002a68c0, {0xd60550, 0xc000003d40}, 0xc0000f3200, 0xc0003478f0, 0x11e4b20, 0x0)
/root/go/pkg/mod/google.golang.org/[email protected]/server.go:1283 +0xcfd
google.golang.org/grpc.(*Server).handleStream(0xc0002a68c0, {0xd60550, 0xc000003d40}, 0xc0000f3200, 0x0)
/root/go/pkg/mod/google.golang.org/[email protected]/server.go:1620 +0xa1b
google.golang.org/grpc.(*Server).serveStreams.func1.2()
/root/go/pkg/mod/google.golang.org/[email protected]/server.go:922 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
/root/go/pkg/mod/google.golang.org/[email protected]/server.go:920 +0x28a
Error: The terraform-provider-packetfabric plugin crashed!
This is always indicative of a bug within the plugin. It would be immensely
helpful if you could report the crash with the plugin's maintainers so that it
can be fixed. The output above should help diagnose the issue.
b7b65185ee94# terraform state list
google_compute_interconnect_attachment.interconnect_1
google_compute_network.vpc_1
google_compute_router.router_1
packetfabric_cs_google_hosted_connection.pf_cs_conn1
random_pet.name