grem11n / terraform-aws-vpc-peering

Terraform module to setup VPC peering connection
https://registry.terraform.io/modules/grem11n/vpc-peering/aws/latest
Apache License 2.0
126 stars 91 forks source link

[BUG] Can't run Terraform init|plan|apply without deleting the .terraform folder #84

Closed lpossamai closed 2 years ago

lpossamai commented 2 years ago

I have to delete my .terraform folder every time in order for me to run terraform init/plan/apply.

The error that I get is:

Error: Duplicate data "aws_vpc_endpoint_service" configuration
│ 
│   on .terraform/modules/vpc_endpoints_nocreate/modules/vpc-endpoints/main.tf line 5:
│    5: data "aws_vpc_endpoint_service" "this" {
│ 
│ A aws_vpc_endpoint_service data resource named "this" was already declared at .terraform/modules/vpc_endpoints_nocreate/modules/vpc-endpoints/main 3.tf:5,1-39. Resource names must be unique per type in each module.
╵
╷
│ Error: Duplicate resource "aws_vpc_endpoint" configuration
│ 
│   on .terraform/modules/vpc_endpoints_nocreate/modules/vpc-endpoints/main.tf line 17:
│   17: resource "aws_vpc_endpoint" "this" {
│ 
│ A aws_vpc_endpoint resource named "this" was already declared at .terraform/modules/vpc_endpoints_nocreate/modules/vpc-endpoints/main 3.tf:17,1-35. Resource names must be unique per type in each module.
╵
╷
│ Error: Duplicate output definition
│ 
│   on .terraform/modules/vpc_endpoints_nocreate/modules/vpc-endpoints/outputs.tf line 1:
│    1: output "endpoints" {
│ 
│ An output named "endpoints" was already defined at .terraform/modules/vpc_endpoints_nocreate/modules/vpc-endpoints/outputs 3.tf:1,1-19. Output names must be unique within a module.
╵
╷
│ Error: Duplicate variable declaration
│ 
│   on .terraform/modules/vpc_endpoints_nocreate/modules/vpc-endpoints/variables.tf line 1:
│    1: variable "create" {
│ 
│ A variable named "create" was already declared at .terraform/modules/vpc_endpoints_nocreate/modules/vpc-endpoints/variables 3.tf:1,1-18. Variable names must be unique within a module.
╵
╷
│ Error: Duplicate variable declaration
│ 
│   on .terraform/modules/vpc_endpoints_nocreate/modules/vpc-endpoints/variables.tf line 7:
│    7: variable "vpc_id" {
│ 
│ A variable named "vpc_id" was already declared at .terraform/modules/vpc_endpoints_nocreate/modules/vpc-endpoints/variables 3.tf:7,1-18. Variable names must be unique within a module.
╵
╷
│ Error: Duplicate variable declaration
│ 
│   on .terraform/modules/vpc_endpoints_nocreate/modules/vpc-endpoints/variables.tf line 13:
│   13: variable "endpoints" {
│ 
│ A variable named "endpoints" was already declared at .terraform/modules/vpc_endpoints_nocreate/modules/vpc-endpoints/variables 3.tf:13,1-21. Variable names must be unique within a module.
╵
╷
│ Error: Duplicate variable declaration
│ 
│   on .terraform/modules/vpc_endpoints_nocreate/modules/vpc-endpoints/variables.tf line 19:
│   19: variable "security_group_ids" {
│ 
│ A variable named "security_group_ids" was already declared at .terraform/modules/vpc_endpoints_nocreate/modules/vpc-endpoints/variables 3.tf:19,1-30. Variable names must be unique within a module.
╵
╷
│ Error: Duplicate variable declaration
│ 
│   on .terraform/modules/vpc_endpoints_nocreate/modules/vpc-endpoints/variables.tf line 25:
│   25: variable "subnet_ids" {

After executing rm -rf .terraform .terraform.lock.hcl && terraform init && terraform workspace select prod, I am able to run init/plan/apply, but only once. Then the errors come back and I have to do these steps again.

Terraform version:

Terraform v1.1.5
on darwin_arm64
+ provider registry.terraform.io/hashicorp/aws v3.74.3
+ provider registry.terraform.io/hashicorp/template v2.2.0

Module version: (Latest? I don't specify the version)

module "module_depends_on" {
  count  = (terraform.workspace == "prod") ? 1 : 0
  source = "github.com/grem11n/terraform-aws-vpc-peering"
grem11n commented 2 years ago

Hello, @lpossamai , I will be able to take a look at it after the war. Thank you for understanding!

lpossamai commented 2 years ago

This is no longer required. Working fine.