Skip to content

Commit

Permalink
Velocloud module - added var.ami_id (#67)
Browse files Browse the repository at this point in the history
* added var.ami_id and rearranged default values

* Continuous Integration - terraform fmt and terraform-docs

* updated examples to include a custom ami_id

* fixing mistake variable back to null

* Continuous Integration - terraform fmt and terraform-docs

* removed sg group examples
  • Loading branch information
zachreborn authored Nov 1, 2024
1 parent df468f8 commit bc7ff4c
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 40 deletions.
59 changes: 42 additions & 17 deletions modules/aws/vendor/velocloud/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,25 +62,49 @@

<!-- USAGE EXAMPLES -->
## Usage
### Simple Example
This example creates a VeloCloud vEdge instance in the VPC of your choosing. The instance will have a NIC in up to three subnets: public, private, and management. The public subnet will have an EIP attached to it. The instance will be assigned a keypair and the VeloCloud activation key will be provided. The VeloCloud orchestrator is required to be provided as well.
```
module "aws_prod_sdwan" {
source = "github.com/zachreborn/terraform-modules//modules/aws/vendor/velocloud"
key_name = module.keypair.key_name
number = 1
public_subnet_ids = module.vpc.public_subnet_ids
private_subnet_ids = module.vpc.private_subnet_ids
velocloud_activation_key = "1234-5678-90AB-CDEF"
velocloud_orchestrator = "vco.example.com"
velocloud_ignore_cert_errors = true
velocloud_lan_cidr_blocks = ["0.0.0.0/0"]
vpc_id = module.vpc.vpc_id
tags = {
terraform = "true"
created_by = "Zachary Hill"
environment = "prod"
project = "aws_poc"
backup = "true"
role = "sdwan"
}
}
```

### Custom AMI Example
This example creates a VeloCloud vEdge instance in the VPC of your choosing. The instance will have a NIC in up to three subnets: public, private, and management. The public subnet will have an EIP attached to it. The instance will be assigned a keypair and the VeloCloud activation key will be provided. The VeloCloud orchestrator is required to be provided as well. The AMI ID is provided to use a custom AMI.
```
module "aws_prod_sdwan" {
source = "github.com/zachreborn/terraform-modules//modules/aws/vendor/velocloud"
availability_zone = [module.vpc.availability_zone[0]]
velocloud_lan_cidr_blocks = ["10.11.0.0/16"]
key_name = module.keypair.key_name
instance_type = "c5.xlarge"
mgmt_subnet_ids = module.vpc.mgmt_subnet_ids
public_subnet_ids = module.vpc.public_subnet_ids
private_subnet_ids = module.vpc.private_subnet_ids
mgmt_ips = ["10.200.61.12"]
public_ips = ["10.200.201.12"]
private_ips = ["10.200.1.12"]
vpc_id = module.vpc.vpc_id
velocloud_activation_key = "1234-5678-90AB-CDEF"
velocloud_orchestrator = "vco.example.com"
tags = {
ami_id = "ami-1234567890"
key_name = module.keypair.key_name
number = 1
public_subnet_ids = module.vpc.public_subnet_ids
private_subnet_ids = module.vpc.private_subnet_ids
velocloud_activation_key = "1234-5678-90AB-CDEF"
velocloud_orchestrator = "vco.example.com"
velocloud_ignore_cert_errors = true
velocloud_lan_cidr_blocks = ["0.0.0.0/0"]
vpc_id = module.vpc.vpc_id
tags = {
terraform = "true"
created_by = "Zachary Hill"
environment = "prod"
Expand Down Expand Up @@ -136,6 +160,7 @@ No modules.

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_ami_id"></a> [ami\_id](#input\_ami\_id) | (Optional) The ID of the AMI to use for the instance. If this is not set, the AMI ID will be automated selected based on the `velocloud_version` defined. | `string` | `null` | no |
| <a name="input_ebs_optimized"></a> [ebs\_optimized](#input\_ebs\_optimized) | (Optional) If true, the launched EC2 instance will be EBS-optimized. Note that if this is not set on an instance type that is optimized by default then this will show as disabled but if the instance type is optimized by default then there is no need to set this and there is no effect to disabling it. See the EBS Optimized section of the AWS User Guide for more information. | `bool` | `true` | no |
| <a name="input_hibernation"></a> [hibernation](#input\_hibernation) | (Optional) If true, the launched EC2 instance will support hibernation. (Available since v0.6.0) | `bool` | `null` | no |
| <a name="input_http_endpoint"></a> [http\_endpoint](#input\_http\_endpoint) | (Optional) Whether the metadata service is available. Valid values include enabled or disabled. Defaults to enabled. | `string` | `"enabled"` | no |
Expand All @@ -146,14 +171,14 @@ No modules.
| <a name="input_key_name"></a> [key\_name](#input\_key\_name) | (Optional) Key name of the Key Pair to use for the instance; which can be managed using the aws\_key\_pair resource. Defaults to null. | `string` | `null` | no |
| <a name="input_lan_sg_name"></a> [lan\_sg\_name](#input\_lan\_sg\_name) | (Optional, Forces new resource) Name of the security group. If omitted, Terraform will assign a random, unique name. | `string` | `"velocloud_lan_sg"` | no |
| <a name="input_mgmt_ips"></a> [mgmt\_ips](#input\_mgmt\_ips) | (Optional) List of private IPs to assign to the ENI. | `list(string)` | `null` | no |
| <a name="input_mgmt_nic_description"></a> [mgmt\_nic\_description](#input\_mgmt\_nic\_description) | (Optional) Description for the network interface. | `string` | `"SDWAN mgmt nic"` | no |
| <a name="input_mgmt_nic_description"></a> [mgmt\_nic\_description](#input\_mgmt\_nic\_description) | (Optional) Description for the network interface. | `string` | `"SDWAN mgmt nic Ge1 in VeloCloud"` | no |
| <a name="input_monitoring"></a> [monitoring](#input\_monitoring) | (Optional) If true, the launched EC2 instance will have detailed monitoring enabled. (Available since v0.6.0) | `bool` | `true` | no |
| <a name="input_number"></a> [number](#input\_number) | (Optional) Quantity of resources to make with this module. Example: Setting this to 2 will create 2 of all the required resources. Default: 1 | `number` | `1` | no |
| <a name="input_private_ips"></a> [private\_ips](#input\_private\_ips) | (Optional) List of private IPs to assign to the ENI. | `list(string)` | `null` | no |
| <a name="input_private_nic_description"></a> [private\_nic\_description](#input\_private\_nic\_description) | (Optional) Description for the network interface. | `string` | `"SDWAN private nic"` | no |
| <a name="input_private_nic_description"></a> [private\_nic\_description](#input\_private\_nic\_description) | (Optional) Description for the network interface. | `string` | `"SDWAN private nic Ge3 in VeloCloud"` | no |
| <a name="input_private_subnet_ids"></a> [private\_subnet\_ids](#input\_private\_subnet\_ids) | (Required) Subnet IDs to create the ENI in. | `list(string)` | n/a | yes |
| <a name="input_public_ips"></a> [public\_ips](#input\_public\_ips) | (Optional) Private IP addresses to associate with the instance in a VPC. | `list(string)` | `null` | no |
| <a name="input_public_nic_description"></a> [public\_nic\_description](#input\_public\_nic\_description) | (Optional) Description for the network interface. | `string` | `"SDWAN public nic"` | no |
| <a name="input_public_nic_description"></a> [public\_nic\_description](#input\_public\_nic\_description) | (Optional) Description for the network interface. | `string` | `"SDWAN public nic Ge2 in VeloCloud"` | no |
| <a name="input_public_subnet_ids"></a> [public\_subnet\_ids](#input\_public\_subnet\_ids) | (Required) Subnet IDs to create the ENI in. | `list(string)` | n/a | yes |
| <a name="input_root_ebs_volume_encrypted"></a> [root\_ebs\_volume\_encrypted](#input\_root\_ebs\_volume\_encrypted) | (Optional) Whether to enable volume encryption on the root ebs volume. Defaults to true. Must be configured to perform drift detection. | `bool` | `true` | no |
| <a name="input_root_volume_size"></a> [root\_volume\_size](#input\_root\_volume\_size) | (Optional) Size of the root volume in gibibytes (GiB). | `number` | `8` | no |
Expand Down
3 changes: 1 addition & 2 deletions modules/aws/vendor/velocloud/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,7 @@ resource "aws_network_interface" "private_nic" {
############################################

resource "aws_instance" "ec2_instance" {

ami = data.aws_ami.velocloud.id
ami = var.ami_id != null ? var.ami_id : data.aws_ami.velocloud.id
count = var.number
ebs_optimized = var.ebs_optimized
hibernation = var.hibernation
Expand Down
48 changes: 27 additions & 21 deletions modules/aws/vendor/velocloud/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

variable "velocloud_version" {
description = "(Optional) The version ID of the VeloCloud VCE AMI to use. Defaults to the latest version. Use semantic versioning to specify a version. Example: 4.5"
default = "4.5"
type = string
default = "4.5"
}

############################################
Expand All @@ -20,20 +20,20 @@ variable "lan_sg_name" {

variable "snmp_mgmt_access_cidr_blocks" {
description = "(Optional) List of CIDR blocks allowed to SNMP into the VeloCloud instance."
default = []
type = list(string)
default = []
}

variable "ssh_mgmt_access_cidr_blocks" {
description = "(Optional) List of CIDR blocks allowed to SSH into the VeloCloud instance."
default = []
type = list(string)
default = []
}

variable "wan_mgmt_sg_name" {
description = "(Optional, Forces new resource) Name of the security group. If omitted, Terraform will assign a random, unique name."
default = "velocloud_wan_mgmt_sg"
type = string
default = "velocloud_wan_mgmt_sg"
}

variable "velocloud_lan_cidr_blocks" {
Expand All @@ -53,20 +53,20 @@ variable "vpc_id" {

variable "mgmt_nic_description" {
description = "(Optional) Description for the network interface."
default = "SDWAN mgmt nic"
type = string
default = "SDWAN mgmt nic Ge1 in VeloCloud"
}

variable "mgmt_ips" {
description = "(Optional) List of private IPs to assign to the ENI."
default = null
type = list(string)
default = null
}

variable "public_nic_description" {
description = "(Optional) Description for the network interface."
default = "SDWAN public nic"
type = string
default = "SDWAN public nic Ge2 in VeloCloud"
}

variable "public_subnet_ids" {
Expand All @@ -76,8 +76,8 @@ variable "public_subnet_ids" {

variable "public_ips" {
description = "(Optional) Private IP addresses to associate with the instance in a VPC."
default = null
type = list(string)
default = null
}

variable "private_subnet_ids" {
Expand All @@ -87,36 +87,42 @@ variable "private_subnet_ids" {

variable "private_nic_description" {
description = "(Optional) Description for the network interface."
default = "SDWAN private nic"
type = string
default = "SDWAN private nic Ge3 in VeloCloud"
}

variable "private_ips" {
description = "(Optional) List of private IPs to assign to the ENI."
default = null
type = list(string)
default = null
}

variable "source_dest_check" {
description = "(Optional) Whether to enable source destination checking for the ENI. Default false."
default = false
type = bool
default = false
}

############################################
# EC2 Instance
############################################

variable "ami_id" {
description = "(Optional) The ID of the AMI to use for the instance. If this is not set, the AMI ID will be automated selected based on the `velocloud_version` defined."
type = string
default = null
}

variable "ebs_optimized" {
description = "(Optional) If true, the launched EC2 instance will be EBS-optimized. Note that if this is not set on an instance type that is optimized by default then this will show as disabled but if the instance type is optimized by default then there is no need to set this and there is no effect to disabling it. See the EBS Optimized section of the AWS User Guide for more information."
default = true
type = bool
default = true
}

variable "monitoring" {
description = "(Optional) If true, the launched EC2 instance will have detailed monitoring enabled. (Available since v0.6.0)"
default = true
type = bool
default = true
}

variable "hibernation" {
Expand Down Expand Up @@ -147,8 +153,8 @@ variable "http_tokens" {

variable "instance_type" {
description = "(Optional) Instance type to use for the instance. Updates to this field will trigger a stop/start of the EC2 instance."
default = "c5.xlarge"
type = string
default = "c5.xlarge"
}

variable "key_name" {
Expand All @@ -159,20 +165,20 @@ variable "key_name" {

variable "iam_instance_profile" {
description = "(Optional) IAM Instance Profile to launch the instance with. Specified as the name of the Instance Profile. Ensure your credentials have the correct permission to assign the instance profile according to the EC2 documentation, notably iam:PassRole."
default = null
type = string
default = null
}

variable "instance_name_prefix" {
description = "(Optional) Used to populate the Name tag."
default = "aws_prod_sdwan"
type = string
default = "aws_prod_sdwan"
}

variable "root_volume_type" {
description = "(Optional) Type of volume. Valid values include standard, gp2, gp3, io1, io2, sc1, or st1. Defaults to gp3"
default = "gp3"
type = string
default = "gp3"
}

variable "root_volume_size" {
Expand All @@ -183,8 +189,8 @@ variable "root_volume_size" {

variable "root_ebs_volume_encrypted" {
description = "(Optional) Whether to enable volume encryption on the root ebs volume. Defaults to true. Must be configured to perform drift detection."
default = true
type = bool
default = true
}

variable "velocloud_activation_key" {
Expand All @@ -198,8 +204,8 @@ variable "velocloud_activation_key" {

variable "velocloud_ignore_cert_errors" {
description = "(Optional) Whether or not to ignore certificate errors when connecting to the VeloCloud orchestrator. Set to true if using private or self-signed certificates on the orchestrator. Defaults to false."
default = false
type = bool
default = false
}

variable "velocloud_orchestrator" {
Expand All @@ -219,17 +225,17 @@ variable "user_data" {

variable "tags" {
description = "(Optional) Map of tags to assign to the device."
type = map(any)
default = {
created_by = "terraform"
terraform = "true"
environment = "prod"
role = "sdwan"
}
type = map(any)
}

variable "number" {
description = "(Optional) Quantity of resources to make with this module. Example: Setting this to 2 will create 2 of all the required resources. Default: 1"
default = 1
type = number
default = 1
}

0 comments on commit bc7ff4c

Please sign in to comment.