terrafying-components 1.7.9 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/terrafying/components/letsencrypt.rb +33 -33
- data/lib/terrafying/components/version.rb +1 -1
- data/lib/terrafying/components/vpn.rb +0 -26
- metadata +2 -4
- data/lib/terrafying/components/support/deregister-vpn +0 -48
- data/lib/terrafying/components/support/register-vpn +0 -46
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55faf0808fc9982431b901ab4a2bf8faedf8eb471f040340b1075e5982d61aa0
|
4
|
+
data.tar.gz: f81aec1f8b7236d05d9e234531827c9f7f05e9e06c2e927b42368e5d5cba3bf7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c0012e3b2469b6de2cc9c9de6c8d4ce995e07d3f5b3ec17ad3cfd5e78f9c5b08d31784f6d538963623c46ee6c81c3a81a27ba6f1dbe16a73dbda91957a0d82e
|
7
|
+
data.tar.gz: d7eba0ca0c56aae91f8cab7b9bdd726cebe07ed1a3de09645667d1424583d2afa97dbbd31b857bd35106cc6d37e09fec574602f9c1ae8dd30823e6252411e4ff
|
@@ -1,34 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
|
2
3
|
require 'terrafying/components/ca'
|
3
4
|
require 'terrafying/generator'
|
4
5
|
require 'open-uri'
|
5
6
|
module Terrafying
|
6
|
-
|
7
7
|
module Components
|
8
|
-
|
9
8
|
class LetsEncrypt < Terrafying::Context
|
10
9
|
|
11
10
|
attr_reader :name, :source
|
12
11
|
|
13
|
-
PROVIDERS = {
|
14
|
-
staging: {
|
15
|
-
server_url: 'https://acme-staging.api.letsencrypt.org/directory',
|
16
|
-
ca_cert: 'https://letsencrypt.org/certs/fakeleintermediatex1.pem'
|
17
|
-
},
|
18
|
-
live: {
|
19
|
-
server_url: 'https://acme-v01.api.letsencrypt.org/directory',
|
20
|
-
ca_cert: 'https://letsencrypt.org/certs/lets-encrypt-x3-cross-signed.pem.txt'
|
21
|
-
}
|
22
|
-
}.freeze
|
23
|
-
|
24
12
|
include CA
|
25
13
|
|
26
14
|
def self.create(name, bucket, options={})
|
27
15
|
LetsEncrypt.new.create name, bucket, options
|
28
16
|
end
|
29
17
|
|
30
|
-
def initialize
|
18
|
+
def initialize
|
31
19
|
super
|
20
|
+
@acme_providers = setup_providers
|
21
|
+
end
|
22
|
+
|
23
|
+
def setup_providers
|
24
|
+
{
|
25
|
+
staging: {
|
26
|
+
ref: provider(:acme, alias: :staging, server_url: 'https://acme-staging-v02.api.letsencrypt.org/directory'),
|
27
|
+
ca_cert: 'https://letsencrypt.org/certs/fakeleintermediatex1.pem'
|
28
|
+
},
|
29
|
+
live: {
|
30
|
+
ref: provider(:acme, alias: :live, server_url: 'https://acme-v02.api.letsencrypt.org/directory'),
|
31
|
+
ca_cert: 'https://letsencrypt.org/certs/lets-encrypt-x3-cross-signed.pem.txt'
|
32
|
+
}
|
33
|
+
}
|
32
34
|
end
|
33
35
|
|
34
36
|
def create(name, bucket, options={})
|
@@ -42,9 +44,8 @@ module Terrafying
|
|
42
44
|
@name = name
|
43
45
|
@bucket = bucket
|
44
46
|
@prefix = options[:prefix]
|
45
|
-
@
|
47
|
+
@acme_provider = @acme_providers[options[:provider]]
|
46
48
|
|
47
|
-
provider :acme, {}
|
48
49
|
provider :tls, {}
|
49
50
|
|
50
51
|
resource :tls_private_key, "#{@name}-account", {
|
@@ -52,31 +53,31 @@ module Terrafying
|
|
52
53
|
ecdsa_curve: "P384",
|
53
54
|
}
|
54
55
|
|
55
|
-
|
56
|
+
resource :acme_registration, "#{@name}-reg", {
|
57
|
+
provider: @acme_provider[:ref],
|
58
|
+
account_key_pem: output_of(:tls_private_key, "#{@name}-account", "private_key_pem"),
|
59
|
+
email_address: options[:email_address],
|
60
|
+
}
|
56
61
|
|
57
|
-
@
|
58
|
-
server_url: @provider[:server_url],
|
59
|
-
account_key_pem: @account_key,
|
60
|
-
email_address: options[:email_address],
|
61
|
-
}
|
62
|
+
@account_key = output_of(:acme_registration, "#{@name}-reg", 'account_key_pem')
|
62
63
|
|
63
64
|
resource :aws_s3_bucket_object, "#{@name}-account", {
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
65
|
+
bucket: @bucket,
|
66
|
+
key: File.join(@prefix, @name, "account.key"),
|
67
|
+
content: @account_key,
|
68
|
+
}
|
68
69
|
|
69
70
|
@ca_cert_acl = options[:public_certificate] ? 'public-read' : 'private'
|
70
71
|
|
71
|
-
open(@
|
72
|
+
open(@acme_provider[:ca_cert], 'rb') do |cert|
|
72
73
|
@ca_cert = cert.read
|
73
74
|
end
|
74
75
|
|
75
76
|
resource :aws_s3_bucket_object, "#{@name}-cert", {
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
77
|
+
bucket: @bucket,
|
78
|
+
key: File.join(@prefix, @name, "ca.cert"),
|
79
|
+
content: @ca_cert,
|
80
|
+
acl: @ca_cert_acl
|
80
81
|
}
|
81
82
|
|
82
83
|
@source = File.join("s3://", @bucket, @prefix, @name, "ca.cert")
|
@@ -118,9 +119,8 @@ module Terrafying
|
|
118
119
|
}
|
119
120
|
|
120
121
|
ctx.resource :acme_certificate, key_ident, {
|
121
|
-
|
122
|
+
provider: @acme_provider[:ref],
|
122
123
|
account_key_pem: @account_key,
|
123
|
-
registration_url: @registration_url,
|
124
124
|
min_days_remaining: options[:min_days_remaining],
|
125
125
|
dns_challenge: {
|
126
126
|
provider: "route53",
|
@@ -122,32 +122,6 @@ module Terrafying
|
|
122
122
|
],
|
123
123
|
}.merge(options[:service])
|
124
124
|
)
|
125
|
-
|
126
|
-
if oauth2_provider[:type] == "azure" and oauth2_provider[:register]
|
127
|
-
|
128
|
-
provider :null, {}
|
129
|
-
|
130
|
-
resource :null_resource, "ad-app-configure", {
|
131
|
-
triggers: {
|
132
|
-
service_resources: @service.resources.join(","),
|
133
|
-
},
|
134
|
-
provisioner: [
|
135
|
-
{
|
136
|
-
"local-exec" => {
|
137
|
-
when: "create",
|
138
|
-
command: "#{File.expand_path(File.dirname(__FILE__))}/support/register-vpn '#{oauth2_provider[:client_id]}' '#{oauth2_provider[:tenant_id]}' '#{@fqdn}'"
|
139
|
-
},
|
140
|
-
},
|
141
|
-
{
|
142
|
-
"local-exec" => {
|
143
|
-
when: "destroy",
|
144
|
-
command: "#{File.expand_path(File.dirname(__FILE__))}/support/deregister-vpn '#{oauth2_provider[:client_id]}' '#{oauth2_provider[:tenant_id]}' '#{@fqdn}'"
|
145
|
-
}
|
146
|
-
},
|
147
|
-
],
|
148
|
-
}
|
149
|
-
end
|
150
|
-
|
151
125
|
self
|
152
126
|
end
|
153
127
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: terrafying-components
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- uSwitch Limited
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-09-
|
11
|
+
date: 2018-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -118,8 +118,6 @@ files:
|
|
118
118
|
- lib/terrafying/components/service.rb
|
119
119
|
- lib/terrafying/components/staticset.rb
|
120
120
|
- lib/terrafying/components/subnet.rb
|
121
|
-
- lib/terrafying/components/support/deregister-vpn
|
122
|
-
- lib/terrafying/components/support/register-vpn
|
123
121
|
- lib/terrafying/components/templates/ignition.yaml
|
124
122
|
- lib/terrafying/components/usable.rb
|
125
123
|
- lib/terrafying/components/version.rb
|
@@ -1,48 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
set -euo pipefail
|
4
|
-
|
5
|
-
app_id="${1}"
|
6
|
-
tenant_id="${2}"
|
7
|
-
new_fqdn="${3}"
|
8
|
-
|
9
|
-
set +u
|
10
|
-
if [[ ! -z $AZURE_USER ]] && [[ ! -z $AZURE_PASSWORD ]]
|
11
|
-
then
|
12
|
-
set -u
|
13
|
-
az login --service-principal \
|
14
|
-
--allow-no-subscriptions \
|
15
|
-
-t "${tenant_id}" \
|
16
|
-
-u "${AZURE_USER}" \
|
17
|
-
-p "${AZURE_PASSWORD}" >/dev/null
|
18
|
-
|
19
|
-
function finish {
|
20
|
-
exit_code=$?
|
21
|
-
az logout
|
22
|
-
exit $exit_code
|
23
|
-
}
|
24
|
-
trap finish EXIT
|
25
|
-
else
|
26
|
-
set -u
|
27
|
-
fi
|
28
|
-
|
29
|
-
app="$(az ad app show --id ${app_id})"
|
30
|
-
|
31
|
-
function urls() {
|
32
|
-
echo ${app} | jq -r '.replyUrls | join("\n")'
|
33
|
-
}
|
34
|
-
|
35
|
-
if [[ $? == 0 ]]
|
36
|
-
then
|
37
|
-
if urls | grep "${new_fqdn}" &>/dev/null
|
38
|
-
then
|
39
|
-
new_reply_urls="$(urls | grep -v "${new_fqdn}" | tr '\n' ' ')"
|
40
|
-
|
41
|
-
az ad app update --id ${app_id} --reply-urls ${new_reply_urls}
|
42
|
-
else
|
43
|
-
echo "Already doesn't contain a reply url for '${new_fqdn}'"
|
44
|
-
fi
|
45
|
-
else
|
46
|
-
echo "App wasn't found"
|
47
|
-
exit 1
|
48
|
-
fi
|
@@ -1,46 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
set -euo pipefail
|
4
|
-
|
5
|
-
app_id="${1}"
|
6
|
-
tenant_id="${2}"
|
7
|
-
new_fqdn="${3}"
|
8
|
-
|
9
|
-
set +u
|
10
|
-
if [[ ! -z $AZURE_USER ]] && [[ ! -z $AZURE_PASSWORD ]]
|
11
|
-
then
|
12
|
-
set -u
|
13
|
-
az login --service-principal \
|
14
|
-
--allow-no-subscriptions \
|
15
|
-
-t "${tenant_id}" \
|
16
|
-
-u "${AZURE_USER}" \
|
17
|
-
-p "${AZURE_PASSWORD}" >/dev/null
|
18
|
-
|
19
|
-
function finish {
|
20
|
-
exit_code=$?
|
21
|
-
az logout
|
22
|
-
exit $exit_code
|
23
|
-
}
|
24
|
-
trap finish EXIT
|
25
|
-
else
|
26
|
-
set -u
|
27
|
-
fi
|
28
|
-
|
29
|
-
app="$(az ad app show --id ${app_id})"
|
30
|
-
|
31
|
-
if [[ $? == 0 ]]
|
32
|
-
then
|
33
|
-
reply_urls="$(echo ${app} | jq -r '.replyUrls | join(" ")')"
|
34
|
-
|
35
|
-
if echo "${reply_urls}" | grep "${new_fqdn}" &>/dev/null
|
36
|
-
then
|
37
|
-
echo "Already contains a reply url for '${new_fqdn}'"
|
38
|
-
else
|
39
|
-
new_reply_urls="${reply_urls} https://${new_fqdn}/oauth2/callback"
|
40
|
-
|
41
|
-
az ad app update --id ${app_id} --reply-urls ${new_reply_urls}
|
42
|
-
fi
|
43
|
-
else
|
44
|
-
echo "App wasn't found"
|
45
|
-
exit 1
|
46
|
-
fi
|