Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autodeploy deploying into wrong account #25

Open
dhoulker opened this issue Oct 15, 2024 · 7 comments
Open

Autodeploy deploying into wrong account #25

dhoulker opened this issue Oct 15, 2024 · 7 comments

Comments

@dhoulker
Copy link

dhoulker commented Oct 15, 2024

I've raised this in Discord, but raising here as well incase any else has the same problem and can help.

We are running into a strange issue with autodeploy. We have 4 environments, mapped to 3 AWS accounts (pr's and dev go to dev account) When we merge into production, the deploy runs, but it deploys into the dev account. I think my SST config is correct as i can see sst deploy --stage prd running in the logs when i merge into prod branch.

In the screenshot, you can see the 4 environments, but prd deploy does not deploy to expected account. I'm sure i'm missing something obvious here, how can i debug it?

image

You can see below the merge into production triggers sst deploy --stage prd

I'm sure i'm doing something wrong, but i'm not sure how to debug this further, does anyone have idea what could be going wrong or steps i can follow to find out whats happening?

image

image

Thanks!

@jayair
Copy link
Contributor

jayair commented Oct 18, 2024

Following up there for now

@dhoulker
Copy link
Author

Thanks @jayair - the console channel has been archived, so i can't respond there. You asked:

"So from the second screenshot here, it's saying that it's deploying to a stage called prd. Now if you go to the app page where it lists all the stages, what's the AWS account listed by prd?"

What happened was we ended up with two prd stages there.

  1. Deployed by autodeploy to the wrong account
  2. The one we deploy manually with sst deploy --stage prd locally, as it was the only route to production

I had to kill the the first one by setting my terminal profile to dev, then running sst remove --stage prd

Like I say, sure i'm doing something wrong just not sure how to debug.

We removed the AWS prod account from the console and re-added, but same thing just happened again.

@jayair
Copy link
Contributor

jayair commented Oct 19, 2024

Do you have an auto deploy block in your sst config?

@dhoulker
Copy link
Author

I do - i assumed this was not the issue as i can see sst deploy --stage prd when merging into the production branch, however maybe i'm wrong.

It looks like this:

console: {
  autodeploy: {
	target(event) {
		// staging -> stg
		if (
			event.type === "branch" &&
			event.branch === "staging" &&
			event.action === "pushed"
		) {
			return { stage: "stg" };
		}
		// production -> prd
		if (
			event.type === "branch" &&
			event.branch === "production" &&
			event.action === "pushed"
		) {
			return { stage: "prd" };
		}
		// dev -> dev
		if (
			event.type === "branch" &&
			event.branch === "dev" &&
			event.action === "pushed"
		) {
			return { stage: "dev" };
		}

		// only create a stage for PRs that are targeting the dev branch
		if (event.type === "pull_request" && event.base === "dev") {
			return { stage: `pr${event.number}` };
		}
	},
  },
},
	```

@dhoulker
Copy link
Author

Hi @jayair, any ideas on what else i can try here? Do you see any issues with my config above?

@jayair
Copy link
Contributor

jayair commented Nov 1, 2024

So is prd supposed to deploy to a stage with the id ending in 414?

@dhoulker
Copy link
Author

dhoulker commented Nov 2, 2024

Yes, thats correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants