create AWS infra

This commit is contained in:
2026-05-15 10:26:43 -04:00
parent 6563b4cc4b
commit 1bc5052d22
21 changed files with 1502 additions and 0 deletions

22
src/aws/cloudformation.py Normal file
View File

@@ -0,0 +1,22 @@
from typing import Any
import boto3
from botocore.exceptions import ClientError
from src.infra.provisioning import STACK_NAME
def stack_status(region: str, profile: str) -> dict[str, Any] | None:
client = boto3.Session(profile_name=profile, region_name=region).client("cloudformation")
try:
stack = client.describe_stacks(StackName=STACK_NAME)["Stacks"][0]
except ClientError as e:
message = e.response.get("Error", {}).get("Message", "")
if "does not exist" in message:
return None
raise
return {
"name": stack["StackName"],
"status": stack["StackStatus"],
"outputs": {item["OutputKey"]: item.get("OutputValue", "") for item in stack.get("Outputs", [])},
}