Skip to content

Commit 56e7518

Browse files
authored
Merge pull request #5 from unifio/cert-gen-bug
Resolved regression in user data template and updated tests
2 parents b5f7f74 + b801448 commit 56e7518

File tree

8 files changed

+184
-3
lines changed

8 files changed

+184
-3
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
- Fix the 4 subnet fixed mapping
88
- Fill in some examples
99

10+
## 0.0.7
11+
12+
#### BUG FIXES:
13+
- Resolved regression in certificate generator user data template.
14+
1015
## 0.0.6
1116

1217
#### BREAKING CHANGES:

Rakefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ inputs = {
1111
'route_cidrs' => '10.10.0.0/25,10.10.0.128/25,10.10.4.0/25,10.10.4.128/25',
1212
's3_bucket' => 'openvpn-certs',
1313
's3_bucket_prefix' => '20160603',
14+
'openvpn_host' => 'vpn.example.io'
1415
}
1516

1617
task :default => :verify
@@ -23,7 +24,7 @@ task :verify do
2324
vars.push("-var #{var}=\"#{value}\"")
2425
end
2526

26-
['openvpn'].each do |stack|
27+
['server','cert-gen'].each do |stack|
2728
task_args = {:stack => stack, :args => vars.join(' ')}
2829
Rake::Task['clean'].execute(Rake::TaskArguments.new(task_args.keys, task_args.values))
2930
Rake::Task['plan'].execute(Rake::TaskArguments.new(task_args.keys, task_args.values))

examples/cert-gen/main.tf

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# OpenVPN Certificate Generator
2+
3+
## Configures AWS provider
4+
provider "aws" {
5+
region = "${var.region}"
6+
}
7+
8+
## Creates generator
9+
module "cert_generator" {
10+
source = "../../generate-certs"
11+
12+
# Resource labels
13+
stack_item_label = "${var.stack_item_label}"
14+
stack_item_fullname = "${var.stack_item_fullname}"
15+
16+
# Instance parameters
17+
ami_custom = "${var.ami_custom}"
18+
instance_type = "${var.instance_type}"
19+
key_name = "${var.key_name}"
20+
region = "${var.region}"
21+
subnet = "${element(split(",",var.subnets),0)}"
22+
vpc_id = "${var.vpc_id}"
23+
24+
# Generator parameters
25+
active_clients = "${var.active_clients}"
26+
cert_key_name = "${var.cert_key_name}"
27+
cert_key_size = "${var.cert_key_size}"
28+
force_cert_regen = "${var.force_cert_regen}"
29+
key_city = "${var.key_city}"
30+
key_country = "${var.key_country}"
31+
key_email = "${var.key_email}"
32+
key_org = "${var.key_org}"
33+
key_ou = "${var.key_ou}"
34+
key_province = "${var.key_province}"
35+
openvpn_host = "${var.openvpn_host}"
36+
revoked_clients = "${var.revoked_clients}"
37+
s3_bucket = "${var.s3_bucket}"
38+
s3_bucket_prefix = "${var.s3_bucket_prefix}"
39+
s3_push_dryrun = "${var.s3_push_dryrun}"
40+
}

examples/cert-gen/variables.tf

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
# Input Variables
2+
3+
## Resource tags
4+
variable "stack_item_label" {
5+
type = "string"
6+
description = "Short form identifier for this stack. This value is used to create the 'Name' resource tag for resources created by this stack item, and also serves as a unique key for re-use."
7+
}
8+
9+
variable "stack_item_fullname" {
10+
type = "string"
11+
description = "Long form descriptive name for this stack item. This value is used to create the 'application' resource tag for resources created by this stack item."
12+
}
13+
14+
## Instance parameters
15+
variable "ami_custom" {
16+
type = "string"
17+
description = "Custom AMI to utilize"
18+
default = ""
19+
}
20+
21+
variable "instance_type" {
22+
type = "string"
23+
description = "EC2 instance type to associate with the launch configuration."
24+
default = "t2.medium"
25+
}
26+
27+
variable "key_name" {
28+
type = "string"
29+
description = "SSH key pair to associate with the launch configuration."
30+
}
31+
32+
variable "region" {
33+
type = "string"
34+
description = "AWS region to be utilized."
35+
}
36+
37+
variable "subnets" {
38+
tpye = "string"
39+
description = "List of VPC subnets eligible for instance deployment"
40+
}
41+
42+
variable "vpc_id" {
43+
type = "string"
44+
description = "ID of the target VPC."
45+
}
46+
47+
## Generator parameters
48+
49+
### Order matters. Do not remove clients here, use the 'revoked_clients' list instead.
50+
variable "active_clients" {
51+
type = "string"
52+
description = "Comma delimited list of active clients"
53+
default = ""
54+
}
55+
56+
variable "cert_key_name" {
57+
type = "string"
58+
default = "EasyRSA"
59+
}
60+
61+
variable "cert_key_size" {
62+
type = "string"
63+
default = 4096
64+
}
65+
66+
variable "force_cert_regen" {
67+
type = "string"
68+
description = "Force all certificates to be regenerated."
69+
default = false
70+
}
71+
72+
variable "key_city" {
73+
type = "string"
74+
description = "City to be associated with the certificate."
75+
default = "San Francisco"
76+
}
77+
78+
variable "key_country" {
79+
type = "string"
80+
description = "Country to be associated with the certificate."
81+
default = "US"
82+
}
83+
84+
variable "key_email" {
85+
type = "string"
86+
description = "Email address to be associated with the certificate."
87+
default = "support@example.io"
88+
}
89+
90+
variable "key_org" {
91+
type = "string"
92+
description = "Organization to be associated with the certificate."
93+
default = "Example, Inc."
94+
}
95+
96+
variable "key_ou" {
97+
type = "string"
98+
description = "Organizational unit to be associated with the certificate."
99+
default = "Operations"
100+
}
101+
102+
variable "key_province" {
103+
type = "string"
104+
description = "Province to be associated with the certificate."
105+
default = "CA"
106+
}
107+
108+
variable "openvpn_host" {
109+
type = "string"
110+
description = "Publicly accessible hostname of the OpenVPN server(s)."
111+
}
112+
113+
# Comma delimited list
114+
variable "revoked_clients" {
115+
type = "string"
116+
description = "Comma delimited list of existing clients who are to have their privileges revoked."
117+
default = ""
118+
}
119+
120+
variable "s3_bucket" {
121+
type = "string"
122+
description = "The S3 bucket where certificate and configuration are stored."
123+
}
124+
125+
### Do not include the trailing slash
126+
variable "s3_bucket_prefix" {
127+
type = "string"
128+
description = "The S3 bucket prefix. Certificates and configuration will be sourced from the root if not configured."
129+
default = ""
130+
}
131+
132+
variable "s3_push_dryrun" {
133+
type = "string"
134+
description = "Dry-run push of certificates into s3 location"
135+
default = false
136+
}

examples/openvpn/outputs.tf

Lines changed: 0 additions & 1 deletion
This file was deleted.
File renamed without changes.
File renamed without changes.

generate-certs/templates/user_data.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ runcmd:
55
- echo "S3_REGION=\"${region}\"" > /etc/default/openvpn-cert-generator
66
- echo "S3_CERT_ROOT_PATH=\"s3://${replace(s3_bucket,"/(\/)+$/","")}/\"" >> /etc/default/openvpn-cert-generator
77
- echo "KEY_SIZE=${cert_key_size}" >> /etc/default/openvpn-cert-generator
8-
- echo "S3_DIR_OVERRIDE=\"${replace(s3_bucket_prefix,"/^(\/)+|(\/)+$/","")}\"" >> /etc/default/openvpn-cert-generator
8+
- echo "S3_DIR_OVERRIDE=\"${replace(s3_dir_override,"/^(\/)+|(\/)+$/","")}\"" >> /etc/default/openvpn-cert-generator
99
- echo "KEY_CITY=\"${key_city}\"" >> /etc/default/openvpn-cert-generator
1010
- echo "KEY_ORG=\"${key_org}\"" >> /etc/default/openvpn-cert-generator
1111
- echo "KEY_EMAIL=\"${key_email}\"" >> /etc/default/openvpn-cert-generator

0 commit comments

Comments
 (0)