预期:标识 |字符串 |分配 | LBRACE 得到:LBRACK[0m[0m in terraform
问题:预期:标识 |字符串 |分配 | LBRACE 得到:LBRACK[0m[0m in terraform 作为 terraform 和 Jenkins 的新手,我正在尝试在 jenkins 上运行 terraform 脚本,但遇到了这个奇怪的问题,如下所示: 查看修订版 59b7e707924169b66e3043a381ab63f6ccd0e2ae(参考/远程/来源/主控) git con
问题:预期:标识 |字符串 |分配 | LBRACE 得到:LBRACK[0m[0m in terraform
作为 terraform 和 Jenkins 的新手,我正在尝试在 jenkins 上运行 terraform 脚本,但遇到了这个奇怪的问题,如下所示:
查看修订版 59b7e707924169b66e3043a381ab63f6ccd0e2ae(参考/远程/来源/主控)
git config core.sparsecheckout # timeoutu003d10 git checkout -f 59b7e707924169b66e3043a381ab63f6ccd0e2ae git rev-list 14cca48b44d7820f3f6ea8ed6d2a0728bc5e2176 # timeoutu003d10 [FT_packer] 加载错误 $ /opt/software/配置:解析 /opt/repository/jenkins/workspace/crspng-CCPDev-ccp-ft-tf/farm_vpc_02/FT_packer/vars.tf 时出错:在 16:35:预期:IDENT |字符串 |分配 | LBRACE 得到:LBRACK[0m[0m 致命:java.lang.Exception:Terraform Get failed: 1 at org.jenkinsci.plugins.terraform.TerraformBuildWrapper.executeGet(TerraformBuildWrapper.java:224) at org.jenkinsci.plugins.terraform .TerraformBuildWrapper.setUp(TerraformBuildWrapper.java:256) 在 hudson.model.Build$BuildExecution.doRun(Build.java:156) 在 hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534) 在 hudson.model。 Run.execute(Run.java:1720) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:98) at hudson.model.Executor.run(Executor .java:401)
完成:失败
Main.tf 看起来像这样:
resource "aws_instance" "FT-packer-node" {
ami = "${var.aws-region}"
instance_type = "${var.instance-type}"
vpc_security_group_ids = "${var.vpc-security-group-ids}"
key_name = "${var.key-name}"
subnet_id = "${var.subnet-id}"
associate_public_ip_address = "${var.associate-public-ip-address}"
availability_zone = "eu-central-1a"
private_ip = "${var.machine-private-ip}"
tags {
Name = "${var.machine-name-node}"
Owner = "${var.team-name}"
}
timeouts {
create = "${var.create-timeout}"
delete = "${var.update-timeout}"
}
}
在 vars.ft 中声明所有变量,如下所示:
variable "access_key" {}
variable "secret_key" {}
# ------------- MACHINE RELATED CONFIGS -------------
variable "vpc-name" {}
# Key file(pep/ppk) to be associated
variable "key-name" {}
# EC2 instance size
variable "instance-type" {}
# VPC Security group id to launch machine in
variable "vpc-security-group-ids" []
# Subnet of the VPC
variable "subnet-id" {}
variable "elb-name" {}
# --------------------------ENDS-----------------------------------------
# ------------------------ Optionals ----------------------------------------
# Below configs can be left unchanged. Change on need basis only.
# Team name
variable "team-name" {}
variable "machine-name-node" {}
variable "machine-private-ip" {}
variable "create-timeout" {}
variable "update-timeout" {}
variable "availability-zones" {}
variable "elb-access-log-bucket-name" {}
variable "elb-access-log-dir-name" {}
variable "is-internal-lb" {}
# Need a public IP ?
variable "associate-public-ip-address" {}
# Region
variable "aws-region" {}
错误显示在上述文件的第 16 行,即
变量“vpc 安全组 ID”[]
实际资源变量在 jenkins 中是这样提到的:
解答
对于您的第二个问题,变量vpc_security_group_ids
的值似乎是一个列表。 (是的,我现在可以从截图中确认)
在下面进行更改
variable "vpc-security-group-ids" {
type = "list"
}
resource "aws_instance" "FT-packer-node" {
vpc_security_group_ids = "${var.vpc-security-group-ids}"
}
在你运行terraform plan/apply
之前,你应该先做一个验证
terraform validate -check-variables=false
这将有助于解决您的第一个问题
加载配置时出错:解析 /opt/repository/jenkins/workspace/crspng-CCPDev-ccp-ft-tf/farm_vpc_02/FT_packer/vars.tf 时出错:在 16:35:预期: 标识 |字符串 |分配 | LBRACE 得到:LBRACK
更多推荐
所有评论(0)