Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for data sources #3

Closed
cesar-rodriguez opened this issue Sep 24, 2017 · 1 comment
Closed

Add support for data sources #3

cesar-rodriguez opened this issue Sep 24, 2017 · 1 comment

Comments

@cesar-rodriguez
Copy link
Contributor

When using data sources, terraform-validate fails tests.

Example:

variable "environment" {}
variable "vpc_id" {}
variable "port" {}

data "aws_vpc" "selected" {
  id = "${var.vpc_id}"
}

resource "aws_security_group" "sg" {
  name        = "test"
  description = "test security group"
  vpc_id      = "${var.vpc_id}"

  ingress {
    from_port = "${var.port}"
    to_port   = "${var.port}"
    protocol  = "tcp"

    cidr_blocks = ["${data.aws_vpc.selected.cidr_block}"]
  }
}

Results:
ERROR: test_aws_security_group_inline_rule_open (terrascan.test_security_group.TestSecurityGroups)

Traceback (most recent call last):
File "/tmp/build/51a4a4ac/terrascan/terrascan/test_security_group.py", line 45, in test_aws_security_group_inline_rule_open
'cidr_blocks').list_should_not_contain('0.0.0.0/0')
File "/usr/local/lib/python3.6/site-packages/terraform_validate/terraform_validate.py", line 167, in list_should_not_contain
actual_property_value = self.validator.substitute_variable_values_in_string(property.property_value)
File "/usr/local/lib/python3.6/site-packages/terraform_validate/terraform_validate.py", line 504, in substitute_variable_values_in_string
variable_default_value = self.get_terraform_variable_value(a.variable)
File "/usr/local/lib/python3.6/site-packages/terraform_validate/terraform_validate.py", line 493, in get_terraform_variable_value
raise TerraformVariableException("There is no Terraform variable '{0}'".format(variable))
terraform_validate.terraform_validate.TerraformVariableException: There is no Terraform variable ''

@cesar-rodriguez
Copy link
Contributor Author

This is no longer an issue as of Terrascan v1.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant