This repository has been archived by the owner on Aug 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2b2a94e
commit 0c81ef5
Showing
10 changed files
with
576 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Instance Template Example | ||
|
||
This example illustrates how to use the `instance-template` module. | ||
|
||
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> | ||
|
||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|-----------------------------------|-------------------------------------------------------|--------|---------|----------| | ||
| resource\_group | Name of the resource group | string | default | no | | ||
| name | Name of the Instance Template | string | n/a | yes | | ||
| vpc | Name of the VPC | string | n/a | yes | | ||
| location | Zone of the subnet | string | n/a | yes | | ||
| image | Image ID for the Instance Template | string | n/a | yes | | ||
| profile | Profile type for the Instance Template | string | n/a | yes | | ||
| ssh\_keys | List of ssh key IDs to the Instance Template | list(string) | n/a | yes | | ||
| primary\_network\_interface | List of primary_network_interface that are to be attached to the Instance Template | list(object) | n/a | yes | | ||
| resource\_group\_id | ID of the resource group | string | n/a | no | | ||
| user\_data | User Data for the Instance Template | string | n/a | no | | ||
| boot\_volume | List of boot volume that are to be attached to the Instance Template| list(object) | n/a | no | | ||
| network\_interfaces | List of network_interfaces that are to be attached to the Instance Template | list(object) | n/a | no | | ||
| data\_volumes | List of volume ids that are to be attached to the Instance Template | list(string) | n/a | no | | ||
| tags | List of tags to attach | list(string) | n/a | no | | ||
| dedicated\_host | Unique Identifier of the Dedicated Host where the instance will be placed | string | n/a | no | | ||
| dedicated\_host\_group | Unique Identifier of the Dedicated Host Group where the instance will be placed | string | n/a | no | | ||
|
||
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> | ||
|
||
NOTE: We can configure the list of primary_network_interface, network_interfaces, boot_volume, tags, ssh_keys, data_volumes to be attached to the instance by entering respective details in input.tfvars. | ||
|
||
## Usage | ||
|
||
terraform apply -var-file="input.tfvars" | ||
|
||
## Note | ||
|
||
For all optional fields, default values (Eg: `null`) are given in varaible.tf file. User can configure the same by overwriting with appropriate values. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
######################################################## | ||
# Instance Template configuration | ||
# Copyright 2020 IBM | ||
######################################################## | ||
|
||
/**************************************************** | ||
Example Usage | ||
//mandatory variables | ||
primary_network_interface = [{ | ||
allow_ip_spoofing = false | ||
subnet = "0737-7a911fcf-737d-4a85-b3b1-0184c6939eb6" | ||
interface_name = "" | ||
primary_ipv4_address = "" | ||
security_groups = ["r006-3c175148-9e94-4300-aa2d-f0a8aca1a9a4"] | ||
}, | ||
] | ||
ssh_keys = ["r006-61f07322-ec1d-4e8d-97d8-3002d46e9d0d"] | ||
// optional variables | ||
network_interfaces = [{ | ||
allow_ip_spoofing = false | ||
subnet = "0727-6d96ba0c-e0da-434d-84ef-b57f0dc1ebff" | ||
interface_name = "" | ||
primary_ipv4_address = "" | ||
security_groups = [] | ||
}, | ||
] | ||
boot_volume = [{ | ||
name = "bootvol1" | ||
encryption = "crn:v1:bluemix:public:kms:us-south:a/a178d11ec2f24159bb21acc368e57cea:24a825b6-697c-4081-bcd7-32632de7a73d:key:58746ed1-22e9-4831-9259-ca40aa885615" | ||
}, | ||
] | ||
tags = ["T1","T2"] | ||
volumes_attachments = [{ | ||
name = "vol_att1" | ||
volume = string | ||
encryption = string | ||
delete_volume_on_instance_delete = true | ||
volume_prototype = list(object({ | ||
profile = string | ||
capacity = number | ||
iops = number | ||
encryption_key = string | ||
}, | ||
] | ||
******************************************************/ | ||
|
||
|
||
primary_network_interface = [{ | ||
allow_ip_spoofing = false | ||
subnet = "<subnet_id>" | ||
interface_name = "<primary_network_interface name>" | ||
security_groups = ["<security_group_id>"] | ||
primary_ipv4_address = "<primary_ipv4_address>" | ||
}, | ||
] | ||
|
||
ssh_keys = ["<sshKeyID>"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
##################################################### | ||
# Instance Template Configuration Example | ||
# Copyright 2020 IBM | ||
##################################################### | ||
|
||
provider "ibm" { | ||
} | ||
|
||
data "ibm_is_vpc" "vpc" { | ||
name = var.vpc | ||
} | ||
|
||
data "ibm_resource_group" "resource_group" { | ||
name = (var.resource_group != null ? var.resource_group : "default") | ||
} | ||
|
||
module "instance-template" { | ||
source = "terraform-ibm-modules/vpc/ibm//modules/instance-template" | ||
|
||
name = var.name | ||
vpc_id = data.ibm_is_vpc.vpc.id | ||
resource_group_id = data.ibm_resource_group.resource_group.id | ||
location = var.location | ||
image = var.image | ||
profile = var.profile | ||
ssh_keys = var.ssh_keys | ||
primary_network_interface = var.primary_network_interface | ||
user_data = var.user_data | ||
boot_volume = var.boot_volume | ||
network_interfaces = var.network_interfaces | ||
volume_attachments = var.volume_attachments | ||
dedicated_host = var.dedicated_host | ||
dedicated_host_group = var.dedicated_host_group | ||
tags = var.tags | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
##################################################### | ||
# Instance Template Configuration Parameters | ||
# Copyright 2020 IBM | ||
##################################################### | ||
|
||
variable "name" { | ||
description = "Name of the Instance Template" | ||
type = string | ||
} | ||
|
||
variable "vpc" { | ||
description = "VPC name" | ||
type = string | ||
} | ||
|
||
variable "location" { | ||
description = "Instance Template zone" | ||
type = string | ||
} | ||
|
||
variable "image" { | ||
description = "Image ID for the Instance Template" | ||
type = string | ||
} | ||
|
||
variable "profile" { | ||
description = "Profile type for the Instance Template" | ||
type = string | ||
} | ||
|
||
variable "ssh_keys" { | ||
description = "List of ssh key IDs to the Instance Template" | ||
type = list(string) | ||
} | ||
|
||
variable "primary_network_interface" { | ||
description = "List of primary_network_interface that are to be attached to the Instance Template" | ||
type = list(object({ | ||
|
||
subnet = string | ||
interface_name = string | ||
security_groups = list(string) | ||
primary_ipv4_address = string | ||
allow_ip_spoofing = bool | ||
})) | ||
} | ||
|
||
##################################################### | ||
# Optional Parameters | ||
##################################################### | ||
|
||
variable "resource_group" { | ||
description = "Resource group name" | ||
type = string | ||
default = null | ||
} | ||
|
||
variable "user_data" { | ||
description = "User Data for the Instance Template" | ||
type = string | ||
default = null | ||
} | ||
|
||
variable "volume_attachments" { | ||
description = "List of volume Attachments that are to be attached to the instance Template" | ||
type = list(object({ | ||
name = string | ||
volume = string | ||
encryption = string | ||
delete_volume_on_instance_delete = bool | ||
volume_prototype = list(object({ | ||
profile = string | ||
capacity = number | ||
iops = number | ||
encryption_key = string | ||
})) | ||
})) | ||
default = null | ||
} | ||
|
||
|
||
variable "tags" { | ||
description = "List of Tags for the vpc" | ||
type = list(string) | ||
default = null | ||
} | ||
|
||
variable "network_interfaces" { | ||
description = "List of network_interfaces that are to be attached to the Instance Template" | ||
type = list(object({ | ||
subnet = string | ||
interface_name = string | ||
security_groups = list(string) | ||
primary_ipv4_address = string | ||
allow_ip_spoofing = bool | ||
})) | ||
default = null | ||
} | ||
|
||
variable "boot_volume" { | ||
description = "List of boot volume that are to be attached to the Instance Template" | ||
type = list(object({ | ||
name = string | ||
encryption = string | ||
})) | ||
default = null | ||
} | ||
|
||
variable "dedicated_host" { | ||
description = "Unique Identifier of the Dedicated Host where the instance will be placed" | ||
type = string | ||
default = null | ||
} | ||
|
||
variable "dedicated_host_group" { | ||
description = "Unique Identifier of the Dedicated Host Group where the instance will be placed" | ||
type = string | ||
default = null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
##################################################### | ||
# Instance Template provider version configuration | ||
# Copyright 2020 IBM | ||
##################################################### | ||
|
||
/*************************************************** | ||
NOTE: To source a particular version of IBM terraform provider, configure the parameter `version` as follows | ||
terraform { | ||
required_version = ">=0.13" | ||
required_providers { | ||
ibm = { | ||
source = "IBM-Cloud/ibm" | ||
version = "1.21.0" | ||
} | ||
} | ||
} | ||
If we dont configure the version parameter, it fetches the latest provider version. | ||
****************************************************/ | ||
|
||
terraform { | ||
required_version = ">=0.13" | ||
required_providers { | ||
ibm = { | ||
source = "IBM-Cloud/ibm" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Instance Template Module Example | ||
|
||
This module is used to create an Instance Template | ||
|
||
## Example Usage | ||
``` | ||
data "ibm_is_vpc" "vpc" { | ||
name = var.vpc | ||
} | ||
data "ibm_resource_group" "resource_group" { | ||
name = (var.resource_group != null ? var.resource_group : "default") | ||
} | ||
module "instance" { | ||
source = "terraform-ibm-modules/vpc/ibm//modules/instance-template" | ||
name = var.name | ||
vpc_id = data.ibm_is_vpc.vpc.id | ||
resource_group_id = data.ibm_resource_group.resource_group.id | ||
location = var.location | ||
image = var.image | ||
profile = var.profile | ||
ssh_keys = var.ssh_keys | ||
primary_network_interface = var.primary_network_interface | ||
user_data = var.user_data | ||
boot_volume = var.boot_volume | ||
network_interfaces = var.network_interfaces | ||
volume_attachments = var.volume_attachments | ||
dedicated_host = var.dedicated_host | ||
dedicated_host_group = var.dedicated_host_group | ||
tags = var.tags | ||
} | ||
``` | ||
|
||
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> | ||
|
||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|-----------------------------------|-------------------------------------------------------|--------|---------|----------| | ||
| name | Name of the Instance Template | string | n/a | yes | | ||
| vpc | Name of the VPC | string | n/a | yes | | ||
| location | Zone of the subnet | string | n/a | yes | | ||
| image | Image ID for the Instance Template | string | n/a | yes | | ||
| profile | Profile type for the Instance Template | string | n/a | yes | | ||
| ssh\_keys | List of ssh key IDs to the Instance Template | list(string) | n/a | yes | | ||
| primary\_network\_interface | List of primary_network_interface that are to be attached to the Instance Template | list(object) | n/a | yes | | ||
| resource\_group\_id | ID of the resource group | string | n/a | no | | ||
| user\_data | User Data for the Instance Template | string | n/a | no | | ||
| boot\_volume | List of boot volume that are to be attached to the Instance Template| list(object) | n/a | no | | ||
| network\_interfaces | List of network_interfaces that are to be attached to the Instance Template | list(object) | n/a | no | | ||
| data\_volumes | List of volume ids that are to be attached to the Instance Template | list(string) | n/a | no | | ||
| tags | List of tags to attach | list(string) | n/a | no | | ||
| dedicated\_host | Unique Identifier of the Dedicated Host where the instance will be placed | string | n/a | no | | ||
| dedicated\_host\_group | Unique Identifier of the Dedicated Host Group where the instance will be placed | string | n/a | no | | ||
|
||
## Outputs | ||
|
||
| Name | Description | | ||
|------|-------------| | ||
| Instance\_template_\_id | The ID of the Instance Template | | ||
| primary\_network\_interfaces | The primary_network_interface IDs of the Instance Template | | ||
|
||
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
Oops, something went wrong.