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 +4 -4
- data/README.md +14 -2
- data/lib/cloud_formation_tool/version.rb +1 -1
- data/lib/cloud_formation_tool.rb +23 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7be18ff2c6036cdb06141cdd8228ac6ddf638817255dc382cb556d092daed68
|
4
|
+
data.tar.gz: e524b656930e02f090a10643a7b2861b31a6ac719bfec3c83c2185baaaac690b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
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
|
|
data/lib/cloud_formation_tool.rb
CHANGED
@@ -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 ||=
|
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,
|