cloudformation-tool 1.5.8 → 1.5.10

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: 1664bf2e43c0a1f38055655a7cf3f03e3cc894994b3f2c4999fe3ba2f176552d
4
- data.tar.gz: 4629049058e37f0646ca4c2366056b30f53ea0984abe9bdb23ebdebba72fbb26
3
+ metadata.gz: b64f38328ec8d1843260e00ec3caf036ed3dff604d013a127df99fe741cf7b61
4
+ data.tar.gz: 3475cfcaaa53b64528c558f8a1eaf79795e676516db8018811503c9646047dcc
5
5
  SHA512:
6
- metadata.gz: 6ee389717fb40caa17dad26a53600005c59a1291e708a8512ace4745b9b053e66e38896be0097c3e00399ec834ed47e73f109ad2ed6ea52a030782276e73e231
7
- data.tar.gz: 702635a6866f36e6abbb34bce3bf6192788c7fd1b1f4ce2950f19f25b9c8ca2a51f34c96be8abf3eb7357a71e7f496ee0608996cf221912e1090fdec1f11ee79
6
+ metadata.gz: d5fe56f25e0f6d1a4c1a7725cd5b22c9fb9d01591be43eea7a95512b8abd8f835ba9034987b96d6126f13b8a16ddd4a9983e3d4e2084e2163fbb3fd86966b0ec
7
+ data.tar.gz: 12cb69dd1a9fe9dfcf238aeafab0d1191c4ef1c71b66aac553fd3f5bb54979cf0ba3de03f9dcf5e1fdb0cee81dece373e7a1a4bdd5b36a616e5328263653ad36
data/README.md CHANGED
@@ -359,11 +359,23 @@ more details and specific options.
359
359
 
360
360
  ### Region Selection
361
361
 
362
- The AWS region to be used can be select by specifying top level option (i.e. before the command name) `-r <region>`, by providing the standard environment variable `AWS_DEFAULT_REGION` or it will default to `us-west-1`
362
+ The CloudFormation tool must know what region the CloudFormation stack is being deployed into, so it
363
+ can create and appropriately located S3 bucket for template intermediary files (such cloud-init templates).
364
+
365
+ The AWS region will be chosen according to this order of precedence:
366
+ - Using the top level command line option `--region`
367
+ - Setting the environment variable `AWS_REGION` (to be compatible with the AWS CLI)
368
+ - Setting a default region in the AWS CLI profile, then selecting that profile using the top level command
369
+ line option `--profile` (this can be done using `aws configure` or by editing the credentials file)
370
+ - Setting the environment variable `AWS_DEFAULT_REGION`
371
+ - If none of these are set, the default AWS region `us-east-1` is assumed
363
372
 
364
373
  ### Credentials Selection
365
374
 
366
- The tool will use the standard AWS credentials selection process, except when you want to use AWS CLI configured credential profiles, you may select to use a profile other than "default" by specifying the top level option (i.e. before the command name) `-p <profile>`, by providing the standard environment variable `AWS_DEFAULT_PROFILE` or by having a file called `.awsprofile` - whose content is the name of a valid AWS credentials profile - in a parent directory (at any level up to the root directory).
375
+ The tool will use the standard AWS credentials selection process, except that you may want to use AWS CLI configured
376
+ credential profile - you may select to use a profile other than "default" either by using the top level command line
377
+ option `--profile`, by providing the standard environment variable `AWS_DEFAULT_PROFILE`, or by creating a file called
378
+ `.awsprofile` - whose content is the name of a valid AWS credentials profile - in a parent directory (at any level up to the root directory).
367
379
 
368
380
  ## Library API
369
381
 
@@ -1,3 +1,3 @@
1
1
  module CloudFormationTool
2
- VERSION = '1.5.8'
2
+ VERSION = '1.5.10'
3
3
  end
@@ -1,5 +1,7 @@
1
1
  require 'logger'
2
2
  require 'autoloaded'
3
+ require 'socket'
4
+ require 'aws-sdk-core'
3
5
 
4
6
  def logger
5
7
  ($__logger ||= Logger.new(STDERR))
@@ -37,6 +39,22 @@ def error(message = nul, &block)
37
39
  end)
38
40
  end
39
41
 
42
+ # Hack AWS SDK to let us find out the Profile's region that it resolved
43
+ module Aws
44
+ class SharedConfig
45
+ def profile_region
46
+ c = (if @parsed_credentials and @parsed_credentials[@profile_name] then
47
+ @parsed_credentials[@profile_name]
48
+ elsif @parsed_config and @parsed_config[@profile_name] then
49
+ @parsed_config[@profile_name]
50
+ else
51
+ {}
52
+ end)
53
+ c['region'] || c['aws_region'] || c['sso_region'] || nil
54
+ end
55
+ end
56
+ end
57
+
40
58
  module CloudFormationTool
41
59
 
42
60
  Autoloaded.module do |autoloaded|
@@ -54,7 +72,10 @@ module CloudFormationTool
54
72
  end
55
73
 
56
74
  def region
57
- $__region ||= (ENV['AWS_DEFAULT_REGION'] || 'us-west-1')
75
+ $__region ||= ENV['AWS_REGION'] ||
76
+ Aws::SharedConfig.new(profile_name: profile, config_enabled: true).profile_region ||
77
+ ENV['AWS_DEFAULT_REGION'] ||
78
+ 'us-east-1'
58
79
  end
59
80
 
60
81
  def profile name = nil
@@ -62,7 +83,6 @@ module CloudFormationTool
62
83
  end
63
84
 
64
85
  def awscreds
65
- require 'aws-sdk-core'
66
86
  #$__aws_creds ||= Aws::SharedCredentials.new(profile_name: profile)
67
87
  config = Aws::SharedConfig.new(profile_name: profile, config_enabled: true)
68
88
  $__aws_creds ||= config.credentials
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudformation-tool
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.8
4
+ version: 1.5.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oded Arbel