cloudformation-tool 1.5.7 → 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: 54883f0b3b73d46c3c1713a195b9890e44d45b0f6518bc0af02a05723ae98639
4
- data.tar.gz: de8e95b100a2416ce91466d23ca4b409bcce5ed0c49392c1035113be5d8a3384
3
+ metadata.gz: f7be18ff2c6036cdb06141cdd8228ac6ddf638817255dc382cb556d092daed68
4
+ data.tar.gz: e524b656930e02f090a10643a7b2861b31a6ac719bfec3c83c2185baaaac690b
5
5
  SHA512:
6
- metadata.gz: 95940c9d47d1ae01da4f6f34bd7ed78f40a5b3888037f768dfdaf84febeab5755f56ac78aecd4ab20e3e4f2e6f2dffa01048509824d096cb9ff5618cccd22bcc
7
- data.tar.gz: 919a01d74e3f9da20933c8b2efd3dc5ea3aac7d78a3ac7f9e540ead9a9e037a857e35b0d695f0c4cdaef0503b02e28c223758c27dd3918672b1153c912a52f17
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 REGION - 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.7'
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,21 +72,27 @@ 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
- def profile
61
- $__profile ||= find_profile(nil, ENV['AWS_PROFILE'] || ENV['AWS_DEFAULT_PROFILE'] || 'default')
81
+ def profile name = nil
82
+ $__profile ||= name || find_profile(nil, ENV['AWS_PROFILE'] || ENV['AWS_DEFAULT_PROFILE'] || 'default')
62
83
  end
63
84
 
64
85
  def awscreds
65
- require 'aws-sdk-core'
66
- $__aws_creds ||= Aws::SharedCredentials.new(profile_name: profile)
86
+ #$__aws_creds ||= Aws::SharedCredentials.new(profile_name: profile)
87
+ config = Aws::SharedConfig.new(profile_name: profile, config_enabled: true)
88
+ $__aws_creds ||= config.credentials
67
89
  end
68
90
 
69
91
  def aws_config
92
+ p region
70
93
  {
71
- credentials: awscreds,
94
+ # credentials: awscreds,
95
+ profile: profile,
72
96
  region: region,
73
97
  http_read_timeout: 5
74
98
  }
@@ -116,11 +140,12 @@ module CloudFormationTool
116
140
  if bucket.nil?
117
141
  name = cf_bucket_name(region)
118
142
  log "Creating CF template bucket #{name}"
119
- awss3.create_bucket({
143
+ awss3(region).create_bucket({
120
144
  acl: "private",
121
145
  bucket: name,
122
146
  object_ownership: 'BucketOwnerPreferred'
123
147
  }.merge(if region == 'us-east-1' then {} else { create_bucket_configuration: { location_constraint: region } } end))
148
+ awss3(region).delete_public_access_block({bucket: name})
124
149
  name
125
150
  else
126
151
  bucket[:name]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudformation-tool
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.7
4
+ version: 1.5.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oded Arbel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-01 00:00:00.000000000 Z
11
+ date: 2023-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 12.3.3
27
+ - !ruby/object:Gem::Dependency
28
+ name: psych
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '4.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '4.0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: clamp
29
43
  requirement: !ruby/object:Gem::Requirement