firespring_dev_commands 2.0.5 → 2.1.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc0c3856d6d9cce9b429f158ace60d901d373a5ea8067645285e8a3a21bc3d5b
|
4
|
+
data.tar.gz: c280047c0fc07d28a2aadfb7f554c19c3ddb80957d875988a67885d2222e83ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7f7b2a1723ca77b297f4d252f178958e2841ecc665613863cfbb3b20c120dcfad3aa6f96c036f8404ad1f6fb188b22182d9d5f961922de0b0f12d1d7c957332
|
7
|
+
data.tar.gz: d4f65836fe4afddbe6b97a39f5df1bc01e38e6b394bb8763751bfd8a373cbdfae0ad4f96cf744aed5543d783f78f5d283b556d4d1567dd2532d9e1bf671f3979
|
@@ -10,7 +10,7 @@ module Dev
|
|
10
10
|
# Yields that config object to any given block
|
11
11
|
# Returns the resulting config object
|
12
12
|
def self.config
|
13
|
-
@config ||= Config.new(
|
13
|
+
@config ||= Config.new(default_login_role_name: Dev::Aws::DEFAULT_LOGIN_ROLE_NAME)
|
14
14
|
yield(@config) if block_given?
|
15
15
|
@config
|
16
16
|
end
|
@@ -23,6 +23,10 @@ module Dev
|
|
23
23
|
# The name of the file containing the Aws settings
|
24
24
|
CONFIG_FILE = "#{Dev::Aws::CONFIG_DIR}/config".freeze
|
25
25
|
|
26
|
+
def self.config_ini
|
27
|
+
IniFile.new(filename: CONFIG_FILE, default: 'default')
|
28
|
+
end
|
29
|
+
|
26
30
|
# TODO: registry is deprecated and should be removed on the next major release
|
27
31
|
attr_accessor :root, :children, :default, :registry, :ecr_registry_ids
|
28
32
|
|
@@ -75,7 +79,7 @@ module Dev
|
|
75
79
|
puts 'Configuring default login values'
|
76
80
|
|
77
81
|
# Write region and mfa serial to config file
|
78
|
-
cfgini =
|
82
|
+
cfgini = self.class.config_ini
|
79
83
|
defaultini = cfgini['default']
|
80
84
|
|
81
85
|
region_default = defaultini['region'] || ENV['AWS_DEFAULT_REGION'] || Dev::Aws::DEFAULT_REGION
|
@@ -101,7 +105,7 @@ module Dev
|
|
101
105
|
# Setup Aws account specific settings
|
102
106
|
def setup!(account)
|
103
107
|
# Run base setup if it doesn't exist
|
104
|
-
Rake::Task['aws:configure:default'].invoke unless File.exist?(CONFIG_FILE)
|
108
|
+
Rake::Task['aws:configure:default'].invoke unless File.exist?(CONFIG_FILE) && self.class.config_ini.has_section?('default')
|
105
109
|
|
106
110
|
puts
|
107
111
|
puts "Configuring #{account} login values"
|
@@ -115,7 +119,7 @@ module Dev
|
|
115
119
|
raise 'Configure default account settings first (rake aws:configure:default)' unless File.exist?(CONFIG_FILE)
|
116
120
|
|
117
121
|
# Parse the ini file and load values
|
118
|
-
cfgini =
|
122
|
+
cfgini = self.class.config_ini
|
119
123
|
defaultini = cfgini['default']
|
120
124
|
profileini = cfgini["profile #{account}"]
|
121
125
|
|
@@ -124,13 +128,21 @@ module Dev
|
|
124
128
|
region_default = profileini['region'] || defaultini['region'] || ENV['AWS_DEFAULT_REGION'] || Dev::Aws::DEFAULT_REGION
|
125
129
|
profileini['region'] = Dev::Common.new.ask('Default region name', region_default)
|
126
130
|
|
127
|
-
# NOTE:
|
128
|
-
#
|
129
|
-
|
130
|
-
profileini['role_name']
|
131
|
-
|
131
|
+
# NOTE: Turns out the role_arn is needed by the aws cli so we are changing directions here. Eventually we should remove the role_name
|
132
|
+
# from the ini files and only store the role arn. However we need to still keep the functinoality so that the user is only asked
|
133
|
+
# for the role name - not the entire arn
|
134
|
+
role_name_default = if profileini['role_name']
|
135
|
+
profileini['role_name']
|
136
|
+
elsif profileini['role_arn']
|
137
|
+
profileini['role_arn']&.split(%r{role/})&.last
|
138
|
+
else
|
139
|
+
self.class.config.default_login_role_name
|
140
|
+
end
|
141
|
+
role_name = Dev::Common.new.ask('Default role name', role_name_default)
|
142
|
+
profileini['role_arn'] = "arn:aws:iam::#{account}:role/#{role_name}"
|
143
|
+
# TODO: role_name is deprecated. Eventually, we should delete the role_name entry from the config. Leaving it for now
|
132
144
|
# because some projects may be using older versions of the dev_commands library
|
133
|
-
# profileini.delete('
|
145
|
+
# profileini.delete('role_name')
|
134
146
|
|
135
147
|
cfgini.write
|
136
148
|
end
|
@@ -11,6 +11,10 @@ module Dev
|
|
11
11
|
# The local file where temporary credentials are stored
|
12
12
|
CONFIG_FILE = "#{Dev::Aws::CONFIG_DIR}/credentials".freeze
|
13
13
|
|
14
|
+
def self.config_ini
|
15
|
+
IniFile.new(filename: CONFIG_FILE, default: 'default')
|
16
|
+
end
|
17
|
+
|
14
18
|
# The account the profile is currently logged in to
|
15
19
|
def logged_in_account
|
16
20
|
::Aws::STS::Client.new.get_caller_identity.account
|
@@ -72,7 +76,7 @@ module Dev
|
|
72
76
|
puts 'Configuring default credential values'
|
73
77
|
|
74
78
|
# Write access key / secret key in the credentials file
|
75
|
-
credini =
|
79
|
+
credini = self.class.config_ini
|
76
80
|
defaultini = credini['default']
|
77
81
|
|
78
82
|
access_key_default = defaultini['aws_access_key_id']
|
@@ -87,7 +91,7 @@ module Dev
|
|
87
91
|
# Write Aws account specific settings to the credentials file
|
88
92
|
def write!(account, creds)
|
89
93
|
# Write access key / secret key / session token in the credentials file
|
90
|
-
credini =
|
94
|
+
credini = self.class.config_ini
|
91
95
|
defaultini = credini[account]
|
92
96
|
|
93
97
|
defaultini['aws_access_key_id'] = creds.access_key_id
|
@@ -132,7 +136,7 @@ module Dev
|
|
132
136
|
return unless File.exist?(CONFIG_FILE)
|
133
137
|
|
134
138
|
# Otherwise load access key / secret key / session token from the credentials file into the environment
|
135
|
-
credini =
|
139
|
+
credini = self.class.config_ini
|
136
140
|
profile_credentials = credini[Dev::Aws::Profile.new.current]
|
137
141
|
return unless profile_credentials
|
138
142
|
|
@@ -42,9 +42,11 @@ module Dev
|
|
42
42
|
serial = "arn:aws:iam::#{Dev::Aws::Account.new.root.id}:mfa/#{serial}" if serial
|
43
43
|
serial ||= profileini['mfa_serial'] || defaultini['mfa_serial']
|
44
44
|
|
45
|
-
role = profileini['
|
46
|
-
|
47
|
-
|
45
|
+
role = profileini['role_arn'] || defaultini['role_arn']
|
46
|
+
# NOTE: We supported role name for a period of time but we are switching back to role_arn.
|
47
|
+
# Leaving this here for a period of time until it can be deprecated
|
48
|
+
role ||= "arn:aws:iam::#{account}:role/#{profileini['role_name'] || defaultini['role_name']}"
|
49
|
+
# TODO: role_name is deprecated. Eventually, we should remove the above line
|
48
50
|
|
49
51
|
session_name = profileini['role_session_name'] || defaultini['role_session_name']
|
50
52
|
session_duration = profileini['session_duration'] || defaultini['session_duration']
|
@@ -72,10 +74,10 @@ module Dev
|
|
72
74
|
# Returns the config ini file
|
73
75
|
# Runs the setup for our current account if it's not already setup
|
74
76
|
def setup_cfgini(account)
|
75
|
-
cfgini =
|
77
|
+
cfgini = Dev::Aws::Account.config_ini
|
76
78
|
unless cfgini.has_section?("profile #{account}")
|
77
79
|
Dev::Aws::Account.new.write!(account)
|
78
|
-
cfgini =
|
80
|
+
cfgini = Dev::Aws::Account.config_ini
|
79
81
|
end
|
80
82
|
cfgini
|
81
83
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: firespring_dev_commands
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Firespring
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-07-
|
11
|
+
date: 2023-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|