-
Notifications
You must be signed in to change notification settings - Fork 150
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
'AttributeError: 'str' object has no attribute 'append'' #725
Comments
The scenario to reproduce the issueFile structure: % tree terraform
terraform
├── main.tf
├── my-module
│ ├── module.tf
│ ├── my-data-module
│ │ └── output.tf
│ ├── my-nested-module
│ │ └── sg.tf
│ └── sg.tf
└── terraform.tf Lets say our terraform module uses a
module "component" {
source = "./my-module"
} the
module "data-common" {
source = "./my-data-module"
}
resource "aws_security_group" "example_sg" {
name = "example_sg"
description = "Example security group"
ingress {
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = module.data-common.cidr_blocks
}
} also it uses the
module "nested-component" {
source = "./my-nested-module"
}
resource "aws_security_group" "example_sg_nested_host" {
name = "example_sg_nested_host"
description = "Example security group nested"
}
resource "aws_security_group" "example_sg_nested_client" {
name = "example_sg_nested_client"
description = "Example security group nested"
}
resource "aws_security_group_rule" "example_sg_nested_host_ingress_client" {
source_security_group_id = aws_security_group.example_sg_nested_client.id
security_group_id = aws_security_group.example_sg_nested_host.id
type = "ingress"
from_port = 443
to_port = 443
protocol = "tcp"
}
resource "aws_security_group_rule" "example_sg_nested_client_egress_host" {
source_security_group_id = aws_security_group.example_sg_nested_host.id
security_group_id = aws_security_group.example_sg_nested_client.id
type = "egress"
from_port = 443
to_port = 443
protocol = "tcp"
} This setup causes the error described in the issue and a following warning
ObservationIf we stop using
resource "aws_security_group" "example_sg" {
name = "example_sg"
description = "Example security group"
ingress {
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
} it starts working fine again. |
By adding a debug log in the if statement here cli/terraform_compliance/extensions/terraform.py Lines 335 to 336 in e9f37e7
like this if parameter not in self.resources[source_resource]['values']:
self.resources[source_resource]['values'][parameter] = target_resource
defaults = Defaults()
console_write('{} {}: {}'.format(defaults.warning_icon,
defaults.warning_colour('WARNING (test)'),
defaults.info_colour('Injecting string into "{}" parameter... Source resource {}, target resource {} ref type "{}".'
''.format(parameter, source_resource, target_resource, ref_type)))) and another one just before the failing line here cli/terraform_compliance/extensions/terraform.py Lines 325 to 326 in e9f37e7
like this if ref_type in self.resources[target_resource]['values'] and not isinstance(self.resources[target_resource]['values'][ref_type], list):
defaults = Defaults()
console_write('{} {}: {}'.format(defaults.warning_icon,
defaults.warning_colour('WARNING'),
defaults.info_colour('Source resource {}, target resource {} ref type "{}" is not a list. Parameter: {} '
'The value is: "{}"'.format(source_resource, target_resource, ref_type, parameter, self.resources[target_resource]['values'][ref_type])))) we can see that the failing run logs following warnings
where the successful run logs following
We can quickly tell that when we're using the
|
Description
Getting the following error when running tf-compliance after checks:
The same Terraform code works fine in a different environment:
and here it runs the scenarios as expected.
To Reproduce
Is there a secure location I can upload the plan to?
Tested Versions:
The text was updated successfully, but these errors were encountered: