-
Notifications
You must be signed in to change notification settings - Fork 504
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #479 from patilpankaj212/bugFix
fix panic for list variables
- Loading branch information
Showing
5 changed files
with
103 additions
and
3 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
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
15 changes: 15 additions & 0 deletions
15
pkg/iac-providers/terraform/v12/testdata/list-type-vars-test/main.tf
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,15 @@ | ||
data "aws_ami" "amazon_linux" { | ||
most_recent = true | ||
} | ||
|
||
resource "aws_instance" "app" { | ||
count = var.instance_count | ||
|
||
ami = data.aws_ami.amazon_linux.id | ||
instance_type = var.instance_type | ||
|
||
subnet_id = var.subnet_ids[count.index % length(var.subnet_ids)] | ||
vpc_security_group_ids = var.security_group_ids | ||
|
||
tags = var.tags | ||
} |
31 changes: 31 additions & 0 deletions
31
pkg/iac-providers/terraform/v12/testdata/list-type-vars-test/variables.tf
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,31 @@ | ||
variable "instance_count" { | ||
description = "Number of EC2 instances to deploy" | ||
type = list(number) | ||
default = [1,2] | ||
} | ||
|
||
variable "instance_type" { | ||
description = "Type of EC2 instance to use" | ||
type = string | ||
default = "blah_instance" | ||
} | ||
|
||
variable "subnet_ids" { | ||
description = "Subnet IDs for EC2 instances" | ||
type = list(string) | ||
default = ["10.0.0.0/8"] | ||
} | ||
|
||
variable "security_group_ids" { | ||
description = "Security group IDs for EC2 instances" | ||
type = list(string) | ||
} | ||
|
||
variable "tags" { | ||
description = "Tags for instances" | ||
type = map | ||
default = { | ||
"a" = "b" | ||
"c" = "d" | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
pkg/iac-providers/terraform/v12/testdata/tfjson/list-vars-test.json
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,28 @@ | ||
{ | ||
"aws_instance": [ | ||
{ | ||
"id": "aws_instance.app", | ||
"name": "app", | ||
"source": "main.tf", | ||
"line": 5, | ||
"type": "aws_instance", | ||
"config": { | ||
"ami": "${data.aws_ami.amazon_linux.id}", | ||
"count": [ | ||
1, | ||
2 | ||
], | ||
"instance_type": "blah_instance", | ||
"subnet_id": [ | ||
"10.0.0.0/8" | ||
], | ||
"tags": { | ||
"a": "b", | ||
"c": "d" | ||
}, | ||
"vpc_security_group_ids": "${var.security_group_ids}" | ||
}, | ||
"skip_rules": null | ||
} | ||
] | ||
} |