Skip to content

Commit d1c113f

Browse files
committed
Added a flaf to create virtual private gateway
1 parent e7bde63 commit d1c113f

File tree

6 files changed

+73
-18
lines changed

6 files changed

+73
-18
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,22 @@
22

33
[![Quality gate](https://sonarcloud.io/api/project_badges/quality_gate?project=sourcefuse_terraform-aws-arc-vpn)](https://sonarcloud.io/summary/new_code?id=sourcefuse_terraform-aws-arc-vpn)
44

5-
[![Snyk](https://github.com/sourcefuse/terraform-aws-refarch-vpn/actions/workflows/test.yml/badge.svg)](https://github.com/sourcefuse/terraform-aws-refarch-vpn/actions/workflows/test.yml)
5+
[![Snyk](https://github.com/sourcefuse/terraform-aws-refarch-vpn/actions/workflows/test.yml/badge.svg)](https://github.com/sourcefuse/c/actions/workflows/test.yml)
66

77
## Overview
88

99
SourceFuse AWS Reference Architecture (ARC) Terraform module for managing a Client VPN.
1010

11+
For more information about this repository and its usage, please see [Terraform AWS ARC CloudFront Usage Guide](https://github.com/sourcefuse/terraform-aws-arc-vpn/blob/main/docs/module-usage-guide/README.md).
12+
1113
## Usage
1214

1315
To see a full example, check out the [main.tf](https://github.com/sourcefuse/terraform-aws-arc-vpn/blob/main/example/main.tf) file in the example folder.
1416

15-
```hcl
17+
```tcl
1618
module "this" {
1719
source = "sourcefuse/arc-vpn/aws"
18-
version = "0.0.4"
20+
version = "1.0.0"
1921
vpc_id = data.aws_vpc.this.id
2022
2123
authentication_options_type = "certificate-authentication"

docs/module-usage-guide/README.md

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44

55
### Purpose of the Document
66

7-
This document provides guidelines and instructions for users looking to implement Terraform ARC module for managing a Client VPN.
7+
This document provides guidelines and instructions for users looking to implement Terraform ARC module for managing a AWS Client VPN.
8+
9+
#### What is AWS Client VPN ?
10+
AWS Client VPN is a managed remote access VPN solution used by your remote workforce to securely access resources within both AWS and your on-premises network. Fully elastic, it automatically scales up, or down, based on demand.
811

912
### Module Overview
1013

@@ -24,7 +27,7 @@ Before using this module, ensure you have the following:
2427

2528
To use the module in your Terraform configuration, include the following source block:
2629

27-
```hcl
30+
```tcl
2831
module "client_vpn" {
2932
source = "sourcefuse/arc-vpn/aws"
3033
version = "0.0.8"
@@ -48,7 +51,9 @@ Integrate the module with your existing Terraform mono repo configuration, follo
4851

4952
### Required AWS Permissions
5053

51-
Ensure that the AWS credentials used to execute Terraform have the necessary permissions to create Client VPN.
54+
Ensure that the AWS credentials used to execute Terraform have the necessary permissions to create
55+
- Client VPN Endpoint
56+
- Virtual Private Gateway
5257

5358
## Module Configuration
5459

@@ -68,28 +73,49 @@ For basic usage, see the [example](https://github.com/sourcefuse/terraform-aws-a
6873

6974
This example will create:
7075

71-
Self-Signed Certificate Authority (CA) Creation: It creates a self-signed CA certificate using the cloudposse/terraform-aws-ssm-tls-self-signed-cert module. The certificate is stored in AWS SSM (Systems Manager).
76+
- Self-Signed Certificate Authority (CA) Creation: It creates a self-signed CA certificate using the cloudposse/terraform-aws-ssm-tls-self-signed-cert module. The certificate is stored in AWS SSM (Systems Manager).
7277

73-
Self-Signed Root Certificate Creation: It creates a self-signed root certificate using the cloudposse/terraform-aws-ssm-tls-self-signed-cert module. This certificate is signed by the previously created CA certificate.
78+
- Self-Signed Root Certificate Creation: It creates a self-signed root certificate using the cloudposse/terraform-aws-ssm-tls-self-signed-cert module. This certificate is signed by the previously created CA certificate.
7479

75-
VPN Setup: It uses the sourcefuse/arc-vpn/aws module to create a VPN setup. This includes:
80+
- VPN Setup: It uses the sourcefuse/arc-vpn/aws module to create a VPN setup. This includes:
7681

77-
Setting up certificate-based authentication using the self-signed root certificate.
82+
- Certificate-based authentication using the self-signed root certificate.
7883

79-
Authorizing all groups to access the VPN.
84+
- Authorize all groups to access the VPN.
8085

81-
Specifying the private subnets where the VPN endpoints will be created.
86+
- Specifying the private subnets where the VPN endpoints will be created.
8287

83-
Specifying the target network CIDR block, which is the VPC's CIDR block.
88+
- Specifying the target network CIDR block, which is the VPC's CIDR block.
8489

85-
Creating a self-signed server certificate.
90+
- Created a self-signed server certificate.
8691

87-
Setting up the client VPN with a specified client CIDR block, VPN name, and VPN gateway name.
92+
- Setting up the client VPN with a specified client CIDR block, VPN name, and VPN gateway name.
8893

8994
The VPN setup allows users to securely connect to the AWS VPC from anywhere, using the created client VPN. The self-signed certificates are used to authenticate the users.
95+
96+
### How to create AWS Client VPN file
97+
- Download and install AWS Client VPN Application [download](https://aws.amazon.com/vpn/client-vpn-download/)
98+
- Download the AWS Client VPN Configuration File
99+
- Navigate to `VPC` > `Client VPN endpoints`
100+
- Select the endpoint and click `Download Client Configuration`
101+
- Incase authentication is using certificate
102+
- Open the Client Configuration file in an editor.
103+
- Append the certificate data as show below to the configuration file
104+
```
105+
<cert>
106+
Copy from SSM PARAM self-signed-cert-ca.pem
107+
</cert>
108+
109+
<key>
110+
Copy from SSM PARAM self-signed-cert-ca.key
111+
</key>
112+
```
113+
114+
115+
90116
### Tips and Recommendations
91117

92-
The module focuses on setting up AWS Client VPN. Adjust the configuration parameters as needed for your specific use case.
118+
To authenticate the AWS Client VPN, integration with Active Directory (AD) is possible.
93119

94120
## Troubleshooting
95121

example/.terraform.lock.hcl

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/main.tf

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,16 @@ data "aws_subnets" "private" {
6060
## certs
6161
################################################################################
6262
module "self_signed_cert_ca" {
63-
source = "git::https://github.com/cloudposse/terraform-aws-ssm-tls-self-signed-cert.git?ref=1.3.0"
63+
source = "git::https://github.com/cloudposse/terraform-aws-ssm-tls- self-signed-cert.git?ref=1.3.0"
6464

6565
attributes = ["self", "signed", "cert", "ca"]
6666

67+
enabled = true
68+
69+
namespace = var.namespace
70+
stage = var.environment
71+
name = "demo"
72+
6773
secret_path_format = var.secret_path_format
6874

6975
subject = {
@@ -94,8 +100,14 @@ data "aws_ssm_parameter" "ca_key" {
94100
module "self_signed_cert_root" {
95101
source = "git::https://github.com/cloudposse/terraform-aws-ssm-tls-self-signed-cert.git?ref=1.3.0"
96102

103+
enabled = true
104+
97105
attributes = ["self", "signed", "cert", "root"]
98106

107+
namespace = var.namespace
108+
stage = var.environment
109+
name = "demo"
110+
99111
secret_path_format = var.secret_path_format
100112

101113
subject = {
@@ -123,12 +135,13 @@ module "self_signed_cert_root" {
123135
}
124136
}
125137

138+
126139
################################################################################
127140
## vpn
128141
################################################################################
129142
module "vpn" {
130143
source = "sourcefuse/arc-vpn/aws"
131-
version = "0.0.4"
144+
//version = "1.0.0" # pin the correct version
132145

133146
vpc_id = data.aws_vpc.this.id
134147

@@ -152,5 +165,7 @@ module "vpn" {
152165
client_vpn_name = "${var.namespace}-${var.environment}-client-vpn-example"
153166
client_vpn_gateway_name = "${var.namespace}-${var.environment}-vpn-gateway-example"
154167

168+
create_vpn_gateway = true
169+
155170
tags = module.tags.tags
156171
}

main.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ module "self_signed_cert" {
6767
attributes = ["self", "signed", "cert", "server"]
6868
secret_path_format = var.self_signed_server_cert_secret_path_format
6969

70+
name = var.client_vpn_name
71+
72+
7073
subject = {
7174
common_name = var.self_signed_server_cert_server_common_name
7275
organization = var.self_signed_server_cert_organization_name
@@ -93,6 +96,7 @@ module "self_signed_cert" {
9396
## vpn
9497
################################################################################
9598
resource "aws_vpn_gateway" "this" {
99+
count = var.create_vpn_gateway ? 1 : 0
96100
vpc_id = var.vpc_id
97101

98102
tags = merge(var.tags, tomap({

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,3 +261,9 @@ variable "client_vpn_authorize_all_groups" {
261261
description = "Indicates whether the authorization rule grants access to all clients. One of access_group_id or authorize_all_groups must be set."
262262
default = true
263263
}
264+
265+
variable "create_vpn_gateway" {
266+
type = bool
267+
description = "Whether to create VPN Gateway, as for a VPC only one Gateway is allowed"
268+
default = true
269+
}

0 commit comments

Comments
 (0)