cloudformation-tool 1.5.8 → 1.5.9

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: 1664bf2e43c0a1f38055655a7cf3f03e3cc894994b3f2c4999fe3ba2f176552d
4
- data.tar.gz: 4629049058e37f0646ca4c2366056b30f53ea0984abe9bdb23ebdebba72fbb26
3
+ metadata.gz: f7be18ff2c6036cdb06141cdd8228ac6ddf638817255dc382cb556d092daed68
4
+ data.tar.gz: e524b656930e02f090a10643a7b2861b31a6ac719bfec3c83c2185baaaac690b
5
5
  SHA512:
6
- metadata.gz: 6ee389717fb40caa17dad26a53600005c59a1291e708a8512ace4745b9b053e66e38896be0097c3e00399ec834ed47e73f109ad2ed6ea52a030782276e73e231
7
- data.tar.gz: 702635a6866f36e6abbb34bce3bf6192788c7fd1b1f4ce2950f19f25b9c8ca2a51f34c96be8abf3eb7357a71e7f496ee0608996cf221912e1090fdec1f11ee79
6
+ metadata.gz: 6b5fd5bffc734fe2336b8410431a11ba4f70e1271373266efbe8ad4044004f2ddd653568298e3c700ab084315e8c34504ac371b44879991cae3c8fb0a7295a82
7
+ data.tar.gz: 500a58da8d2663bf28580e471c20f20acdbb5573227d19412262890abfb97669251d478e1e3917c7423bd790db280fe3c30a8af0cd3d1701ce8ec14b75d69fd0
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.9'
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,13 +83,13 @@ 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
69
89
  end
70
90
 
71
91
  def aws_config
92
+ p region
72
93
  {
73
94
  # credentials: awscreds,
74
95
  profile: profile,
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.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oded Arbel