AWS Amazon EC2 Client VPN Endpoint
This page shows how to write Terraform and CloudFormation for Amazon EC2 Client VPN Endpoint and write them securely.
aws_ec2_client_vpn_endpoint (Terraform)
The Client VPN Endpoint in Amazon EC2 can be configured in Terraform with the resource name aws_ec2_client_vpn_endpoint
. The following sections describe 3 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "aws_ec2_client_vpn_endpoint" "client_vpn" {
description = var.description
server_certificate_arn = var.server_certificate_arn
client_cidr_block = var.client_cidr_block
split_tunnel = var.split_tunnel
depends_on = [var.cloudwatch_log_stream_name]
resource "aws_ec2_client_vpn_endpoint" "client_vpn" {
description = var.description
server_certificate_arn = var.server_certificate_arn
client_cidr_block = var.client_cidr_block
split_tunnel = var.split_tunnel
depends_on = [var.cloudwatch_log_stream_name]
resource "aws_ec2_client_vpn_endpoint" "vpc_ssl_client_vpn" {
description = var.client_vpn_name
server_certificate_arn = var.asm_server_cert
client_cidr_block = var.client_cidr_block
split_tunnel = var.split_tunnel
transport_protocol = "udp"
Parameters
-
arn
optional computed - string -
client_cidr_block
required - string -
description
optional - string -
dns_name
optional computed - string -
dns_servers
optional - set of string -
id
optional computed - string -
server_certificate_arn
required - string -
split_tunnel
optional - bool -
status
optional computed - string -
tags
optional - map from string to string -
transport_protocol
optional - string -
authentication_options
list block-
active_directory_id
optional - string -
root_certificate_chain_arn
optional - string -
saml_provider_arn
optional - string -
type
required - string
-
-
connection_log_options
list block-
cloudwatch_log_group
optional - string -
cloudwatch_log_stream
optional - string -
enabled
required - bool
-
Explanation in Terraform Registry
Provides an AWS Client VPN endpoint for OpenVPN clients. 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.
aws_default_vpc
Ensure to avoid using default VPC
It is better to define the own VPC and use it.
aws_network_acl_rule
Ensure your network ACL rule blocks unwanted inbound traffic
It is better to block unwanted inbound traffic.
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).
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.
aws_security_group
Ensure your security group blocks unwanted inbound traffic
It is better to block unwanted inbound traffic.
AWS::EC2::ClientVpnEndpoint (CloudFormation)
The ClientVpnEndpoint in EC2 can be configured in CloudFormation with the resource name AWS::EC2::ClientVpnEndpoint
. The following sections describe 10 examples of how to use the resource and its parameters.
Example Usage from GitHub
Type: AWS::EC2::ClientVpnEndpoint
Properties:
AuthenticationOptions:
- ClientAuthenticationRequest
ClientCidrBlock: String
ConnectionLogOptions:
Type: AWS::EC2::ClientVpnEndpoint
Properties:
AuthenticationOptions:
- Type: "federated-authentication"
FederatedAuthentication:
SAMLProviderArn: !Ref VPNIDP
Type: "AWS::EC2::ClientVpnEndpoint"
Properties:
Description: "Client VPN Endpoint."
# クライアント認証の形式
AuthenticationOptions:
- Type: "certificate-authentication"
Type: AWS::EC2::ClientVpnEndpoint
Properties:
AuthenticationOptions:
- MutualAuthentication:
ClientRootCertificateChainArn: arn:aws:acm:us-east-2:491244520525:certificate/6a87671a-a346-4288-b127-f38849899510
Type: certificate-authentication
Type: AWS::EC2::ClientVpnEndpoint
Properties:
AuthenticationOptions:
- Type: certificate-authentication
MutualAuthentication:
ClientRootCertificateChainArn: !Ref ClientCertificateArn
"Type": "AWS::EC2::ClientVpnEndpoint",
"Properties": {
"AuthenticationOptions": [
{
"MutualAuthentication": {
"ClientRootCertificateChainArn": {
"AWS::EC2::ClientVpnEndpoint.CertificateAuthenticationRequest": {
"Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-clientvpnendpoint-certificateauthenticationrequest.html",
"Properties": {
"ClientRootCertificateChainArn": {
"Required": true,
"Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-clientvpnendpoint-certificateauthenticationrequest.html#cfn-ec2-clientvpnendpoint-certificateauthenticationrequest-clientrootcertificatechainarn",
"Type": "AWS::EC2::ClientVpnEndpoint",
"Properties": {
"AuthenticationOptions": [
{
"MutualAuthentication": {
"ClientRootCertificateChainArn": {
"Type": "AWS::EC2::ClientVpnEndpoint",
"Properties": {
"AuthenticationOptions": [
{
"MutualAuthentication": {
"ClientRootCertificateChainArn": "arn:aws:acm:us-east-1:981237193288:certificate/10a8404f-9bc4-444b-bcd6-096d5ae0e71f"
"Type" : "AWS::EC2::ClientVpnEndpoint",
"Properties" : {
"AuthenticationOptions" : [
{
"MutualAuthentication" : {
"ClientRootCertificateChainArn" : { "Ref" : "CERTParameter" }
Parameters
-
ClientCidrBlock
required - String -
ClientConnectOptions
optional - ClientConnectOptions -
Description
optional - String -
TagSpecifications
optional - List of TagSpecification -
AuthenticationOptions
required - List of ClientAuthenticationRequest -
ServerCertificateArn
required - String -
DnsServers
optional - List -
SecurityGroupIds
optional - List -
ConnectionLogOptions
required - ConnectionLogOptions -
SplitTunnel
optional - Boolean -
VpcId
optional - String -
SelfServicePortal
optional - String -
TransportProtocol
optional - String -
VpnPort
optional - Integer
Explanation in CloudFormation Registry
Specifies a Client VPN endpoint. A Client VPN endpoint is the resource you create and configure to enable and manage client VPN sessions. It is the destination endpoint at which all client VPN sessions are terminated.
Frequently asked questions
What is AWS Amazon EC2 Client VPN Endpoint?
AWS Amazon EC2 Client VPN Endpoint 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 Endpoint?
For Terraform, the simplyviki/terr1, arthurngatat/Tia-first-copy and ataylor05/terraform source code examples are useful. See the Terraform Example section for further details.
For CloudFormation, the suprajagantena/HA, craighagan/ClientVPNSAMLIDP and noname-work/aws-cloudformation source code examples are useful. See the CloudFormation Example section for further details.