Skip to content

Commit

Permalink
Small fixes (region removal, formatting, docs) (#19)
Browse files Browse the repository at this point in the history
* Remove region and add types

* Fix readme formatting

* Update versions.tf

* Test formatting and context

* Auto Format

* Use enabled flag

* Update outputs.tf

* Count logic and var.region removal fixes

* Use renamed module in outputs

* Bring back ssm param depends_on

* Missing tags and fixed outputs

* make pr/readme

* Auto Format

* Removed basic_constraints and validity, used retention in days

* Auto Format

Co-authored-by: cloudpossebot <[email protected]>
  • Loading branch information
nitrocode and cloudpossebot authored Dec 2, 2021
1 parent a167f96 commit 543b6ae
Show file tree
Hide file tree
Showing 9 changed files with 177 additions and 244 deletions.
131 changes: 61 additions & 70 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,65 +99,59 @@ For automated tests of the complete example using [bats](https://github.com/bats
(which tests and deploys the example on AWS), see [test](test).

```hcl
module "vpc_target" {
source = "cloudposse/vpc/aws"
version = "0.21.1"
cidr_block = "172.16.0.0/16"
context = module.this.context
}
module "vpc_client" {
source = "cloudposse/vpc/aws"
version = "0.21.1"
cidr_block = "172.31.0.0/16"
context = module.this.context
}
module "subnets" {
source = "cloudposse/dynamic-subnets/aws"
version = "0.39.3"
availability_zones = var.availability_zones
vpc_id = module.vpc_target.vpc_id
igw_id = module.vpc_target.igw_id
cidr_block = module.vpc_target.vpc_cidr_block
nat_gateway_enabled = true
nat_instance_enabled = false
context = module.this.context
}
module "example" {
source = "cloudposse/ec2-client-vpn"
region = var.region
client_cidr = module.vpc_client.vpc_cidr_block
organization_name = var.organization_name
logging_enabled = var.logging_enabled
retention_in_days = var.retention_in_days
internet_access_enabled = var.internet_access_enabled
associated_subnets = module.subnets.private_subnet_ids
authorization_rules = var.authorization_rules
additional_routes = [
{
destination_cidr_block = "0.0.0.0/0"
description = "Internet Route"
target_vpc_subnet_id = element(module.subnets.private_subnet_ids, 0)
}
]
}
module "vpc_target" {
source = "cloudposse/vpc/aws"
version = "0.21.1"
cidr_block = "172.16.0.0/16"
context = module.this.context
}
module "vpc_client" {
source = "cloudposse/vpc/aws"
version = "0.21.1"
cidr_block = "172.31.0.0/16"
context = module.this.context
}
module "subnets" {
source = "cloudposse/dynamic-subnets/aws"
version = "0.39.3"
availability_zones = var.availability_zones
vpc_id = module.vpc_target.vpc_id
igw_id = module.vpc_target.igw_id
cidr_block = module.vpc_target.vpc_cidr_block
nat_gateway_enabled = true
nat_instance_enabled = false
context = module.this.context
}
module "ec2_client_vpn" {
source = "cloudposse/ec2-client-vpn/aws"
# Cloud Posse recommends pinning every module to a specific version
# version = "x.x.x"
client_cidr = module.vpc_client.vpc_cidr_block
organization_name = var.organization_name
logging_enabled = var.logging_enabled
retention_in_days = var.retention_in_days
internet_access_enabled = var.internet_access_enabled
associated_subnets = module.subnets.private_subnet_ids
authorization_rules = var.authorization_rules
additional_routes = [
{
destination_cidr_block = "0.0.0.0/0"
description = "Internet Route"
target_vpc_subnet_id = element(module.subnets.private_subnet_ids, 0)
}
]
}
```


Expand Down Expand Up @@ -190,8 +184,6 @@ Available targets:
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.14 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.0 |
| <a name="requirement_awsutils"></a> [awsutils](#requirement\_awsutils) | >= 0.8.0 |
| <a name="requirement_local"></a> [local](#requirement\_local) | >= 1.2 |
| <a name="requirement_null"></a> [null](#requirement\_null) | >= 2.0 |

## Providers

Expand Down Expand Up @@ -235,14 +227,13 @@ Available targets:
| <a name="input_attributes"></a> [attributes](#input\_attributes) | ID element. Additional attributes (e.g. `workers` or `cluster`) to add to `id`,<br>in the order they appear in the list. New attributes are appended to the<br>end of the list. The elements of the list are joined by the `delimiter`<br>and treated as a single ID element. | `list(string)` | `[]` | no |
| <a name="input_authentication_type"></a> [authentication\_type](#input\_authentication\_type) | One of `certificate-authentication` or `federated-authentication` | `string` | `"certificate-authentication"` | no |
| <a name="input_authorization_rules"></a> [authorization\_rules](#input\_authorization\_rules) | List of objects describing the authorization rules for the client vpn | <pre>list(object({<br> name = string<br> access_group_id = string<br> authorize_all_groups = bool<br> description = string<br> target_network_cidr = string<br> }))</pre> | n/a | yes |
| <a name="input_basic_constraints"></a> [basic\_constraints](#input\_basic\_constraints) | The [basic constraints](https://datatracker.ietf.org/doc/html/rfc5280#section-4.2.1.9) of the issued certificate.<br>Currently, only the `CA` constraint (which identifies whether the subject of the certificate is a CA) can be set.<br>Defaults to this certificate not being a CA. | <pre>object({<br> ca = bool<br> })</pre> | <pre>{<br> "ca": false<br>}</pre> | no |
| <a name="input_ca_common_name"></a> [ca\_common\_name](#input\_ca\_common\_name) | Unique Common Name for CA self-signed certificate | `string` | `null` | no |
| <a name="input_client_cidr"></a> [client\_cidr](#input\_client\_cidr) | Network CIDR to use for clients | `any` | n/a | yes |
| <a name="input_client_cidr"></a> [client\_cidr](#input\_client\_cidr) | Network CIDR to use for clients | `string` | n/a | yes |
| <a name="input_client_conf_tmpl_path"></a> [client\_conf\_tmpl\_path](#input\_client\_conf\_tmpl\_path) | Path to template file of vpn client exported configuration. Path is relative to ${path.module} | `string` | `null` | no |
| <a name="input_context"></a> [context](#input\_context) | Single object for setting entire context at once.<br>See description of individual variables for details.<br>Leave string and numeric variables as `null` to use default value.<br>Individual variable settings (non-null) override settings in context object,<br>except for attributes, tags, and additional\_tag\_map, which are merged. | `any` | <pre>{<br> "additional_tag_map": {},<br> "attributes": [],<br> "delimiter": null,<br> "descriptor_formats": {},<br> "enabled": true,<br> "environment": null,<br> "id_length_limit": null,<br> "label_key_case": null,<br> "label_order": [],<br> "label_value_case": null,<br> "labels_as_tags": [<br> "unset"<br> ],<br> "name": null,<br> "namespace": null,<br> "regex_replace_chars": null,<br> "stage": null,<br> "tags": {},<br> "tenant": null<br>}</pre> | no |
| <a name="input_delimiter"></a> [delimiter](#input\_delimiter) | Delimiter to be used between ID elements.<br>Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. | `string` | `null` | no |
| <a name="input_descriptor_formats"></a> [descriptor\_formats](#input\_descriptor\_formats) | Describe additional descriptors to be output in the `descriptors` output map.<br>Map of maps. Keys are names of descriptors. Values are maps of the form<br>`{<br> format = string<br> labels = list(string)<br>}`<br>(Type is `any` so the map values can later be enhanced to provide additional options.)<br>`format` is a Terraform format string to be passed to the `format()` function.<br>`labels` is a list of labels, in order, to pass to `format()` function.<br>Label values will be normalized before being passed to `format()` so they will be<br>identical to how they appear in `id`.<br>Default is `{}` (`descriptors` output will be empty). | `any` | `{}` | no |
| <a name="input_dns_servers"></a> [dns\_servers](#input\_dns\_servers) | (Optional) Information about the DNS servers to be used for DNS resolution. A Client VPN endpoint can have up to two DNS servers. If no DNS server is specified, the DNS address of the VPC that is to be associated with Client VPN endpoint is used as the DNS server. | `list(string)` | `[]` | no |
| <a name="input_dns_servers"></a> [dns\_servers](#input\_dns\_servers) | Information about the DNS servers to be used for DNS resolution. A Client VPN endpoint can have up to two DNS servers. If no DNS server is specified, the DNS address of the VPC that is to be associated with Client VPN endpoint is used as the DNS server. | `list(string)` | `[]` | no |
| <a name="input_enabled"></a> [enabled](#input\_enabled) | Set to false to prevent the module from creating any resources | `bool` | `null` | no |
| <a name="input_environment"></a> [environment](#input\_environment) | ID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT' | `string` | `null` | no |
| <a name="input_export_client_certificate"></a> [export\_client\_certificate](#input\_export\_client\_certificate) | Flag to determine whether to export the client certificate with the VPN configuration | `bool` | `false` | no |
Expand All @@ -257,17 +248,15 @@ Available targets:
| <a name="input_namespace"></a> [namespace](#input\_namespace) | ID element. Usually an abbreviation of your organization name, e.g. 'eg' or 'cp', to help ensure generated IDs are globally unique | `string` | `null` | no |
| <a name="input_organization_name"></a> [organization\_name](#input\_organization\_name) | Name of organization to use in private certificate | `string` | n/a | yes |
| <a name="input_regex_replace_chars"></a> [regex\_replace\_chars](#input\_regex\_replace\_chars) | Terraform regular expression (regex) string.<br>Characters matching the regex will be removed from the ID elements.<br>If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no |
| <a name="input_region"></a> [region](#input\_region) | VPN Endpoints are region-specific. This identifies the region. AWS Region | `string` | n/a | yes |
| <a name="input_retention_in_days"></a> [retention\_in\_days](#input\_retention\_in\_days) | Number of days you want to retain log events in the log group | `string` | `"30"` | no |
| <a name="input_retention_in_days"></a> [retention\_in\_days](#input\_retention\_in\_days) | Number of days you want to retain log events in the log group | `number` | `"30"` | no |
| <a name="input_root_common_name"></a> [root\_common\_name](#input\_root\_common\_name) | Unique Common Name for Root self-signed certificate | `string` | `null` | no |
| <a name="input_saml_metadata_document"></a> [saml\_metadata\_document](#input\_saml\_metadata\_document) | Optional SAML metadata document. Must include this or `saml_provider_arn` | `string` | `null` | no |
| <a name="input_saml_provider_arn"></a> [saml\_provider\_arn](#input\_saml\_provider\_arn) | Optional SAML provider ARN. Must include this or `saml_metadata_document` | `string` | `null` | no |
| <a name="input_server_common_name"></a> [server\_common\_name](#input\_server\_common\_name) | Unique Common Name for Server self-signed certificate | `string` | `null` | no |
| <a name="input_split_tunnel"></a> [split\_tunnel](#input\_split\_tunnel) | (Optional) Indicates whether split-tunnel is enabled on VPN endpoint. Default value is false. | `bool` | `false` | no |
| <a name="input_split_tunnel"></a> [split\_tunnel](#input\_split\_tunnel) | Indicates whether split-tunnel is enabled on VPN endpoint. Default value is false. | `bool` | `false` | no |
| <a name="input_stage"></a> [stage](#input\_stage) | ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no |
| <a name="input_tags"></a> [tags](#input\_tags) | Additional tags (e.g. `{'BusinessUnit': 'XYZ'}`).<br>Neither the tag keys nor the tag values will be modified by this module. | `map(string)` | `{}` | no |
| <a name="input_tenant"></a> [tenant](#input\_tenant) | ID element \_(Rarely used, not included by default)\_. A customer identifier, indicating who this instance of a resource is for | `string` | `null` | no |
| <a name="input_validity"></a> [validity](#input\_validity) | Validity settings for the issued certificate:<br>`duration_hours`: The number of hours from issuing the certificate until it becomes invalid.<br>`early_renewal_hours`: If set, the resource will consider the certificate to have expired the given number of hours before its actual expiry time (see: [self\_signed\_cert.early\_renewal\_hours](https://registry.terraform.io/providers/hashicorp/tls/latest/docs/resources/self_signed_cert#early_renewal_hours)).<br>Defaults to 10 years and no early renewal hours. | <pre>object({<br> duration_hours = number<br> early_renewal_hours = number<br> })</pre> | <pre>{<br> "duration_hours": 87600,<br> "early_renewal_hours": null<br>}</pre> | no |
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | ID of VPC to attach VPN to | `string` | n/a | yes |

## Outputs
Expand Down Expand Up @@ -439,14 +428,16 @@ Check out [our other projects][github], [follow us on twitter][twitter], [apply
### Contributors

<!-- markdownlint-disable -->
| [![Erik Osterman][osterman_avatar]][osterman_homepage]<br/>[Erik Osterman][osterman_homepage] | [![Leo Przybylski][r351574nc3_avatar]][r351574nc3_homepage]<br/>[Leo Przybylski][r351574nc3_homepage] |
|---|---|
| [![Erik Osterman][osterman_avatar]][osterman_homepage]<br/>[Erik Osterman][osterman_homepage] | [![Leo Przybylski][r351574nc3_avatar]][r351574nc3_homepage]<br/>[Leo Przybylski][r351574nc3_homepage] | [![RB][nitrocode_avatar]][nitrocode_homepage]<br/>[RB][nitrocode_homepage] |
|---|---|---|
<!-- markdownlint-restore -->

[osterman_homepage]: https://github.com/osterman
[osterman_avatar]: https://img.cloudposse.com/150x150/https://github.com/osterman.png
[r351574nc3_homepage]: https://github.com/r351574nc3
[r351574nc3_avatar]: https://img.cloudposse.com/150x150/https://github.com/r351574nc3.png
[nitrocode_homepage]: https://github.com/nitrocode
[nitrocode_avatar]: https://img.cloudposse.com/150x150/https://github.com/nitrocode.png

[![README Footer][readme_footer_img]][readme_footer_link]
[![Beacon][beacon]][website]
Expand Down
114 changes: 55 additions & 59 deletions README.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,65 +68,59 @@ usage: |-
(which tests and deploys the example on AWS), see [test](test).
```hcl
module "vpc_target" {
source = "cloudposse/vpc/aws"
version = "0.21.1"
cidr_block = "172.16.0.0/16"
context = module.this.context
}
module "vpc_client" {
source = "cloudposse/vpc/aws"
version = "0.21.1"
cidr_block = "172.31.0.0/16"
context = module.this.context
}
module "subnets" {
source = "cloudposse/dynamic-subnets/aws"
version = "0.39.3"
availability_zones = var.availability_zones
vpc_id = module.vpc_target.vpc_id
igw_id = module.vpc_target.igw_id
cidr_block = module.vpc_target.vpc_cidr_block
nat_gateway_enabled = true
nat_instance_enabled = false
context = module.this.context
}
module "example" {
source = "cloudposse/ec2-client-vpn"
region = var.region
client_cidr = module.vpc_client.vpc_cidr_block
organization_name = var.organization_name
logging_enabled = var.logging_enabled
retention_in_days = var.retention_in_days
internet_access_enabled = var.internet_access_enabled
associated_subnets = module.subnets.private_subnet_ids
authorization_rules = var.authorization_rules
additional_routes = [
{
destination_cidr_block = "0.0.0.0/0"
description = "Internet Route"
target_vpc_subnet_id = element(module.subnets.private_subnet_ids, 0)
}
]
}
module "vpc_target" {
source = "cloudposse/vpc/aws"
version = "0.21.1"
cidr_block = "172.16.0.0/16"
context = module.this.context
}
module "vpc_client" {
source = "cloudposse/vpc/aws"
version = "0.21.1"
cidr_block = "172.31.0.0/16"
context = module.this.context
}
module "subnets" {
source = "cloudposse/dynamic-subnets/aws"
version = "0.39.3"
availability_zones = var.availability_zones
vpc_id = module.vpc_target.vpc_id
igw_id = module.vpc_target.igw_id
cidr_block = module.vpc_target.vpc_cidr_block
nat_gateway_enabled = true
nat_instance_enabled = false
context = module.this.context
}
module "ec2_client_vpn" {
source = "cloudposse/ec2-client-vpn/aws"
# Cloud Posse recommends pinning every module to a specific version
# version = "x.x.x"
client_cidr = module.vpc_client.vpc_cidr_block
organization_name = var.organization_name
logging_enabled = var.logging_enabled
retention_in_days = var.retention_in_days
internet_access_enabled = var.internet_access_enabled
associated_subnets = module.subnets.private_subnet_ids
authorization_rules = var.authorization_rules
additional_routes = [
{
destination_cidr_block = "0.0.0.0/0"
description = "Internet Route"
target_vpc_subnet_id = element(module.subnets.private_subnet_ids, 0)
}
]
}
```
# Example usage
Expand All @@ -149,3 +143,5 @@ contributors:
github: "osterman"
- name: "Leo Przybylski"
github: "r351574nc3"
- name: "RB"
github: "nitrocode"
Loading

0 comments on commit 543b6ae

Please sign in to comment.