-
Notifications
You must be signed in to change notification settings - Fork 94
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
Error: with canonical "aws_security_group.this_name_prefix": graph node already exists #103
Comments
I found a similar error when trying to import a tfstate file.
To reproduce:
The list of resources in the tfstate file:
|
Ok I see the issue. The logic right now does not separate resources of different modules, so:
Are understood as |
Merged the fix to master. |
@xescugc I update to version $ terraform state list
aws_key_pair.key_pair
local_file.ansible_inventory
local_file.private_key
null_resource.ansible_installation
tls_private_key.private_key
module.ec2_bastion.aws_instance.this[0]
module.ec2_redhat_a.aws_instance.this[0]
module.ec2_redhat_b.aws_instance.this[0]
module.ec2_ubuntu_a[0].aws_instance.this[0]
module.ec2_ubuntu_a[1].aws_instance.this[0]
module.ec2_ubuntu_b[0].aws_instance.this[0]
module.ec2_ubuntu_b[1].aws_instance.this[0]
module.ssh_sg.aws_security_group.this_name_prefix[0]
module.ssh_sg.aws_security_group_rule.ingress_rules[0]
module.vpc.aws_internet_gateway.this[0]
module.vpc.aws_route.public_internet_gateway[0]
module.vpc.aws_route_table.private[0]
module.vpc.aws_route_table.private[1]
module.vpc.aws_route_table.public[0]
module.vpc.aws_route_table_association.private[0]
module.vpc.aws_route_table_association.private[1]
module.vpc.aws_route_table_association.public[0]
module.vpc.aws_subnet.private[0]
module.vpc.aws_subnet.private[1]
module.vpc.aws_subnet.public[0]
module.vpc.aws_vpc.this[0] |
Ok I see the error. We are not (I'll have to check how) considering a module used multiple times, for what I see in your case you have the I will check and find a way to identify it :). BTW could you run If with the new TFState still fails for the same reason then, if it's ok with you, you could share it so I actually write a test case for it :). Only if it's ok for you ofc. |
{
"version": 4,
"terraform_version": "0.15.3",
"serial": 899,
"lineage": "d170e278-4de7-37d9-5083-fd901247cebd",
"outputs": {},
"resources": [
{
"module": "module.all_sg",
"mode": "managed",
"type": "aws_security_group",
"name": "this_name_prefix",
"provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
"instances": [
{
"index_key": 0,
"schema_version": 1,
"attributes": {
"egress": [],
"id": "sg-0987114dd4c1ff786",
"ingress": []
},
"sensitive_attributes": [],
"dependencies": [
"module.vpc.aws_vpc.this"
],
"create_before_destroy": true
}
]
},
{
"module": "module.all_sg",
"mode": "managed",
"type": "aws_security_group_rule",
"name": "egress_rules",
"provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
"instances": [
{
"index_key": 0,
"schema_version": 2,
"attributes": {
"id": "sgrule-3777339840",
"security_group_id": "sg-0987114dd4c1ff786",
"source_security_group_id": null
},
"sensitive_attributes": [],
"dependencies": [
"module.all_sg.aws_security_group.this",
"module.all_sg.aws_security_group.this_name_prefix",
"module.vpc.aws_vpc.this"
]
}
]
},
{
"module": "module.all_sg",
"mode": "managed",
"type": "aws_security_group_rule",
"name": "ingress_rules",
"provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
"instances": [
{
"index_key": 0,
"schema_version": 2,
"attributes": {
"id": "sgrule-1734591447",
"security_group_id": "sg-0987114dd4c1ff786",
"source_security_group_id": null
},
"sensitive_attributes": [],
"dependencies": [
"module.all_sg.aws_security_group.this",
"module.all_sg.aws_security_group.this_name_prefix",
"module.vpc.aws_vpc.this"
]
}
]
},
{
"module": "module.ec2_openvpn.module.bastion_sg",
"mode": "managed",
"type": "aws_security_group",
"name": "this_name_prefix",
"provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
"instances": [
{
"index_key": 0,
"schema_version": 1,
"attributes": {
"egress": [],
"id": "sg-0004cc061bc236c1c",
"ingress": []
},
"sensitive_attributes": [],
"dependencies": [
"module.vpc.aws_vpc.this"
],
"create_before_destroy": true
}
]
},
{
"module": "module.ec2_openvpn.module.bastion_sg",
"mode": "managed",
"type": "aws_security_group_rule",
"name": "egress_rules",
"provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
"instances": [
{
"index_key": 0,
"schema_version": 2,
"attributes": {
"id": "sgrule-82634802",
"security_group_id": "sg-0004cc061bc236c1c",
"source_security_group_id": null
},
"sensitive_attributes": [],
"dependencies": [
"module.ec2_openvpn.module.bastion_sg.aws_security_group.this",
"module.ec2_openvpn.module.bastion_sg.aws_security_group.this_name_prefix",
"module.vpc.aws_vpc.this"
]
}
]
},
{
"module": "module.ec2_openvpn.module.bastion_sg",
"mode": "managed",
"type": "aws_security_group_rule",
"name": "ingress_rules",
"provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
"instances": [
{
"index_key": 0,
"schema_version": 2,
"attributes": {
"id": "sgrule-96428233",
"security_group_id": "sg-0004cc061bc236c1c",
"source_security_group_id": null
},
"sensitive_attributes": [],
"dependencies": [
"module.ec2_openvpn.module.bastion_sg.aws_security_group.this",
"module.ec2_openvpn.module.bastion_sg.aws_security_group.this_name_prefix",
"module.vpc.aws_vpc.this"
]
}
]
},
{
"module": "module.ec2_openvpn.module.ec2_bastion",
"mode": "managed",
"type": "aws_instance",
"name": "this",
"provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
"instances": [
{
"index_key": 0,
"schema_version": 1,
"attributes": {
"id": "i-0a21b3e118e0ba2ef"
},
"sensitive_attributes": [],
"dependencies": [
"aws_key_pair.key_pair",
"module.ec2_openvpn.module.bastion_sg.aws_security_group.this",
"module.ec2_openvpn.module.bastion_sg.aws_security_group.this_name_prefix",
"module.vpc.aws_subnet.public",
"module.vpc.aws_vpc.this",
"module.vpc.aws_vpc_ipv4_cidr_block_association.this",
"tls_private_key.private_key"
]
}
]
},
{
"module": "module.ec2_redhat_a",
"mode": "managed",
"type": "aws_instance",
"name": "this",
"provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
"instances": [
{
"index_key": 0,
"schema_version": 1,
"attributes": {
"id": "i-05f9a6abce16ab928"
},
"sensitive_attributes": [],
"dependencies": [
"aws_key_pair.key_pair",
"module.all_sg.aws_security_group.this",
"module.all_sg.aws_security_group.this_name_prefix",
"module.vpc.aws_subnet.private",
"module.vpc.aws_vpc.this",
"module.vpc.aws_vpc_ipv4_cidr_block_association.this",
"tls_private_key.private_key"
]
}
]
},
{
"module": "module.ec2_redhat_b",
"mode": "managed",
"type": "aws_instance",
"name": "this",
"provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
"instances": [
{
"index_key": 0,
"schema_version": 1,
"attributes": {
"id": "i-0befa657413af7c25"
},
"sensitive_attributes": [],
"dependencies": [
"aws_key_pair.key_pair",
"module.all_sg.aws_security_group.this",
"module.all_sg.aws_security_group.this_name_prefix",
"module.vpc.aws_subnet.private",
"module.vpc.aws_vpc.this",
"module.vpc.aws_vpc_ipv4_cidr_block_association.this",
"tls_private_key.private_key"
]
}
]
},
{
"module": "module.ec2_ubuntu_a[0]",
"mode": "managed",
"type": "aws_instance",
"name": "this",
"provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
"instances": [
{
"index_key": 0,
"schema_version": 1,
"attributes": {
"id": "i-01cde81471bc7715c"
},
"sensitive_attributes": [],
"dependencies": [
"aws_key_pair.key_pair",
"module.all_sg.aws_security_group.this",
"module.all_sg.aws_security_group.this_name_prefix",
"module.vpc.aws_subnet.private",
"module.vpc.aws_vpc.this",
"module.vpc.aws_vpc_ipv4_cidr_block_association.this",
"tls_private_key.private_key"
]
}
]
},
{
"module": "module.ec2_ubuntu_a[1]",
"mode": "managed",
"type": "aws_instance",
"name": "this",
"provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
"instances": [
{
"index_key": 0,
"schema_version": 1,
"attributes": {
"id": "i-0bbdaaaca5cf61ef5"
},
"sensitive_attributes": [],
"dependencies": [
"aws_key_pair.key_pair",
"module.all_sg.aws_security_group.this",
"module.all_sg.aws_security_group.this_name_prefix",
"module.vpc.aws_subnet.private",
"module.vpc.aws_vpc.this",
"module.vpc.aws_vpc_ipv4_cidr_block_association.this",
"tls_private_key.private_key"
]
}
]
},
{
"module": "module.ec2_ubuntu_b[0]",
"mode": "managed",
"type": "aws_instance",
"name": "this",
"provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
"instances": [
{
"index_key": 0,
"schema_version": 1,
"attributes": {
"id": "i-09f7c0b262ec08dfa"
},
"sensitive_attributes": [],
"dependencies": [
"aws_key_pair.key_pair",
"module.all_sg.aws_security_group.this",
"module.all_sg.aws_security_group.this_name_prefix",
"module.vpc.aws_subnet.private",
"module.vpc.aws_vpc.this",
"module.vpc.aws_vpc_ipv4_cidr_block_association.this",
"tls_private_key.private_key"
]
}
]
},
{
"module": "module.ec2_ubuntu_b[1]",
"mode": "managed",
"type": "aws_instance",
"name": "this",
"provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
"instances": [
{
"index_key": 0,
"schema_version": 1,
"attributes": {
"id": "i-0df31351fc10da682"
},
"sensitive_attributes": [],
"dependencies": [
"aws_key_pair.key_pair",
"module.all_sg.aws_security_group.this",
"module.all_sg.aws_security_group.this_name_prefix",
"module.vpc.aws_subnet.private",
"module.vpc.aws_vpc.this",
"module.vpc.aws_vpc_ipv4_cidr_block_association.this",
"tls_private_key.private_key"
]
}
]
},
{
"module": "module.vpc",
"mode": "managed",
"type": "aws_eip",
"name": "nat",
"provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
"instances": [
{
"index_key": 0,
"schema_version": 0,
"attributes": {
"id": "eipalloc-0353cd2b1a2c0ed66"
},
"sensitive_attributes": []
}
]
},
{
"module": "module.vpc",
"mode": "managed",
"type": "aws_internet_gateway",
"name": "this",
"provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
"instances": [
{
"index_key": 0,
"schema_version": 0,
"attributes": {
"id": "igw-0e982a7cdfc39d2ff"
},
"sensitive_attributes": [],
"dependencies": [
"module.vpc.aws_vpc.this",
"module.vpc.aws_vpc_ipv4_cidr_block_association.this"
]
}
]
},
{
"module": "module.vpc",
"mode": "managed",
"type": "aws_nat_gateway",
"name": "this",
"provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
"instances": [
{
"index_key": 0,
"schema_version": 0,
"attributes": {
"id": "nat-0d46ed83250f7d846"
},
"sensitive_attributes": [],
"dependencies": [
"module.vpc.aws_eip.nat",
"module.vpc.aws_internet_gateway.this",
"module.vpc.aws_subnet.public",
"module.vpc.aws_vpc.this",
"module.vpc.aws_vpc_ipv4_cidr_block_association.this"
]
}
]
}
]
} |
Terraform version : 0.14.7
OS: Ubuntu 20 on WSL
Provider: AWS
Command:
terraform state pull | inframap generate --tfstate --connections=false | dot -Tpng > inframap.png
First I got empty graph, Then I try with
--connections=false
and got errorI think you need this output
terraform state list | grep aws_security_group.this_name_prefix
The text was updated successfully, but these errors were encountered: