-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathvariables.tf
More file actions
133 lines (113 loc) · 5.75 KB
/
variables.tf
File metadata and controls
133 lines (113 loc) · 5.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
########################################################################################################################
# Input variables
########################################################################################################################
variable "ibmcloud_api_key" {
type = string
description = "The IBM Cloud API key used to provision resources."
sensitive = true
}
variable "existing_resource_group_name" {
type = string
description = "The name of an existing resource group to provision the resources. [Learn more](https://cloud.ibm.com/docs/account?topic=account-rgs&interface=ui#create_rgs) about how to create a resource group."
default = "Default"
}
variable "prefix" {
type = string
description = "The prefix to add to all resources that this solution creates (e.g `prod`, `test`, `dev`). To skip using a prefix, set this value to null or an empty string. [Learn more](https://terraform-ibm-modules.github.io/documentation/#/prefix.md). **Important:** Updating the prefix after the initial deployment may require recreating certain resources. Learn more about this limitation [here](https://cloud.ibm.com/docs/secure-infrastructure-vpc?topic=secure-infrastructure-vpc-known-issues#ki-vpc-prefix-change-recreate)."
nullable = true
validation {
condition = var.prefix == null || var.prefix == "" ? true : alltrue([
can(regex("^[a-z][-a-z0-9]*[a-z0-9]$", var.prefix)), length(regexall("--", var.prefix)) == 0
])
error_message = "Prefix must begin with a lowercase letter and may contain only lowercase letters, digits, and hyphens '-'. It must not end with a hyphen('-'), and cannot contain consecutive hyphens ('--')."
}
validation {
condition = var.prefix == null || var.prefix == "" ? true : length(var.prefix) <= 16
error_message = "Prefix must not exceed 16 characters."
}
}
variable "existing_vpc_crn" {
description = "The CRN of an existing VPC. VSI will be provisioned in the first subnet of the VPC."
type = string
default = null
validation {
condition = anytrue([
can(regex("^crn:v\\d:(.*:){2}is:(.*:)([aos]\\/[\\w_\\-]+)::vpc:[0-9a-z]{4}-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", var.existing_vpc_crn)),
var.existing_vpc_crn == null,
])
error_message = "The value provided for 'existing_vpc_crn' is not valid."
}
}
variable "vpc_region" {
type = string
description = "Region in which VPC will be deployed. [Learn More](https://terraform-ibm-modules.github.io/documentation/#/region)."
default = "us-south"
}
variable "provider_visibility" {
description = "Set the visibility value for the IBM terraform provider. [Learn more](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/guides/custom-service-endpoints)."
type = string
default = "private"
validation {
condition = contains(["public", "private", "public-and-private"], var.provider_visibility)
error_message = "Invalid value for 'provider_visibility'. Allowed values are 'public', 'private', or 'public-and-private'."
}
}
variable "resource_tags" {
description = "The list of tags to add to the Virtual server instance."
type = list(string)
default = []
}
variable "access_tags" {
type = list(string)
description = "The list of access tags to add to the Virtual server instance. For more information, see https://cloud.ibm.com/docs/account?topic=account-access-tags-tutorial."
default = []
}
##############################################################################
# Virtual server instance Variables
##############################################################################
variable "vsi_name" {
description = "The name of the Virtual server instance."
type = string
default = "qs-vsi"
}
variable "image_name" {
description = "Image ID used for Virtual server instance. [Learn more](https://cloud.ibm.com/docs/vpc?topic=vpc-about-images)"
type = string
default = "ibm-ubuntu-24-04-4-minimal-amd64-2"
}
variable "size" {
type = string
description = "The Virtual server instance machine size. [Learn more](https://github.com/terraform-ibm-modules/terraform-ibm-landing-zone-vsi/tree/main/solutions/quickstart/DA_docs.md)."
default = "mini"
}
variable "user_data" {
description = "The user data that automatically performs common configuration tasks or runs scripts. When using the user_data variable in your configuration, it's essential to provide the content in the correct format for it to be properly recognized by the terraform. Use <<-EOT and EOT to enclose your user_data content to ensure it's passed as multi-line string. [Learn more](https://cloud.ibm.com/docs/secure-infrastructure-vpc?topic=secure-infrastructure-vpc-user-data)"
type = string
default = <<-EOT
#!/bin/bash
cat > /etc/profile.d/welcome.sh << 'EOF'
#!/bin/bash
if [ -t 0 ] && [ "$PS1" ]; then
echo "=========================================="
echo "Welcome to Your IBM Cloud VSI!"
echo "=========================================="
echo "Server Information:"
echo "- Hostname: $(hostname)"
echo "- IP Address: $(hostname -I | awk '{print $1}')"
echo "- OS: $(if [ -f /etc/os-release ]; then grep PRETTY_NAME /etc/os-release | cut -d'"' -f2; elif [ -f /etc/redhat-release ]; then cat /etc/redhat-release; else uname -s; fi)"
echo ""
fi
EOF
chmod +x /etc/profile.d/welcome.sh
EOT
}
variable "enable_floating_ip" {
description = "Allocate and assign a floating IP address to the virtual server instance."
type = bool
default = true
}
variable "existing_ssh_key_name" {
type = string
description = "An existing ssh key name to use for this example, if unset a new ssh key will be created."
default = null
}