terraspace 2.2.0 → 2.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 672cf9e56e84babb2bc53f8e076a13cb51aa9741416fcd6128e66b3774d335fb
4
- data.tar.gz: 10417698653e7ae38863e1c9d3a1fafebb2ea937693e8c5c0f65cb14e81b1f0b
3
+ metadata.gz: 0c7a68a82f374785998967cf8af6d56f78130d7e03e8b0d7e64e85a9483e61cd
4
+ data.tar.gz: 2883619576b4a57c0e049edbc2cdae9d44b6c23926e3fe85084170bed5afb6c3
5
5
  SHA512:
6
- metadata.gz: fbb895751949a30c32caaadad94a7d24c711313ca3675bb849f8ec9ab04b21e00901051ba5914d2c6a9317cabd91345cf8efe2ed053b90f61bb56228117b2249
7
- data.tar.gz: d2fcb5d16322d8a2c7bdf15be9d8108aefaee66505deb4c54acaad2339958d4a9cf4def684e4a08a44ff467f2ce9e7269a9d38924bf668634bdd93e3cd55d69d
6
+ metadata.gz: fbbd8c9339438902bc05b507292497c7714ccf9264a0155ab4fcd51c9e7d89d8ea0fc0a94f60228273fb9830f4458269eefa259a014d14a5754692a3d7747a2a
7
+ data.tar.gz: e62b1db8f363a94bbea6ed69ec1a6323171ab4442ff9059f0141fc2017837167659f741b2a7bf7e88f6d643320ac2040ff4e35e6564e0725861f030cd48809d4
data/CHANGELOG.md CHANGED
@@ -3,6 +3,12 @@
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/), even before v1.0.
5
5
 
6
+ ## [2.2.2] - 2022-09-14
7
+ - [#268](https://github.com/boltops-tools/terraspace/pull/268) custom config.build.dependency_words ability
8
+
9
+ ## [2.2.1] - 2022-09-08
10
+ - [#265](https://github.com/boltops-tools/terraspace/pull/265) import command
11
+
6
12
  ## [2.2.0] - 2022-09-02
7
13
  - [#261](https://github.com/boltops-tools/terraspace/pull/261) extra layer also process env-extra
8
14
  - [#262](https://github.com/boltops-tools/terraspace/pull/262) improve graph dependency processing: replace tfvars so only output and depends_on are evaluated
@@ -42,6 +42,7 @@ module Terraspace
42
42
  config.build.clean_cache = nil # defaults to true
43
43
  config.build.default_pass_files = ["/files/"]
44
44
  config.build.pass_files = []
45
+ config.build.dependency_words = []
45
46
 
46
47
  config.bundle = ActiveSupport::OrderedOptions.new
47
48
  config.bundle.logger = ts_logger
@@ -0,0 +1,29 @@
1
+ ## Examples
2
+
3
+ terraspace import ec2 aws_instance.this i-088a0a47e2e852cc8
4
+ terraspace import vpc module.vpc.aws_vpc.this vpc-000782e4951a734c7
5
+ terraspace import vpc module.vpc.aws_vpc.this vpc-000782e4951a734c7
6
+
7
+ A general workflow is to use terraspace plan, inspect what resources, are missing and and import resources based on that. The `state list` command is also useful.
8
+
9
+ terraspace plan vpc
10
+ terraspace import vpc module.vpc.aws_vpc.this vpc-000782e4951a734c7
11
+ terraspace plan vpc
12
+ terraspace import vpc module.vpc.aws_internet_gateway.this[0] igw-0fa4bec3b4b46948a
13
+ terraspace state list vpc
14
+
15
+ Example with output:
16
+
17
+ $ terraspace import vpc module.vpc.aws_internet_gateway.this[0] igw-0fa4bec3b4b46948a
18
+ Building .terraspace-cache/us-west-2/dev/stacks/vpc
19
+ Current directory: .terraspace-cache/us-west-2/dev/stacks/vpc
20
+ => terraform import module.vpc.aws_internet_gateway.this[0] igw-0fa4bec3b4b46948a
21
+ module.vpc.aws_internet_gateway.this[0]: Importing from ID "igw-0fa4bec3b4b46948a"...
22
+ module.vpc.aws_internet_gateway.this[0]: Import prepared!
23
+ Prepared aws_internet_gateway for import
24
+ module.vpc.aws_internet_gateway.this[0]: Refreshing state... [id=igw-0fa4bec3b4b46948a]
25
+
26
+ Import successful!
27
+
28
+ The resources that were imported are shown above. These resources are now in
29
+ your Terraform state and will henceforth be managed by Terraform.
@@ -0,0 +1,12 @@
1
+ class Terraspace::CLI
2
+ class Import < Base
3
+ def run
4
+ commander.run
5
+ end
6
+
7
+ def commander
8
+ Commander.new("import", @options)
9
+ end
10
+ memoize :commander
11
+ end
12
+ end
@@ -109,6 +109,12 @@ module Terraspace
109
109
  Fmt.new(options.merge(mod: mod)).run
110
110
  end
111
111
 
112
+ desc "import ADDR ID", "Import existing infrastructure into your Terraform state"
113
+ long_desc Help.text(:import)
114
+ def import(mod, addr, id)
115
+ Import.new(options.merge(mod: mod, addr: addr, id: id)).run
116
+ end
117
+
112
118
  desc "info STACK", "Get info about stack."
113
119
  long_desc Help.text(:info)
114
120
  instance_option.call
@@ -26,7 +26,10 @@ module Terraspace::Compiler::Erb
26
26
  def new_line(line)
27
27
  md = line.match(/.*(<% |<%=)/) || line.match(/.*<%$/)
28
28
  if md
29
- words = %w[output depends_on] # TODO: consider allowing user customizations
29
+ words = %w[output depends_on]
30
+ dependency_words = [Terraspace.config.build.dependency_words].flatten
31
+ words += dependency_words # custom user words to evaluated in first pass also
32
+ return line if words.include?('*') # passthrough for special case '*'
30
33
  # IE: <%= output or <% depends_on
31
34
  regexp = Regexp.new(".*<%.*#{words.join('|')}.*")
32
35
  if line.match(regexp)
@@ -117,6 +117,10 @@ module Terraspace::Terraform::Args
117
117
  auto_approve_arg
118
118
  end
119
119
 
120
+ def import_args
121
+ [@options[:addr], @options[:id]]
122
+ end
123
+
120
124
  def auto_approve_arg
121
125
  @options[:yes] || @options[:auto] ? ["-auto-approve"] : []
122
126
  end
@@ -1,3 +1,3 @@
1
1
  module Terraspace
2
- VERSION = "2.2.0"
2
+ VERSION = "2.2.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: terraspace
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-09-02 00:00:00.000000000 Z
11
+ date: 2022-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -571,6 +571,7 @@ files:
571
571
  - lib/terraspace/cli/help/down.md
572
572
  - lib/terraspace/cli/help/fmt.md
573
573
  - lib/terraspace/cli/help/force_unlock.md
574
+ - lib/terraspace/cli/help/import.md
574
575
  - lib/terraspace/cli/help/info.md
575
576
  - lib/terraspace/cli/help/init.md
576
577
  - lib/terraspace/cli/help/list.md
@@ -604,6 +605,7 @@ files:
604
605
  - lib/terraspace/cli/help/tfc/sync.md
605
606
  - lib/terraspace/cli/help/up.md
606
607
  - lib/terraspace/cli/help/validate.md
608
+ - lib/terraspace/cli/import.rb
607
609
  - lib/terraspace/cli/info.rb
608
610
  - lib/terraspace/cli/init.rb
609
611
  - lib/terraspace/cli/list.rb