-
-
Notifications
You must be signed in to change notification settings - Fork 95
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: Invalid count argument #58
Labels
bug
🐛 An issue with the system
Comments
terraform {
required_providers {
aws = {
version = "3.74.1"
}
}
}
provider "aws" {
region = "eu-west-2"
}
provider "aws" {
alias = "eu-west-2"
region = "eu-west-2"
}
provider "aws" {
alias = "us-west-1"
region = "us-west-1"
}
resource "aws_vpc" "vpc_uswest" {
provider = aws.us-west-1
cidr_block = "10.10.0.0/16"
enable_dns_support = true
enable_dns_hostnames = true
}
resource "aws_vpc" "vpc_euwest" {
provider = aws.eu-west-2
cidr_block = "10.11.0.0/16"
enable_dns_support = true
enable_dns_hostnames = true
}
resource "aws_iam_role" "test_role" {
name = "cross_region_vpc_peering"
assume_role_policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Action = "sts:AssumeRole"
Effect = "Allow"
Sid = ""
Principal = {
"AWS" : "arn:aws:iam::426005093346:user/kiril"
}
}]
})
}
module "vpc-peering-multi-account" {
source = "cloudposse/vpc-peering-multi-account/aws"
// version = "0.5.0"
accepter_region = var.accepter_region
accepter_vpc_id = aws_vpc.vpc_uswest.id
requester_aws_assume_role_arn = aws_iam_role.test_role.arn
requester_region = var.requester_region
requester_vpc_id = aws_vpc.vpc_euwest.id
}
resource "aws_subnet" "subnet_1_us" {
provider = aws.us-west-1
// availability_zone = element(data.aws_availability_zones.azs.names, 0)
vpc_id = aws_vpc.vpc_uswest.id
cidr_block = "10.10.1.0/24"
}
resource "aws_subnet" "subnet_1_eu" {
// provider = aws.eu-west-2
vpc_id = aws_vpc.vpc_euwest.id
cidr_block = "10.11.1.0/24"
availability_zone = "eu-west-2a"
}
resource "aws_route_table" "route_table_us" {
provider = aws.us-west-1
vpc_id = aws_vpc.vpc_uswest.id
// route {
// cidr_block = "0.0.0.0/0"
// gateway_id = aws_internet_gateway.igw-us.id
// }
// route {
// cidr_block = "10.11.1.0/24"
// vpc_peering_connection_id = aws_vpc_peering_connection.eu-us-peering.id
// }
lifecycle {
ignore_changes = all
}
tags = {
Name = "US-Region-RT"
}
}
resource "aws_main_route_table_association" "set-us-default-rt-assoc" {
provider = aws.us-west-1
vpc_id = aws_vpc.vpc_uswest.id
route_table_id = aws_route_table.route_table_us.id
}
resource "aws_route_table" "route_table_eu" {
provider = aws.eu-west-2
vpc_id = aws_vpc.vpc_euwest.id
/* route {
cidr_block = "0.0.0.0/0"
gateway_id = aws_internet_gateway.igw-eu.id
}
route {
cidr_block = "10.0.1.0/24"
vpc_peering_connection_id = aws_vpc_peering_connection.eu-us-peering.id
}
*/
lifecycle {
ignore_changes = all
}
tags = {
Name = "EU-Region-RT"
}
}
resource "aws_main_route_table_association" "set-eu-default-rt-assoc" {
provider = aws.eu-west-2
vpc_id = aws_vpc.vpc_euwest.id
route_table_id = aws_route_table.route_table_eu.id
} |
I fixed some of the formatting above to make it readable. This is most likely due to the subnets and vpc not already existing prior to creating the vpc peering. In our current example, we only create the peering and assume the vpcs are already created. You may want to consider our other module which does support creating both vpcs and the peering connection. Please comment and we can reopen the issue |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The text was updated successfully, but these errors were encountered: