Bootstrap FreeKB - Amazon Web Services (AWS) - Create Route using the AWS CLI
Amazon Web Services (AWS) - Create Route using the AWS CLI


This assumes you have already configured the aws command line tool. If not, check out my article on Getting Started with the AWS CLI.

The aws ec2 describe-route-tables command can be used to list your Route Tables. Something like this should be returned.

aws ec2 describe-route-tables

 

Something like this should be returned. Notice in this example the Route Table has 2 Routes.

[
    {
        "Associations": [
            {
                "AssociationState": {
                    "State": "associated"
                },
                "RouteTableAssociationId": "rtbassoc-03d88b8f543d22956",
                "Main": true,
                "RouteTableId": "rtb-0587dc78ea0f59472"
            }
        ],
        "RouteTableId": "rtb-0587dc78ea0f59472",
        "VpcId": "vpc-014d2fcfa335d3c01",
        "PropagatingVgws": [],
        "Tags": [
            {
                "Value": "ManagedByAmazonFSx",
                "Key": "AmazonFSx"
            }
        ],
        "Routes": [
            {
                "GatewayId": "local",
                "DestinationCidrBlock": "172.31.0.0/16",
                "State": "active",
                "Origin": "CreateRouteTable"
            },
            {
                "GatewayId": "igw-020c1f7ec148352b3",
                "DestinationCidrBlock": "0.0.0.0/0",
                "State": "active",
                "Origin": "CreateRoute"
            }
        ],
        "OwnerId": "123456789012"
    }
]

 

The aws ec2 create-route command can be used to add a Route to the Route Table. In this example, a Transit Gateway Route is added to the Route Table.

aws ec2 create-route \
--route-table-id rtb-0587dc78ea0f59472 \
--destination-cidr-block 172.16.0.0/16 \
--transit-gateway-id tgw-036b93068244418ff

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter c0ce93 in the box below so that we can be sure you are a human.