Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
What's new
4
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Menu
Open sidebar
rlees85-ruby
terraform-wrapper
Commits
cd280004
Commit
cd280004
authored
Dec 08, 2021
by
Rich
Browse files
Allow tainting
parent
92aa3496
Changes
6
Hide whitespace changes
Inline
Side-by-side
archlinux/PKGBUILD
View file @
cd280004
...
...
@@ -3,7 +3,7 @@
_gemname
=
terraform-wrapper
pkgname
=
ruby-
${
_gemname
}
pkgver
=
1.2.
6
pkgver
=
1.2.
7
pkgrel
=
1
pkgdesc
=
"A ruby wrapper for managing Terraform binaries and remote state."
arch
=(
any
)
...
...
lib/terraform-wrapper.rb
View file @
cd280004
...
...
@@ -59,6 +59,7 @@ module TerraformWrapper
tasks
<<
TerraformWrapper
::
Tasks
::
Init
.
new
(
binary:
binary
,
code:
code
,
options:
config_options
)
tasks
<<
TerraformWrapper
::
Tasks
::
Plan
.
new
(
binary:
binary
,
code:
code
,
options:
config_options
)
tasks
<<
TerraformWrapper
::
Tasks
::
PlanDestroy
.
new
(
binary:
binary
,
code:
code
,
options:
config_options
)
tasks
<<
TerraformWrapper
::
Tasks
::
Taint
.
new
(
binary:
binary
,
code:
code
,
options:
config_options
)
tasks
<<
TerraformWrapper
::
Tasks
::
Upgrade
.
new
(
binary:
binary
,
code:
code
)
tasks
<<
TerraformWrapper
::
Tasks
::
Validate
.
new
(
binary:
binary
,
code:
code
)
return
tasks
...
...
lib/terraform-wrapper/shared/runner.rb
View file @
cd280004
...
...
@@ -148,7 +148,6 @@ module TerraformWrapper
def
import
(
address:
nil
,
id:
nil
)
logger
.
fatal
(
"Cannot Terraform import before initialising backend!"
)
unless
initialised
logger
.
fatal
(
"Terraform state address for import must be a string!"
)
unless
address
.
kind_of?
(
String
)
logger
.
fatal
(
"Terraform state address for import must be a string!"
)
unless
address
.
kind_of?
(
String
)
logger
.
fatal
(
"Terraform state address for import must not be blank!"
)
if
address
.
strip
.
empty?
...
...
@@ -165,6 +164,20 @@ module TerraformWrapper
logger
.
fatal
(
"Terraform import failed!"
)
unless
run
(
action:
"import"
,
parameters:
parameters
)
end
###############################################################################
def
taint
(
address:
nil
)
logger
.
fatal
(
"Cannot Terraform taint before initialising backend!"
)
unless
initialised
logger
.
fatal
(
"Terraform state address for taint must be a string!"
)
unless
address
.
kind_of?
(
String
)
logger
.
fatal
(
"Terraform state address for taint must not be blank!"
)
if
address
.
strip
.
empty?
parameters
=
Array
.
new
parameters
.
append
(
"'
#{
address
}
'"
)
logger
.
fatal
(
"Terraform taint failed!"
)
unless
run
(
action:
"taint"
,
parameters:
parameters
)
end
###############################################################################
def
validate
...
...
lib/terraform-wrapper/tasks.rb
View file @
cd280004
...
...
@@ -12,6 +12,7 @@ require_relative 'tasks/import'
require_relative
'tasks/init'
require_relative
'tasks/plan'
require_relative
'tasks/plandestroy'
require_relative
'tasks/taint'
require_relative
'tasks/upgrade'
require_relative
'tasks/validate'
...
...
lib/terraform-wrapper/tasks/taint.rb
0 → 100644
View file @
cd280004
###############################################################################
module
TerraformWrapper
###############################################################################
module
Tasks
###############################################################################
class
Taint
<
::
Rake
::
TaskLib
###############################################################################
include
TerraformWrapper
::
Shared
::
Logging
###############################################################################
@binary
@code
@options
###############################################################################
def
initialize
(
binary
:,
code
:,
options
:)
@binary
=
binary
@code
=
code
@options
=
options
yield
self
if
block_given?
taint_task
end
###############################################################################
def
taint_task
desc
"Taint a piece of existing infrastructure so that Terraform recreates it at next apply."
task
:taint
,
[
:config
,
:address
]
=>
:binary
do
|
t
,
args
|
options
=
@options
.
merge
({
"name"
=>
args
[
:config
]})
logger
.
info
(
"Processing configuration for Terraform taint..."
)
config
=
TerraformWrapper
::
Shared
::
Config
.
new
(
code:
@code
,
options:
options
)
runner
=
TerraformWrapper
::
Shared
::
Runner
.
new
(
binary:
@binary
,
code:
@code
)
logger
.
info
(
"Running Terraform taint for service:
#{
config
.
service
}
, component:
#{
@code
.
name
}
..."
)
runner
.
init
(
config:
config
)
runner
.
taint
(
address:
args
[
:address
])
end
end
###############################################################################
end
###############################################################################
end
###############################################################################
end
###############################################################################
lib/terraform-wrapper/version.rb
View file @
cd280004
...
...
@@ -4,7 +4,7 @@ module TerraformWrapper
###############################################################################
VERSION
=
"1.2.
6
"
VERSION
=
"1.2.
7
"
###############################################################################
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment