Reputation: 1128
How can I update the default route table that is automatically created when I create a VPC by using Terraform?
I would like to add some tags to it.
This is how I create my VPC
module "aws_vpc" {
source = "../../modules/Virtual Private Cloud"
vpc_cidr = "10.0.0.0/16"
vpc_instance_tenancy = "default"
vpc_tags = {
Name = "Web Application VPC"
project = "Alpha"
cost_center = "92736"
developer = "J.Pean"
}
}
Module looks like this:
resource "aws_vpc" "new" {
cidr_block = var.vpc_cidr
instance_tenancy = "default"
tags = var.vpc_tags
}
Upvotes: 1
Views: 1004
Reputation: 1128
You can manage your newly created route table as well as nacl and sg through the resources:
Upvotes: 1
Reputation: 9655
resource "null_resource" "tag_default_route_table" {
triggers = {
route_table_id = aws_vpc.new.default_route_table_id
}
provisioner "local-exec" {
interpreter=["/bin/bash", "-c"]
command = <<EOF
set -euo pipefail
aws ec2 create-tags --resources route_table_id --tags 'Key="somekey",Value=test'
EOF
}
}
Using null_resource
Upvotes: 1