terraspace_plugin_azurerm 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/terraspace_plugin_azurerm/interfaces/helper/secret/fetcher.rb +38 -2
- data/lib/terraspace_plugin_azurerm/interfaces/helper/secret.rb +3 -3
- data/lib/terraspace_plugin_azurerm/interfaces/helper.rb +1 -1
- data/lib/terraspace_plugin_azurerm/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33dd9bb20fc1cc57ccd1e31f46e52621838ad043b118e67061b0c7b0bf96bf9c
|
4
|
+
data.tar.gz: c3721a61c30ad15870c1858ada72199380c9628572f80a3a0576750266a65b90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 442becc7f22e2b5b3bf1dc6c621a1dd52af1d4696934c3e6fd9dfc83e4f5d723fb5b5aceb29d24ef47b5b7be939a2676d8d205f77422618a31c8f381ce5d468a
|
7
|
+
data.tar.gz: 3e10754d0616e4877c34435cf30da1452eb58cafa938d82d3326ded07670b01cf202d11410ea114a3bb21dc177acadaf9dc4a05b3a524108bb5865ad3fe16d62
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,9 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
This project *loosely tries* to adhere to [Semantic Versioning](http://semver.org/).
|
5
5
|
|
6
|
+
## [0.3.3] - 2022-01-04
|
7
|
+
- [#10](https://github.com/boltops-tools/terraspace_plugin_azurerm/pull/10) azure_secret support expansion automatically
|
8
|
+
|
6
9
|
## [0.3.2] - 2021-11-29
|
7
10
|
- [#9](https://github.com/boltops-tools/terraspace_plugin_azurerm/pull/9) change starter resource_group_name to have env
|
8
11
|
|
@@ -4,11 +4,14 @@ class TerraspacePluginAzurerm::Interfaces::Helper::Secret
|
|
4
4
|
class Fetcher
|
5
5
|
class Error < StandardError; end
|
6
6
|
class VaultNotFoundError < Error; end
|
7
|
+
class VaultNotConfiguredError < Error; end
|
7
8
|
|
8
9
|
include TerraspacePluginAzurerm::Logging
|
9
10
|
include TerraspacePluginAzurerm::Clients::Options
|
11
|
+
extend Memoist
|
10
12
|
|
11
|
-
def initialize
|
13
|
+
def initialize(mod, options={})
|
14
|
+
@mod, @options = mod, options
|
12
15
|
o = base_client_options
|
13
16
|
@client_id = o[:client_id]
|
14
17
|
@client_secret = o[:client_secret]
|
@@ -20,16 +23,21 @@ class TerraspacePluginAzurerm::Interfaces::Helper::Secret
|
|
20
23
|
get_secret(name, opts)
|
21
24
|
end
|
22
25
|
|
23
|
-
def get_secret(name,
|
26
|
+
def get_secret(name, options={})
|
27
|
+
vault = options[:vault]
|
28
|
+
version = options[:version]
|
24
29
|
unless token
|
25
30
|
return "ERROR: Unable to authorize and get the temporary token. Double check your ARM_ env variables."
|
26
31
|
end
|
27
32
|
|
28
33
|
version = "/#{version}" if version
|
34
|
+
check_vault_configured!(vault)
|
29
35
|
vault_subdomain = vault.downcase
|
30
36
|
# Using Azure REST API since the old gem doesnt support secrets https://github.com/Azure/azure-sdk-for-ruby
|
31
37
|
# https://docs.microsoft.com/en-us/rest/api/keyvault/getsecret/getsecret
|
38
|
+
name = expansion(name) if expand?
|
32
39
|
url = "https://#{vault_subdomain}.vault.azure.net/secrets/#{name}#{version}?api-version=7.1"
|
40
|
+
logger.debug "Azure vault url #{url}"
|
33
41
|
uri = URI(url)
|
34
42
|
req = Net::HTTP::Get.new(uri)
|
35
43
|
req["Authorization"] = token
|
@@ -55,6 +63,23 @@ class TerraspacePluginAzurerm::Interfaces::Helper::Secret
|
|
55
63
|
end
|
56
64
|
end
|
57
65
|
|
66
|
+
def check_vault_configured!(vault)
|
67
|
+
return if vault
|
68
|
+
logger.error "ERROR: Vault has not been configured or vault option not passed in the azure_secret helper method.".color(:red)
|
69
|
+
logger.error <<~EOL
|
70
|
+
Please configure the Azure KeyVault you want to use. Example:
|
71
|
+
|
72
|
+
config/plugins/azurerm.rb
|
73
|
+
|
74
|
+
TerraspacePluginAzurerm.configure do |config|
|
75
|
+
config.secrets.vault = "REPLACE_WITH_YOUR_VAULT_NAME"
|
76
|
+
end
|
77
|
+
|
78
|
+
Docs: https://terraspace.cloud/docs/helpers/azure/secrets/
|
79
|
+
EOL
|
80
|
+
raise VaultNotConfiguredError.new
|
81
|
+
end
|
82
|
+
|
58
83
|
def send_request(uri, req)
|
59
84
|
http = Net::HTTP.new(uri.host, uri.port)
|
60
85
|
http.open_timeout = http.read_timeout = 30
|
@@ -108,5 +133,16 @@ class TerraspacePluginAzurerm::Interfaces::Helper::Secret
|
|
108
133
|
@@token = false
|
109
134
|
end
|
110
135
|
end
|
136
|
+
|
137
|
+
private
|
138
|
+
delegate :expansion, to: :expander
|
139
|
+
def expander
|
140
|
+
TerraspacePluginAzurerm::Interfaces::Expander.new(@mod)
|
141
|
+
end
|
142
|
+
memoize :expander
|
143
|
+
|
144
|
+
def expand?
|
145
|
+
!(@options[:expansion] == false || @options[:expand] == false)
|
146
|
+
end
|
111
147
|
end
|
112
148
|
end
|
@@ -6,8 +6,8 @@ module TerraspacePluginAzurerm::Interfaces::Helper
|
|
6
6
|
include TerraspacePluginAzurerm::Logging
|
7
7
|
include TerraspacePluginAzurerm::Clients::Options
|
8
8
|
|
9
|
-
def initialize(options={})
|
10
|
-
@options = options
|
9
|
+
def initialize(mod, options={})
|
10
|
+
@mod, @options = mod, options
|
11
11
|
@base64 = options[:base64]
|
12
12
|
end
|
13
13
|
|
@@ -19,7 +19,7 @@ module TerraspacePluginAzurerm::Interfaces::Helper
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def fetcher
|
22
|
-
Fetcher.new
|
22
|
+
Fetcher.new(@mod, @options)
|
23
23
|
end
|
24
24
|
memoize :fetcher
|
25
25
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: terraspace_plugin_azurerm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tung Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: azure-storage-blob
|
@@ -179,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: '0'
|
181
181
|
requirements: []
|
182
|
-
rubygems_version: 3.
|
182
|
+
rubygems_version: 3.2.32
|
183
183
|
signing_key:
|
184
184
|
specification_version: 4
|
185
185
|
summary: Terraspace Azurerm Cloud Plugin
|