##// END OF EJS Templates
automation: don't create resources when deleting things...
Gregory Szorc -
r42463:dd6a9723 default
parent child Browse files
Show More
@@ -53,7 +53,7 class HGAutomation:
53 53
54 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 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 Install-WindowsFeature -Name Net-Framewo
180 180 class AWSConnection:
181 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 184 self.automation = automation
185 185 self.local_state_path = automation.state_path
186 186
@@ -191,11 +191,12 class AWSConnection:
191 191 self.ec2resource = self.session.resource('ec2')
192 192 self.iamclient = self.session.client('iam')
193 193 self.iamresource = self.session.resource('iam')
194
195 ensure_key_pairs(automation.state_path, self.ec2resource)
194 self.security_groups = {}
196 195
197 self.security_groups = ensure_security_groups(self.ec2resource)
198 ensure_iam_state(self.iamresource)
196 if ensure_ec2_state:
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 201 def key_pair_path_private(self, name):
201 202 """Path to a key pair private key file."""
@@ -95,12 +95,12 def build_all_windows_packages(hga: HGAu
95 95
96 96
97 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 99 aws.terminate_ec2_instances(c.ec2resource)
100 100
101 101
102 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 104 aws.remove_resources(c)
105 105
106 106
General Comments 0
You need to be logged in to leave comments. Login now