pulumi/automation-api-examples

Remote deployment from Git source fails

Closed this issue · 1 comments

What happened?

Running stack.up fails:

2024-09-04 12:31:51.559 CEST
$ curl --retry 5 -H "Authorization: token $PULUMI_ACCESS_TOKEN" "$PULUMI_SERVICE_URL/deployments/executor" -o /pulumi-deploy-executor.gz && gzip -d /pulumi-deploy-executor.gz && chmod +x /pulumi-deploy-executor
2024-09-04 12:32:02.281 CEST
  File "/code/api/pulumi.py", line 22, in create_or_update_stack
2024-09-04 12:32:02.281 CEST
    res = stack.up(on_output=print)
2024-09-04 12:32:02.281 CEST
          ^^^^^^^^^^^^^^^^^^^^^^^^^
2024-09-04 12:32:02.281 CEST
  File "/usr/local/lib/python3.11/site-packages/pulumi/automation/_remote_stack.py", line 59, in up
2024-09-04 12:32:02.281 CEST
    return self.__stack.up(on_output=on_output, on_event=on_event)
2024-09-04 12:32:02.281 CEST
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-09-04 12:32:02.281 CEST
  File "/usr/local/lib/python3.11/site-packages/pulumi/automation/_stack.py", line 375, in up
2024-09-04 12:32:02.281 CEST
    assert summary is not None
2024-09-04 12:32:02.281 CEST
           ^^^^^^^^^^^^^^^^^^^
2024-09-04 12:32:02.281 CEST
AssertionError

Example

import os
import json
from pulumi import automation as auto

personal_access_token = os.environ['GITHUB_ACCESS_TOKEN']
username = os.environ['USERNAME']
project = os.environ['PROJECT']
gcp_project = os.environ['GCP_PROJECT']
repo = os.environ['GITHUB_REPOSITORY_URL']
path = os.environ['PATH']


def create_or_update_stack(tenant_id: str):
	stack_name = auto.fully_qualified_stack_name(username, project, f'env-{tenant_id}')
	stack = auto.create_or_select_remote_stack_git_source(
		stack_name=stack_name,
		url=repo,
		branch="refs/heads/master",
		project_path=path,
		auth=auto.RemoteGitAuth(personal_access_token=personal_access_token),
		opts=auto.RemoteWorkspaceOptions(
			env_vars={
				"GCP_PROJECT": gcp_project
			}
		)
	)
	res = stack.up(on_output=print)
	print(f"update summary: \n{json.dumps(res.summary.resource_changes, indent=4)}")
	print(f"app url: {res.outputs}")


def delete_stack(tenant_id: str):
	stack_name = auto.fully_qualified_stack_name(username, project, f'env-{tenant_id}')
	stack = auto.select_remote_stack_git_source(
		stack_name=stack_name,
		url=repo,
		branch="refs/heads/master",
		project_path=path,
		auth=auto.RemoteGitAuth(personal_access_token=personal_access_token),
		opts=auto.RemoteWorkspaceOptions(
			env_vars={
				"GCP_PROJECT": gcp_project
			}
		)
	)
	stack.destroy(on_output=print)
	stack.workspace.remove_stack(stack_name)

Output of pulumi about

CLI          
Version      3.127.0
Go Version   go1.22.5
Go Compiler  gc

Plugins
KIND      NAME        VERSION
resource  gcp         7.32.0
resource  kubernetes  4.15.0
language  python      unknown
resource  random      4.16.3

Host     
OS       debian
Version  12.6
Arch     x86_64

This project is written in python: executable='/home/osboxes/Workspace/secator-cloud-pulumi/k8s/venv/bin/python3' version='3.11.2'

Backend        
Name           pulumi.com
URL            https://app.pulumi.com/ocervell
User           ocervell
Organizations  ocervell
Token type     personal

Dependencies:
NAME               VERSION
pip                24.1.2
pulumi_gcp         7.32.0
pulumi_kubernetes  4.15.0
pulumi_random      4.16.3
setuptools         70.3.0
wheel              0.43.0

Pulumi locates its logs in /tmp by default
warning: Failed to get information about the current stack: No current stack

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

Thanks for the issue @ocervell. We'll use pulumi/pulumi#17155 to track this.