@@ -87,7 +87,7 @@ def get_parameters_with_prefix(self, parameter_prefix: str, ssm) -> dict:
87
87
for parameter in page ['Parameters' ]:
88
88
parameters .append (parameter )
89
89
return parameters
90
-
90
+
91
91
def ssm_client (self , aws_config : AWSConfig ):
92
92
"""
93
93
Builds an SSM client using the provided Config.
@@ -99,21 +99,21 @@ def ssm_client(self, aws_config: AWSConfig):
99
99
region_name = aws_config .defaultRegion
100
100
)
101
101
return session .client ('ssm' )
102
-
102
+
103
103
def aws_config_from_environment (self ) -> AWSConfig :
104
104
"""
105
105
Inpsects the environment for four well-known AWS environment
106
106
variables, and populates their value into an Config bundle.
107
-
107
+
108
108
These credentials are used for two purposes:
109
109
1. To call get-parameters-by-path against SSM, to understand
110
110
the resource outputs of the various CDK scripts;
111
111
2. For the execution of the test suites themselves, on the device.
112
-
112
+
113
113
As a consequence, these credentials must have permissions
114
114
sufficient to read data out of SSM Parameter Store, as well as
115
115
to execute all of the various test suites, both.
116
-
116
+
117
117
The default region is used only while talking to SSM. The
118
118
provided region should be the same as what was used while
119
119
running the CDK scripts.
@@ -124,7 +124,24 @@ def aws_config_from_environment(self) -> AWSConfig:
124
124
os .environ ['AWS_SESSION_TOKEN' ],
125
125
os .environ ['AWS_DEFAULT_REGION' ]
126
126
)
127
-
127
+
128
+ def get_package_data (self ) -> dict :
129
+ aws_config = self .aws_config_from_environment ()
130
+ parameter_prefix = self .STACK_PREFIX_BASE + '/' + self .platform
131
+ ssm = self .ssm_client (aws_config )
132
+ parameters = self .get_parameters_with_prefix (parameter_prefix , ssm )
133
+ package_data = self .build_package_data (parameter_prefix , parameters )
134
+ return package_data
135
+
136
+ def get_credentials_data (self ) -> dict :
137
+ aws_config = self .aws_config_from_environment ()
138
+ credentials_data = {
139
+ 'accessKey' : aws_config .accessKey ,
140
+ 'secretKey' : aws_config .secretKey ,
141
+ 'sessionToken' : aws_config .sessionToken
142
+ }
143
+ return credentials_data
144
+
128
145
def print_device_config (self ) -> None :
129
146
"""
130
147
Obtains credentials from the environment (only). Builds a Simple
@@ -136,17 +153,10 @@ def print_device_config(self) -> None:
136
153
device running the SDK integration tests. The output of this
137
154
function may be piped to a file.
138
155
"""
139
- aws_config = self .aws_config_from_environment ()
140
- parameter_prefix = self .STACK_PREFIX_BASE + '/' + self .platform
141
- ssm = self .ssm_client (aws_config )
142
- parameters = self .get_parameters_with_prefix (parameter_prefix , ssm )
143
- package_data = self .build_package_data (parameter_prefix , parameters )
156
+ package_data = self .get_package_data ()
157
+ credentials_data = self .get_credentials_data ()
144
158
print (json .dumps ({
145
- 'credentials' : {
146
- 'accessKey' : aws_config .accessKey ,
147
- 'secretKey' : aws_config .secretKey ,
148
- 'sessionToken' : aws_config .sessionToken
149
- },
159
+ 'credentials' : credentials_data ,
150
160
'packages' : package_data
151
161
}, indent = 2 ))
152
162
0 commit comments