Show More
@@ -53,7 +53,7 b' class HGAutomation:' | |||||
53 |
|
53 | |||
54 | return password |
|
54 | return password | |
55 |
|
55 | |||
56 | def aws_connection(self, region: str): |
|
56 | def aws_connection(self, region: str, ensure_ec2_state: bool=True): | |
57 | """Obtain an AWSConnection instance bound to a specific region.""" |
|
57 | """Obtain an AWSConnection instance bound to a specific region.""" | |
58 |
|
58 | |||
59 | return AWSConnection(self, region) |
|
59 | return AWSConnection(self, region, ensure_ec2_state=ensure_ec2_state) |
@@ -180,7 +180,7 b' Install-WindowsFeature -Name Net-Framewo' | |||||
180 | class AWSConnection: |
|
180 | class AWSConnection: | |
181 | """Manages the state of a connection with AWS.""" |
|
181 | """Manages the state of a connection with AWS.""" | |
182 |
|
182 | |||
183 | def __init__(self, automation, region: str): |
|
183 | def __init__(self, automation, region: str, ensure_ec2_state: bool=True): | |
184 | self.automation = automation |
|
184 | self.automation = automation | |
185 | self.local_state_path = automation.state_path |
|
185 | self.local_state_path = automation.state_path | |
186 |
|
186 | |||
@@ -191,11 +191,12 b' class AWSConnection:' | |||||
191 | self.ec2resource = self.session.resource('ec2') |
|
191 | self.ec2resource = self.session.resource('ec2') | |
192 | self.iamclient = self.session.client('iam') |
|
192 | self.iamclient = self.session.client('iam') | |
193 | self.iamresource = self.session.resource('iam') |
|
193 | self.iamresource = self.session.resource('iam') | |
194 |
|
194 | self.security_groups = {} | ||
195 | ensure_key_pairs(automation.state_path, self.ec2resource) |
|
|||
196 |
|
195 | |||
197 | self.security_groups = ensure_security_groups(self.ec2resource) |
|
196 | if ensure_ec2_state: | |
198 |
ensure_ |
|
197 | ensure_key_pairs(automation.state_path, self.ec2resource) | |
|
198 | self.security_groups = ensure_security_groups(self.ec2resource) | |||
|
199 | ensure_iam_state(self.iamresource) | |||
199 |
|
200 | |||
200 | def key_pair_path_private(self, name): |
|
201 | def key_pair_path_private(self, name): | |
201 | """Path to a key pair private key file.""" |
|
202 | """Path to a key pair private key file.""" |
@@ -95,12 +95,12 b' def build_all_windows_packages(hga: HGAu' | |||||
95 |
|
95 | |||
96 |
|
96 | |||
97 | def terminate_ec2_instances(hga: HGAutomation, aws_region): |
|
97 | def terminate_ec2_instances(hga: HGAutomation, aws_region): | |
98 | c = hga.aws_connection(aws_region) |
|
98 | c = hga.aws_connection(aws_region, ensure_ec2_state=False) | |
99 | aws.terminate_ec2_instances(c.ec2resource) |
|
99 | aws.terminate_ec2_instances(c.ec2resource) | |
100 |
|
100 | |||
101 |
|
101 | |||
102 | def purge_ec2_resources(hga: HGAutomation, aws_region): |
|
102 | def purge_ec2_resources(hga: HGAutomation, aws_region): | |
103 | c = hga.aws_connection(aws_region) |
|
103 | c = hga.aws_connection(aws_region, ensure_ec2_state=False) | |
104 | aws.remove_resources(c) |
|
104 | aws.remove_resources(c) | |
105 |
|
105 | |||
106 |
|
106 |
General Comments 0
You need to be logged in to leave comments.
Login now