AWS Amazon EC2 Client VPN Authorization Rule

This page shows how to write Terraform and CloudFormation for Amazon EC2 Client VPN Authorization Rule and write them securely.

aws_ec2_client_vpn_authorization_rule (Terraform)

The Client VPN Authorization Rule in Amazon EC2 can be configured in Terraform with the resource name aws_ec2_client_vpn_authorization_rule. The following sections describe 1 example of how to use the resource and its parameters.

Example Usage from GitHub

vpn.tf#L55
resource "aws_ec2_client_vpn_authorization_rule" "vpn_auth_rule" {
  client_vpn_endpoint_id = aws_ec2_client_vpn_endpoint.vpn.id
  target_network_cidr    = module.vpc.vpc_cidr_block
  authorize_all_groups   = true

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

Provides authorization rules for AWS Client VPN endpoints. For more information on usage, please see the AWS Client VPN Administrator's Guide.

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::ClientVpnAuthorizationRule (CloudFormation)

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

Example Usage from GitHub

client-vpn-with-directory.yml#L98
    Type: AWS::EC2::ClientVpnAuthorizationRule
    Condition: RoutePeered
    Properties:
      # AccessGroupId: String
      AuthorizeAllGroups: true
      ClientVpnEndpointId: !Ref ClientVPN
template.yml#L43
    Type: AWS::EC2::ClientVpnAuthorizationRule
    Properties:
      AuthorizeAllGroups: true
      ClientVpnEndpointId: !Ref ClientVpnEndpoint
      TargetNetworkCidr: !GetAtt Vpc.CidrBlock

Scenario-2-G.yml#L27
    Type: AWS::EC2::ClientVpnAuthorizationRule
    Properties:
      AuthorizeAllGroups: true
      ClientVpnEndpointId:
        Ref: ClientVPNEndpoint
      Description: Authorization rule for clients to access internet
create_client_vpn.yml#L158
    Type: AWS::EC2::ClientVpnAuthorizationRule
    Properties:
      AuthorizeAllGroups: True
      ClientVpnEndpointId: !Ref VPNEndpoint
      Description: To VPC
      TargetNetworkCidr: !GetAtt VPNVPC.CidrBlock
clientvpn-cloudformation.yml#L108
    Type: "AWS::EC2::ClientVpnAuthorizationRule"
    Properties:
      ClientVpnEndpointId: !Ref VPNEndpoint
      AccessGroupId: PermitVLAN1
      TargetNetworkCidr: "10.1.0.0/16"
      Description: "PermitVLAN1 to 10.1.0.0/16"
vpn-ingress-stack.json#L8
      "Type" : "AWS::EC2::ClientVpnAuthorizationRule",
      "Properties" : {
        "AuthorizeAllGroups": "true",
        "ClientVpnEndpointId": {"Ref": "clientVpnEndpointId"},
        "Description": "authorize-client-vpn-ingress",
        "TargetNetworkCidr": {"Ref": "targetNetworkCidr"}
integ.client-vpn-endpoint.expected.json#L571
      "Type": "AWS::EC2::ClientVpnAuthorizationRule",
      "Properties": {
        "ClientVpnEndpointId": {
          "Ref": "VpcEndpoint6FF034F6"
        },
        "TargetNetworkCidr": {
vpn-client-stack-dev.template.json#L326
      "Type": "AWS::EC2::ClientVpnAuthorizationRule",
      "Properties": {
        "ClientVpnEndpointId": {
          "Ref": "clientVpnEndpoint5E60766B"
        },
        "TargetNetworkCidr": {
cloudformation-template.json#L324
      "Type": "AWS::EC2::ClientVpnAuthorizationRule",
      "Properties": {
        "ClientVpnEndpointId": {
          "Ref": "EC2CVE11MMM"
        },
        "TargetNetworkCidr": "0.0.0.0/0",
EC2ClientVpnAuthorizationRuleSpecification.json#L3
    "AWS::EC2::ClientVpnAuthorizationRule": {
      "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-clientvpnauthorizationrule.html",
      "Properties": {
        "ClientVpnEndpointId": {
          "Required": true,
          "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-clientvpnauthorizationrule.html#cfn-ec2-clientvpnauthorizationrule-clientvpnendpointid",

Parameters

Explanation in CloudFormation Registry

Specifies an ingress authorization rule to add to a Client VPN endpoint. Ingress authorization rules act as firewall rules that grant access to networks. You must configure ingress authorization rules to enable clients to access resources in AWS or on-premises networks.

Frequently asked questions

What is AWS Amazon EC2 Client VPN Authorization Rule?

AWS Amazon EC2 Client VPN Authorization Rule 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 Client VPN Authorization Rule?

For Terraform, the cisagov/inl-aws source code example is useful. See the Terraform Example section for further details.

For CloudFormation, the CU-CommunityApps/cu-aws-cloudformation, agibalov/aws-experiment and bayustira/TemplateCloudFormationYAML source code examples are useful. See the CloudFormation Example section for further details.