AWS Amazon EC2 VPN Gateway Route Propagation

This page shows how to write Terraform and CloudFormation for Amazon EC2 VPN Gateway Route Propagation and write them securely.

aws_vpn_gateway_route_propagation (Terraform)

The VPN Gateway Route Propagation in Amazon EC2 can be configured in Terraform with the resource name aws_vpn_gateway_route_propagation. The following sections describe 3 examples of how to use the resource and its parameters.

Example Usage from GitHub

main.tf#L25
resource "aws_vpn_gateway_route_propagation" "vgw-public-routes" {
  count = length(data.aws_availability_zones.azs.names)
  vpn_gateway_id = aws_vpn_gateway.vgw.id
  route_table_id = element(var.vgw-public-route-table-id,count.index )

}
main.tf#L25
resource "aws_vpn_gateway_route_propagation" "vgw-public-routes" {
  count = length(data.aws_availability_zones.azs.names)
  vpn_gateway_id = aws_vpn_gateway.vgw.id
  route_table_id = element(var.vgw-public-route-table-id,count.index )

}
main.tf#L49
resource "aws_vpn_gateway_route_propagation" "public" {
  route_table_id = aws_route_table.public.id
  vpn_gateway_id = aws_vpn_gateway.default.id
}

resource "aws_vpn_gateway_route_propagation" "private" {

Review your Terraform file for AWS best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

Parameters

Explanation in Terraform Registry

Requests automatic route propagation between a VPN gateway and a route table.

Note: This resource should not be used with a route table that has the propagating_vgws argument set. If that argument is set, any route propagation not explicitly listed in its value will be removed.

Tips: Best Practices for The Other AWS Amazon EC2 Resources

In addition to the aws_default_vpc, AWS Amazon EC2 has the other resources that should be configured for security reasons. Please check some examples of those resources and precautions.

risk-label

aws_default_vpc

Ensure to avoid using default VPC

It is better to define the own VPC and use it.

risk-label

aws_network_acl_rule

Ensure your network ACL rule blocks unwanted inbound traffic

It is better to block unwanted inbound traffic.

risk-label

aws_ebs_volume

Ensure to use a customer-managed key for EBS volume encryption

It is better to use a customer-managed key for EBS volume encryption. It can be gain more control over the encryption by using customer-managed keys (CMK).

risk-label

aws_instance

Ensure to avoid storing AWS access keys in user data

It is better to avoid storing AWS access keys in user data. `aws_iam_instance_profile` could be used instead.

risk-label

aws_security_group

Ensure your security group blocks unwanted inbound traffic

It is better to block unwanted inbound traffic.

Review your AWS Amazon EC2 settings

In addition to the above, there are other security points you should be aware of making sure that your .tf files are protected in Shisho Cloud.

AWS::EC2::VPNGateway (CloudFormation)

The VPNGateway in EC2 can be configured in CloudFormation with the resource name AWS::EC2::VPNGateway. The following sections describe 10 examples of how to use the resource and its parameters.

Example Usage from GitHub

vpn-bgp.yml#L88
    Type: AWS::EC2::VPNGateway
    Properties:
      Type: ipsec.1
      Tags:
      - Key: Name
        Value:
aws-vpn-stack.yml#L26
    Type: "AWS::EC2::VPNGateway"
    Properties:
      Type: ipsec.1

  VPCGatewayAttachment:
    Type: "AWS::EC2::VPCGatewayAttachment"
vpn.yml#L21
    Type: "AWS::EC2::VPNGateway"
    Properties:
      Type: "ipsec.1"

  VpnConnection:
    Type: "AWS::EC2::VPNConnection"
mu.yml#L16
        Type: "AWS::EC2::VPNGateway"
        Properties:
          Type: ipsec.1
      VPNconnection:
        Type: "AWS::EC2::VPNConnection"
        Properties:
mu.yml#L16
        Type: "AWS::EC2::VPNGateway"
        Properties:
          Type: ipsec.1
      VPNconnection:
        Type: "AWS::EC2::VPNConnection"
        Properties:
vpn-bgp.json#L97
      "Type": "AWS::EC2::VPNGateway",
      "Properties": {
        "Type": "ipsec.1",
        "Tags": [
          {
            "Key": "Name",
vpn-bgp.json#L97
      "Type": "AWS::EC2::VPNGateway",
      "Properties": {
        "Type": "ipsec.1",
        "Tags": [
          {
            "Key": "Name",
indent_output.json#L93
            "Type": "AWS::EC2::VPNGatewayRoutePropagation"
        },
        "aclentry1": {
            "Properties": {
                "CidrBlock": "172.16.0.0/24",
                "Egress": "true",
vpc.json#L82
         "Type" : "AWS::EC2::VPNGateway",
         "Properties" : {
            "Type" : "ipsec.1"
         }
      },
      "VpnConnectionGreen" : {
vpngw.json#L14
        "Type" : "AWS::EC2::VPNGateway",
        "Properties" : {
           "Type" : "ipsec.1",
           "Tags" : [ { "Key" : "Name", "Value" : "Production" } ]
        }
     },

Parameters

Explanation in CloudFormation Registry

Specifies a virtual private gateway. A virtual private gateway is the endpoint on the VPC side of your VPN connection. You can create a virtual private gateway before creating the VPC itself.

For more information, see AWS Site-to-Site VPN in the AWS Site-to-Site VPN User Guide.

Frequently asked questions

What is AWS Amazon EC2 VPN Gateway Route Propagation?

AWS Amazon EC2 VPN Gateway Route Propagation is a resource for Amazon EC2 of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.

Where can I find the example code for the AWS Amazon EC2 VPN Gateway Route Propagation?

For Terraform, the sayindil/Terraform, sharmamukesh76/Terraform-advanced and ericdahl/tf-vpn-sandbox source code examples are useful. See the Terraform Example section for further details.

For CloudFormation, the librannk/AWS-CloudFormation-tmplte, djoreilly/aws-vpn-testing and anri-c/my-aws-cf-templates source code examples are useful. See the CloudFormation Example section for further details.