Skip to content

Commit

Permalink
feat: Add resource IPAM service
Browse files Browse the repository at this point in the history
  • Loading branch information
smutel committed Feb 7, 2021
1 parent bce527e commit 4e3d637
Show file tree
Hide file tree
Showing 4 changed files with 423 additions and 0 deletions.
57 changes: 57 additions & 0 deletions docs/resources/ipam_service.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# netbox\_ipam\_service Resource

Manage a service within Netbox.

## Example Usage

```hcl
resource "netbox_ipam_service" "service_test" {
name = "SMTP"
virtualmachine_id = netbox_virtualization_vm.vm_test.id
ip_addresses_id = [netbox_ipam_ip_addresses.ip_test.id]
port = "22"
protocol = "tcp"
description = "Service created by terraform"
tag {
name = "tag1"
slug = "tag1"
}
custom_fields = {
cf_boolean = "true"
cf_date = "2020-12-25"
cf_integer = "10"
cf_selection = "1"
cf_text = "Some text"
cf_url = "https://github.com"
}
}
```

## Argument Reference

The following arguments are supported:
* ``custom_fields`` - (Optional) Custom Field Keys and Values for this object
* For boolean, use the string value "true" or "false"
* For data, use the string format "YYYY-MM-DD"
* For integer, use the value between double quote "10"
* For selection, use the level id
* For text, use the string value
* For URL, use the URL as string
* ``description`` - (Optional) The description of this object.
* ``device_id`` - (Optional) The ID of the device linked to this object.
* ``ip_addresses_id`` - (Optional) Array of ID of the IP addresses attached to this object.
* ``name`` - (Required) The name for this object.
* ``port`` - (Optional) The port of this object.
* ``protocol`` - (Required) The protocol of this object (tcp or udp).
* ``virtualmachine_id`` - (Optional) The ID of the vm linked to this object.

The ``tag`` block supports:
* ``name`` - (Required) Name of the existing tag to associate with this resource.
* ``slug`` - (Required) Slug of the existing tag to associate with this resource.

## Attributes Reference

In addition to the above arguments, the following attributes are exported:
* ``id`` - The id (ref in Netbox) of this object.
23 changes: 23 additions & 0 deletions examples/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,29 @@ resource "netbox_virtualization_vm" "vm_test" {
}
}

resource "netbox_ipam_service" "service_test" {
name = "SMTP"
virtualmachine_id = netbox_virtualization_vm.vm_test.id
ip_addresses_id = [netbox_ipam_ip_addresses.ip_test.id]
port = "22"
protocol = "tcp"
description = "Service created by terraform"

tag {
name = "tag1"
slug = "tag1"
}

custom_fields = {
cf_boolean = "true"
cf_date = "2020-12-25"
cf_integer = "10"
cf_selection = "1"
cf_text = "Some text"
cf_url = "https://github.com"
}
}

resource "netbox_virtualization_interface" "interface_test" {
name = "default"
virtualmachine_id = netbox_virtualization_vm.vm_test.id
Expand Down
1 change: 1 addition & 0 deletions netbox/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ func Provider() *schema.Provider {
"netbox_ipam_aggregate": resourceNetboxIpamAggregate(),
"netbox_ipam_ip_addresses": resourceNetboxIpamIPAddresses(),
"netbox_ipam_prefix": resourceNetboxIpamPrefix(),
"netbox_ipam_service": resourceNetboxIpamService(),
"netbox_ipam_vlan": resourceNetboxIpamVlan(),
"netbox_ipam_vlan_group": resourceNetboxIpamVlanGroup(),
"netbox_tenancy_tenant": resourceNetboxTenancyTenant(),
Expand Down
Loading

0 comments on commit 4e3d637

Please sign in to comment.