lablink_allocator_service.providers.aws¶
lablink_allocator_service.providers.aws
¶
AWSProvider — behavior-preserving wrapper over existing AWS utilities.
Classes¶
AWSProvider(*, region=None, tofu_dir=None, **_)
¶
Source code in packages/allocator/src/lablink_allocator_service/providers/aws.py
Attributes¶
can_destroy_hosts = True
class-attribute
instance-attribute
¶
can_provision_hosts = True
class-attribute
instance-attribute
¶
can_recover_hosts = True
class-attribute
instance-attribute
¶
client_connectivity = AllocatorProxiedClientConnectivity()
instance-attribute
¶
name = 'aws'
class-attribute
instance-attribute
¶
Methods:¶
destroy_hosts(handles, progress_callback=None)
¶
Plan, then apply, a full-workspace destroy. handles is
accepted for protocol consistency but not used for per-handle
filtering — OpenTofu destroy operates against the whole state
file. Mirrors provision_hosts's plan+show+apply sequence (added
so resources_total can be computed exactly the same way
provision_hosts computes it for creates) instead of the single
tofu destroy call this method used before.
Raises FileNotFoundError if no runtime tfvars exists (signals "no client VMs were ever launched" — route handler maps this to 404).
Source code in packages/allocator/src/lablink_allocator_service/providers/aws.py
get_host_access(hostname)
¶
Return (instance_id, public_ip, ssh_key_path) for hostname.
Looks up the EC2 instance by Name tag, fetches its public IP, and reads the SSH private key from the OpenTofu state directory. Any component may be None if unavailable (instance not found, no public IP, or tofu_dir not set / key file absent).
Source code in packages/allocator/src/lablink_allocator_service/providers/aws.py
list_hosts()
¶
Source code in packages/allocator/src/lablink_allocator_service/providers/aws.py
provision_hosts(count, spec, progress_callback=None)
¶
Run tofu plan + audit + apply for count new client hosts.
Moves the inline logic that used to live in main.py's /api/launch
handler behind the provider seam (SR-F1). spec is a dict of
runtime values that used to be assembled inline in the route.
Raises:
| Type | Description |
|---|---|
RuntimeError
|
if tofu_dir is None |
SGAuditFailure
|
propagated from audit_tofu_plan when the plan would expose :6080 / :7070 to the internet |
CalledProcessError
|
propagated from any tofu invocation failure |
Source code in packages/allocator/src/lablink_allocator_service/providers/aws.py
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 | |