Hello there! Just a newbie . Want to get(FastApi) ...
# automation-api
a
Hello there! Just a newbie . Want to get(FastApi) a list os my stacks(backend in GCP). Any idea?
b
hey! can you elaborate a bit more? are you using automation API?
a
Yes. I am.
class ResourceGroupRequest(BaseModel): azure_location: str app = FastAPI() def run_pulumi_program(stack_name, external_program): project_settings = auto.ProjectSettings( name=PROJECT_NAME, runtime="python", backend={"url": GCS_BUKET}, ) stack_settings = auto.StackSettings(secrets_provider=GCP_HMS) stack = auto.create_or_select_stack( stack_name=stack_name, project_name=PROJECT_NAME, program=external_program, opts=auto.LocalWorkspaceOptions( project_settings=project_settings, secrets_provider=GCP_HMS, stack_settings={stack_name: stack_settings}, ), ) print("successfully initialized stack") print("setting up config") up_res = stack.up(on_output=print) print("refreshing stack") stack.refresh(on_output=print) print("refresh complete") pulumi.export("output_stack", f"{output_value_from_code}") @app.post("/azure/{resource_group}") async def create(resource_group: str, infra: ResourceGroupRequest): stack_name = f"rg-{resource_group}" nat = f"nat-{resource_group}" natip = f"ip-{resource_group}" gateway = f"gtw-{resource_group}" def pulumi_program(): return create_resource_group(infra.azure_location, resource_group) run_pulumi_program(stack_name, pulumi_program)
Did this for the creation of a resource group. now I want to List all the stacks and delete