I’m trying to do the following:
const allAvailabilityZones = new DataAwsAvailabilityZones(
this,
"all-availability-zones",
{}
).names;
this.vpc = new Vpc(this, "vpc", {
name: `${id}-vpc`,
cidr: "10.1.0.0/16",
azs: allAvailabilityZones,
privateSubnets: ["10.1.0.0/18", "10.1.64.0/18", "10.1.128.0/18"],
publicSubnets: ["10.1.192.0/20", "10.1.208.0/20", "10.1.224.0/20"],
enableNatGateway: true,
singleNatGateway: true,
enableDnsHostnames: true,
tags: {
[`kubernetes.io/cluster/${settings.clusterName}`]: "shared",
},
publicSubnetTags: {
[`kubernetes.io/cluster/${settings.clusterName}`]: "shared",
"kubernetes.io/role/elb": "1",
},
privateSubnetTags: {
[`kubernetes.io/cluster/${settings.clusterName}`]: "shared",
"kubernetes.io/role/internal-elb": "1",
},
});
new VpcEndpoints(this, "vpc-endpoints", {
vpcId: this.vpc.vpcIdOutput,
endpoints: {
s3: {
service: "s3",
service_type: "Gateway",
route_table_ids: [
this.vpc.privateRouteTableIdsOutput,
this.vpc.publicRouteTableIdsOutput
],
}
},
dependsOn: [this.vpc]
});
I’m getting the following error:
Error: Incorrect attribute value type
│
│ on .terraform/modules/vpc-endpoints/modules/vpc-endpoints/main.tf line 33, in resource "aws_vpc_endpoint" "this":
│ 33: route_table_ids = try(each.value.service_type, "Interface") == "Gateway" ? lookup(each.value, "route_table_ids", null) : null
│ ├────────────────
│ │ each.value is object with 3 attributes
│ │ each.value.service_type is "Gateway"
│
│ Inappropriate value for attribute "route_table_ids": element 0: string
│ required.
I just want the endpoints associated the public and private route table ids. I’ve tried various forms following AI suggestions and I can’t get this to work. Any suggestions?
It works if I do this:
route_table_ids: this.vpc.privateRouteTableIdsOutput,