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

Should interface_name and transformation_id be optional? #823

Closed
chrismarget-j opened this issue Aug 27, 2024 · 5 comments
Closed

Should interface_name and transformation_id be optional? #823

chrismarget-j opened this issue Aug 27, 2024 · 5 comments

Comments

@chrismarget-j
Copy link
Collaborator

https://github.com/Juniper/terraform-provider-apstra/blob/cc3b7926c497aa4e7f8539724b62f9c76080e1d8/apstra/freeform/endpoint.go#L78C1-L98C1

interface_name and transformation_id are currently optional. Should they be required?

@ihadi581
Copy link

I think for internal systems it is mandatory and for external systems it is optional.

@chrismarget-j
Copy link
Collaborator Author

@ihadi581 Right! Thank you.

I forgot we'd been down this road before.

I just created a link between two internal systems without using either of these details, and it... "worked".

We may need a safety check during create which ensures that these values are included for internal systems.

@ihadi581
Copy link

@chrismarget-j correct in my testing if i put interfaces name in external system they report need transformation_id if we run plan and if i put dummy transformation_id terraform get error not applicable > plan OK - apply error

example tf condition put interface name :

resource "apstra_freeform_link" "lf-dc1-01_vmx_client" {
  blueprint_id = apstra_freeform_blueprint.dc1.id
  name         = "LF_LAB_DC1_01<>vMX_Client_DC"
  tags         = null
  endpoints    = {
      "${apstra_freeform_system.lf-dc1-01.id}"   = {
            interface_name    = "et-0/0/2:0"
            ipv4_address      = null
            transformation_id = 12
       },
       "${apstra_freeform_system.vmx_client.id}" = {
            interface_name    = "ge-0/0/0"
            ipv4_address      = null
            transformation_id = null
            }
      }
}

output :

Planning failed. Terraform encountered an error while generating this plan.

╷
│ Error: Invalid Attribute Combination
│ 
│   with apstra_freeform_link.lf-dc1-01_vmx_client,
│   on system-link-generate.tf line 103, in resource "apstra_freeform_link" "lf-dc1-01_vmx_client":
│  103: resource "apstra_freeform_link" "lf-dc1-01_vmx_client" {
│ 
│ Attribute "endpoints[\"q2p0SW9OWt2UEAjo0fU\"].transformation_id" must be specified when "endpoints[\"q2p0SW9OWt2UEAjo0fU\"].interface_name" is specified

condition 2 put dummy transformation_id :

resource "apstra_freeform_link" "lf-dc1-01_vmx_client" {
  blueprint_id = apstra_freeform_blueprint.dc1.id
  name         = "LF_LAB_DC1_01<>vMX_Client_DC"
  tags         = null
  endpoints    = {
      "${apstra_freeform_system.lf-dc1-01.id}"   = {
            interface_name    = "et-0/0/2:0"
            ipv4_address      = null
            transformation_id = 12
       },
       "${apstra_freeform_system.vmx_client.id}" = {
            interface_name    = "ge-0/0/0"
            ipv4_address      = null
            transformation_id = 1
            }
      }
}

output :

╷
│ Error: error creating new Link
│ 
│   with apstra_freeform_link.lf-dc1-01_vmx_client,
│   on system-link-generate.tf line 103, in resource "apstra_freeform_link" "lf-dc1-01_vmx_client":
│  103: resource "apstra_freeform_link" "lf-dc1-01_vmx_client" {
│ 
│ {"api_response":null,"config_blueprint_version":0,"errors":{"transformation_id":"Port transformation ID is not applicable for external system"},"error_code":422} - http response '' at
│ 'http://192.187.125.211:8443/api/blueprints/59ba8b30-2e07-48b6-ab60-678840f8288a/links?async=full&async=full'
╵

so i suggestion for external system is optional

@chrismarget-j
Copy link
Collaborator Author

We wrote this error, because transformation_id and interface_name, while optional, should be specified together (or not at all):

Attribute "endpoints[\"q2p0SW9OWt2UEAjo0fU\"].transformation_id" must be specified when "endpoints[\"q2p0SW9OWt2UEAjo0fU\"].interface_name" is specified

This error is from the API:

{"api_response":null,"config_blueprint_version":0,"errors":{"transformation_id":"Port transformation ID is not applicable for external system"},"error_code":422}

...so that case is covered.

But there's another case: transformation_id and interface_name are omitted with an internal system. Terraform doesn't notice this (we don't know the system type, only the ID), and the API doesn't complain.

This one seems like a problem we should catch, so that half-baked links to internal systems don't get created.

@chrismarget-j
Copy link
Collaborator Author

Moving this discussion to #825

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