Expected: IDENT | STRING | ASSIGN | LBRACE received: LBRACK [0m [0m in terraform

Being new to terraform and Jenkins, I am trying to run a terraform script on jenkins, but encountering this strange problem as shown below:

Check version 59b7e707924169b66e3043a381ab63f6ccd0e2ae (Links / remote controls / origin / master)

git config core.sparsecheckout # timeout = 10 git checkout -f 59b7e707924169b66e3043a381ab63f6ccd0e2ae git rev-list 14cca48b44d7820f3f6ea8ed6d2a0728bc5e2176 # timeout = 10 [FT_packer / terform /form par. repository / jenkins / workspace / crspng -CCPDev-ccp-ft-tf / farm_vpc_02 / FT_packer / vars.tf: At 16:35: expected: IDENT | STRING | ASSIGN | LBRACE retrieved: LBRACK [0m [0m FATAL: java.lang.Exception: Terraform Get failed: 1 at org.jenkinsci.plugins.terraform.TerraformBuildWrapper.executeGet (TerraformBuildWrapper.java:224) in org.jenkinsci.ralugter.raldter.raldter.raildter .setUp (TerraformBuildWrapper.java:256) in hudson.model.Build $ BuildExecution.doRun (Build.java:156) in hudson.model.AbstractBuild $ AbstractBuildExecution.run (AbstractBuild.java∗34) in hudson.model.Run. execute (Run.java:1720) in hudson.model.FreeStyleBuild.run (FreeStyleBuild.java:43) in hudson.model.ResourceController.execute (ResourceController.java:98) on hudson.model.Executor.run (Executor.java : 401)

Finished: FAILURE

Main.tf looks like this:

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}" } } 

All variables are declared in vars.ft, as shown below:

 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" {} 

The error is shown on line 16 of the above file, i.e.

variable "vpc-security-group-ids" []

Actual resource variables are mentioned in jenkins like this:

enter image description here

+5
source share
1 answer

For your second problem, it seems the value of the vpc_security_group_ids variable is a list. (Yes, this, I can confirm now, from the screenshot)

Make the changes below

 variable "vpc-security-group-ids" { type = "list" } resource "aws_instance" "FT-packer-node" { vpc_security_group_ids = "${var.vpc-security-group-ids}" } 

Before running terraform plan/apply , first check.

 terraform validate -check-variables=false 

This will be useful to fix your first problem.

Error loading configuration: error analysis / selection / repository / jenkins / workspace / crspng-CCPDev-ccp-ft-tf / farm_vpc_02 / FT_packer / vars.tf : at 16:35: expected: IDENT | STRING | ASSIGN | LBRACE received: LBRACK

+2
source

Source: https://habr.com/ru/post/1272360/


All Articles