Edit (8/16/2023): I figured it out!
I'm trying to pass string parameter(s) to a Terraform map variable, but receiving error "Invalid number literal".
Jenkinsfile:
pipeline {
agent any
parameters {
string(name: 'IP1', defaultValue: '', description: 'Enter first IP address')
}
stages {
stage('Git Checkout') {
steps {
git branch: 'branch1', credentialsId: '', url: 'http://<redacted>.git'
}
}
stage('Deploy Terraform') {
steps {
script {
dir('Linux') {
sh """
terraform init
terraform plan
terraform apply -var 'vms=${params.IP1}' \
--auto-approve
"""
}
}
}
}
}
}
}
variables.tf
variable "vm_map" {
type = map(object({
name = string
ip = string
}))
default = {
"first" = {
name = "ubuntu-jenkins1"
ip = "172.30.100.160"
}
"second" = {
name = "ubuntu-jenkins2"
ip = "172.30.100.161"
}
"third" = {
name = "ubuntu-jenkins3"
ip = "172.30.100.162"
}
}
}