terraspace_plugin_aws 0.3.3 → 0.3.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9a3326332a1832e221e9962a51532ec8a6af56b9907b5bb7fa8cb6f3589d73cf
4
- data.tar.gz: a615e24bcc2e831e52170665223eba3d714605b4f75fee2486c236d03fc112f6
3
+ metadata.gz: a734d60b2713b55bfaf56b012c3f9a496524ea91e9d929de9390c50748cb6eac
4
+ data.tar.gz: 7e7ff81c606f4dab49c37bb217efc676c58c522ceb49a6b95e7b06e398040687
5
5
  SHA512:
6
- metadata.gz: cb39b0df24421a04fbf3bbd0892ba77f151ab248906c44ea6a0ea4de8067bbe7cd70fdc7857d73e008efabe3458467a41e50a866121ed42ce39eb9a0a22636e1
7
- data.tar.gz: 90d815348cfd459edc71812c3d7ef5ae41007d7f9ea73c0dfb6be53d9212a2c1500cb4bc413645b73dccedbebb58ddc35628499bd80b9be0cbc20346ea965d27
6
+ metadata.gz: 99a83edd45b95fbafbce17c2c7a992524176d1335754404716d1d2546ac311baf5010a8e5e3204fd0153e1d718374dda895834947d3d1fb064581e5396df260b
7
+ data.tar.gz: b0f16167fbf2cfa375b487993540072e757c17cbfe1781e4476f6a680fa69c8757e501adc67aea9099e32b4c0e1bfab3352c72c0162592479c3c11ef3c694fda
data/CHANGELOG.md CHANGED
@@ -3,6 +3,10 @@
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.4] - 2021-12-30
7
+ - [#13](https://github.com/boltops-tools/terraspace_plugin_aws/pull/13) check aws setup and provide friendly message
8
+ - [#14](https://github.com/boltops-tools/terraspace_plugin_aws/pull/14) fix aws_secret helper
9
+
6
10
  ## [0.3.3] - 2021-12-14
7
11
  - [#10](https://github.com/boltops-tools/terraspace_plugin_aws/pull/10) implement expand_string? to not expand aws arn values
8
12
 
@@ -2,8 +2,9 @@ module TerraspacePluginAws::Clients
2
2
  module Options
3
3
  private
4
4
  def client_options
5
+ return {} unless @info # aws_secret helper wont have @info
5
6
  if @info['role_arn']
6
- client_assume_role_config
7
+ client_assume_role_options
7
8
  else
8
9
  client_default_options
9
10
  end
@@ -31,7 +32,7 @@ module TerraspacePluginAws::Clients
31
32
  # :external_id (String)
32
33
  # :client (STS::Client)
33
34
  #
34
- def client_assume_role_config
35
+ def client_assume_role_options
35
36
  whitelist = %w[
36
37
  assume_role_duration_seconds
37
38
  assume_role_policy
@@ -59,10 +60,7 @@ module TerraspacePluginAws::Clients
59
60
  end
60
61
  assume_role_config.symbolize_keys! # ruby sdk expects symbols for keys
61
62
  assume_role_config[:role_session_name] ||= [ENV['C9_USER'] || ENV['USER'], 'session'].compact.join('-') # session name is required for the ruby sdk
62
- # options = {client: Aws::STS::Client.new(client_region_option)}
63
- options = {}
64
- options.merge!(assume_role_config)
65
- role_credentials = Aws::AssumeRoleCredentials.new(options)
63
+ role_credentials = Aws::AssumeRoleCredentials.new(assume_role_config)
66
64
  {credentials: role_credentials}
67
65
  end
68
66
 
@@ -23,6 +23,11 @@ module TerraspacePluginAws
23
23
  end
24
24
  memoize :ssm
25
25
 
26
+ def sts
27
+ Aws::STS::Client.new(client_options)
28
+ end
29
+ memoize :sts
30
+
26
31
  def dynamodb
27
32
  Aws::DynamoDB::Client.new(client_options)
28
33
  end
@@ -0,0 +1,15 @@
1
+ class TerraspacePluginAws::Interfaces::Backend
2
+ class Setup < Base
3
+ def check!
4
+ sts.get_caller_identity
5
+ rescue Aws::Errors::MissingCredentialsError => e
6
+ logger.info "ERROR: #{e.class}: #{e.message}".color(:red)
7
+ logger.info <<~EOL
8
+ It doesnt look like AWS credentials and access has been setup.
9
+ Please double check the AWS credentials setup.
10
+ IE: ~/.aws/config and the AWS_PROFILE env variable.
11
+ EOL
12
+ exit 1
13
+ end
14
+ end
15
+ end
@@ -6,6 +6,7 @@ module TerraspacePluginAws::Interfaces
6
6
  def call
7
7
  return unless TerraspacePluginAws.config.auto_create
8
8
 
9
+ Setup.new(@info).check!
9
10
  Bucket.new(@info).create
10
11
  Table.new(@info).create
11
12
  end
@@ -1,3 +1,3 @@
1
1
  module TerraspacePluginAws
2
- VERSION = "0.3.3"
2
+ VERSION = "0.3.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: terraspace_plugin_aws
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-12-14 00:00:00.000000000 Z
11
+ date: 2021-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-dynamodb
@@ -172,6 +172,7 @@ files:
172
172
  - lib/terraspace_plugin_aws/interfaces/backend/base.rb
173
173
  - lib/terraspace_plugin_aws/interfaces/backend/bucket.rb
174
174
  - lib/terraspace_plugin_aws/interfaces/backend/bucket/secure.rb
175
+ - lib/terraspace_plugin_aws/interfaces/backend/setup.rb
175
176
  - lib/terraspace_plugin_aws/interfaces/backend/table.rb
176
177
  - lib/terraspace_plugin_aws/interfaces/config.rb
177
178
  - lib/terraspace_plugin_aws/interfaces/decorator.rb