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

deliverables-2 #119

Merged
merged 5 commits into from
May 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 34 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,59 +1,59 @@
# Terraform Provider for Infoblox
<img width="171" alt="capture" src="https://user-images.githubusercontent.com/36291746/39614422-6b653088-4f8d-11e8-83fd-05b18ca974a2.PNG">

# Terraform Provider for Infoblox
Terraform provider plugin to integrate with Infoblox Network Identity Operating System [NIOS].

## Requirements
* [Terraform](https://www.terraform.io/downloads.html) 0.14.x
* [Go](https://golang.org/doc/install) 1.15.x or 1.16.x (to build the provider plugin)
* CNA License need to be installed on NIOS. If CNA is not installed then following default EA's should be added in NIOS side:
* VM Name :: String Type
* VM ID :: String Type
* Tenant ID :: String Type
* CMP Type :: String Type
* Cloud API Owned :: List Type (Values True, False)
* Network Name :: String Type
The latest version of Infoblox NIOS provider is [v1.1.1](https://github.com/infobloxopen/terraform-provider-infoblox/releases/tag/v1.1.1)

## Building the Provider

* Install and set apt environment variables [Golang](https://golang.org/doc/install) 1.16.x
* Clone the repo and build it
```sh
$ git clone https://github.com/infobloxopen/terraform-provider-infoblox
$ cd terraform-provider-infoblox
$ make build
```

## Using the Provider
If you're building the provider, follow the instructions to [install it as a plugin](https://www.terraform.io/docs/plugins/basics.html#installing-a-plugin). After the build is complete, copy the `terraform-provider-infoblox` binary into the same path as your terraform binary. After placing it into your plugins directory, run `terraform init` to initialize it.

## Developing the Provider
If you wish to work on the provider, you'll first need Go installed on your machine (version 1.15.x or 1.16.x is required).
If you wish to work on the provider, follow the above steps to build it.

To compile the provider, run the following steps:
```sh
$ make build
...
$ ./terraform-provider-infoblox
...
```
To test the provider, you can simply run `make test`.
To test the provider and to run the full suite of acceptance tests run below commands accordingly,
```sh
$ make test
```

In order to run the full suite of acceptance tests `make testacc`.
```sh
$ make testacc
```

## Using the Provider
* To use the plugin install v0.14.x [Terraform](https://www.terraform.io/downloads.html)
* If you're building the provider, follow the instructions to [install it as a plugin](https://www.terraform.io/docs/cli/config/config-file.html#development-overrides-for-provider-developers).
* Once the build is completed, set the `terraform-provider-infoblox` binary file location appropriately in in `dev_overrides`.

## NIOS Requirements
* Plugin can be used without a CNA license and does not mandate to specify any EAs.

* If Cloud Network Automation[CNA] License is installed on NIOS and has a Cloud Platform[CP] member attached. Make sure to have below mandatory EAs in .tf file if non mandatory cloud EAs(like "VM Name", "VM ID", "Network Name") are used.
* Tenant ID :: String Type
* CMP Type :: String Type
* Cloud API Owned :: List Type (Values True, False)

## Features of Provider
### Resource
Create, Update and Delete of below resources is supported along with comment and EAs fields.
* IPv4 & IPv6 Network Container
* IPv4 & IPv6 Network
* Allocation & Deallocation of IPv4 or IPv6 address.
* Association & Disassociation of IPv4 or IPv6 address for a VM.

Below resources are still under development and incomplete.
* Creation & Deletion of Network View in NIOS appliance
* Creation & Deletion of IPv4 Network with comment field in NIOS appliance
* Allocation & Deallocation of IPv4 address from an IPv4 Network
* Association & Disassociation of IPv4 Address for a VM
* Creation and Deletion of A, CNAME, Host, and PTR records

### Data Source
* Supports Data Source for IPv4 Network
* Support Data Source for A and CNAME records
Data Sources for below records are supported.
* IPv4 Network
* A Record
* CNAME Record

## Disclaimer
To use the provider for DNS purposes, a parent (i.e. zone) must already exist. The plugin does not support the creation of zones.
while running acceptance tests create a 10.0.0.0/24 network under default network view and create a reservation for 10.0.0.2 IP
While running acceptance tests create a 10.0.0.0/24 network under default network view and create a reservation for 10.0.0.2 IP
3 changes: 3 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

* The Terraform configuration files under `v0.14` path are written and tested on Terraform v0.14 version and are actively maintained.
* The terraform configuration files under `archived` directory are of older version and are not maintained actively.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
57 changes: 57 additions & 0 deletions examples/v0.14/AWS/AllocationAndAssociation/aws.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Region being used to create the resources
provider "aws" {
region = "us-west-1"
}

# Create a Virtual Private Cloud
resource "aws_vpc" "vpc" {
cidr_block = "10.0.0.0/16"
# Allocates /56 IPv6 CIDR block From Amazon Global Unicast Address to VPC
assign_generated_ipv6_cidr_block = true
tags = {
Name = "tf-vpc"
}
}

# Create a Subnet
resource "aws_subnet" "subnet" {
vpc_id = aws_vpc.vpc.id
cidr_block = infoblox_ipv4_network.ipv4_network.cidr
ipv6_cidr_block = infoblox_ipv6_network.ipv6_network.cidr
availability_zone = "us-west-1a"
assign_ipv6_address_on_creation = false
map_public_ip_on_launch = false

tags = {
Name = "tf-subnet"
Subnet = "tf-subnet"
}
}


#Create Network Interface
resource "aws_network_interface" "ni" {
subnet_id = aws_subnet.subnet.id
private_ips = [infoblox_ipv4_allocation.ipv4_allocation.ip_addr]
ipv6_addresses = [infoblox_ipv6_allocation.ipv6_allocation.ip_addr]

tags = {
Name = "tf-ni"
}
}

# Create AWS Instance
resource "aws_instance" "ec2-instance" {
# This ami is for us-west-1, change to Amazon Linux AMI for your region
ami = "ami-03130878b60947df3"
instance_type = "t2.micro"

network_interface {
network_interface_id = aws_network_interface.ni.id
device_index = 0
}

tags = {
Name = "tf-ec2-instance"
}
}
167 changes: 167 additions & 0 deletions examples/v0.14/AWS/AllocationAndAssociation/infoblox.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
terraform {
# Required providers block for Terraform v0.14.7
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.0"
}
infoblox = {
source = "terraform-providers/infoblox"
version = ">= 1.0"
}
}
}

# Create a network container in Infoblox Grid
resource "infoblox_ipv4_network_container" "IPv4_nw_c" {
network_view_name="default"

cidr = aws_vpc.vpc.cidr_block
comment = "tf IPv4 network container"
extensible_attributes = jsonencode({
"Tenant ID" = "tf-plugin"
Location = "Test loc."
Site = "Test site"
})
}

resource "infoblox_ipv6_network_container" "IPv6_nw_c" {
network_view_name="default"

cidr = aws_vpc.vpc.ipv6_cidr_block
comment = "tf IPv6 network container"
extensible_attributes = jsonencode({
"Tenant ID" = "tf-plugin"
Location = "Test loc."
Site = "Test site"
})
}


# Allocate a network in Infoblox Grid under provided parent CIDR
resource "infoblox_ipv4_network" "ipv4_network"{
network_view_name = "default"

parent_cidr = infoblox_ipv4_network_container.IPv4_nw_c.cidr
allocate_prefix_len = 24
reserve_ip = 2

comment = "tf IPv4 network"
extensible_attributes = jsonencode({
"Tenant ID" = "tf-plugin"
"Network Name" = "ipv4-tf-network"
Location = "Test loc."
Site = "Test site"
})
}

resource "infoblox_ipv6_network" "ipv6_network"{
network_view_name = "default"

parent_cidr = infoblox_ipv6_network_container.IPv6_nw_c.cidr
allocate_prefix_len = 64
reserve_ipv6 = 3

comment = "tf IPv6 network"
extensible_attributes = jsonencode({
"Tenant ID" = "tf-plugin"
"Network Name" = "ipv6-tf-network"
Location = "Test loc."
Site = "Test site"
})
}


# Allocate IP from network
resource "infoblox_ipv4_allocation" "ipv4_allocation"{
network_view_name= "default"
cidr = infoblox_ipv4_network.ipv4_network.cidr
host_name = "test"

#Create Host Record with DNS and DHCP flags
#dns_view="default"
#zone="aws.com"
#enable_dns = "false"
#enable_dhcp = "false"

comment = "tf IPv4 allocation"
extensible_attributes = jsonencode({
"Tenant ID" = "tf-plugin"
"Network Name" = "ipv4-tf-network"
"VM Name" = "tf-ec2-instance"
Location = "Test loc."
Site = "Test site"
})
}

resource "infoblox_ipv6_allocation" "ipv6_allocation" {
network_view_name= "default"
cidr = infoblox_ipv6_network.ipv6_network.cidr
duid = "00:00:00:00:00:00:00:00"
host_name = "test"

#Create Host Record with DNS and DHCP flags
#dns_view="default"
#zone="aws.com"
#enable_dns = "false"
#enable_dhcp = "false"

comment = "tf IPv6 allocation"
extensible_attributes = jsonencode({
"Tenant ID" = "tf-plugin"
"Network Name" = "ipv6-tf-network"
"VM Name" = "tf-ec2-instance-ipv6"
Location = "Test loc."
Site = "Test site"
})
}


# Update Grid with VM data
resource "infoblox_ipv4_association" "ipv4_associate"{
network_view_name = "default"
cidr = infoblox_ipv4_network.ipv4_network.cidr
ip_addr = infoblox_ipv4_allocation.ipv4_allocation.ip_addr
mac_addr = aws_network_interface.ni.mac_address
host_name = "test"

#Create Host Record with DNS and DHCP flags
#dns_view="default"
#zone="aws.com"
#enable_dns = "false"
#enable_dhcp = "false"

comment = "tf IPv4 Association"
extensible_attributes = jsonencode({
"Tenant ID" = "tf-plugin"
"Network Name" = "ipv6-tf-network"
"VM Name" = "tf-ec2-instance"
"VM ID" = aws_instance.ec2-instance.id
Location = "Test loc."
Site = "Test site"
})
}

resource "infoblox_ipv6_association" "ipv6_associate"{
network_view_name = "default"
cidr = infoblox_ipv6_network.ipv6_network.cidr
ip_addr = infoblox_ipv6_allocation.ipv6_allocation.ip_addr
duid = aws_network_interface.ni.mac_address
host_name = "test"

#Create Host Record with DNS and DHCP flags
#dns_view="default"
#zone="aws.com"
#enable_dns = "false"
#enable_dhcp = "false"

comment = "tf IPv6 Association"
extensible_attributes = jsonencode({
"Tenant ID" = "tf-plugin"
"Network Name" = "ipv6-tf-network"
"VM Name" = "tf-ec2-instance-ipv6"
"VM ID" = aws_instance.ec2-instance.id
Location = "Test loc."
Site = "Test site"
})
}
29 changes: 29 additions & 0 deletions examples/v0.14/AWS/Network/aws.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Region being used to create the resources
provider "aws" {
region = "us-west-1"
}

# Create a Virtual Private Cloud
resource "aws_vpc" "vpc" {
cidr_block = "10.0.0.0/16"
# Allocates /56 IPv6 CIDR block From Amazon Global Unicast Address to VPC
assign_generated_ipv6_cidr_block = true
tags = {
Name = "tf-vpc"
}
}

# Create a Subnet
resource "aws_subnet" "subnet" {
vpc_id = aws_vpc.vpc.id
cidr_block = infoblox_ipv4_network.ipv4_network.cidr
ipv6_cidr_block = infoblox_ipv6_network.ipv6_network.cidr
availability_zone = "us-west-1a"
assign_ipv6_address_on_creation = false
map_public_ip_on_launch = false

tags = {
Name = "tf-subnet"
Subnet = "tf-subnet"
}
}
Loading