Can't deploy without making code/manifest changes
Firstly, thanks for such an awesome tool.
I noticed I can't do a re-deploy if I don't make direct changes to the code/manifest.
When I try, I get an error along the lines:
No new infrastructure changes for stack <stack-name>.
Scenarios where I tried to deploy a service but encountered this error:
- After making a change to an environment variable value in an external parameter store
- When the service directly references a docker image location and changes have been made to the image but the tag in the manifest doesn't change (e.g using the
latesttag)
It would be nice to have a way of deploying that ignores if changes have been made or not, like a copilot svc deploy --force.
Alternatively, If there's a work around that doesn't involve having to make random minor code changes for the sake of copilot recognizing the change, I would love to know.
Thanks!
Hi @yudori !
Thanks for the detailed description, the feature request makes a lot of sense! I believe this is a duplicate of #2521.
A slight complication of the existing proposal is that when users run copilot deploy --force with modifications to their code or manifest, they would expect the cloudformation stack to get updated.
Therefore, we would need a way of detecting whether --force should map to force-new-deployment for UpdateService or should be ignored.
One thing that we can do is catch the error here to see if it's ErrChangeSetEmpty:
https://github.com/aws/copilot-cli/blob/07eaba8bcc6ed13e0f8c9fdb22b52f235b7ca63c/internal/pkg/cli/svc_deploy.go#L461-L463
and if so, then we check if --force is set and do a force-new-deployment instead with the AWS SDK.
Thanks for the explanation @efekarakus . That makes sense to me.
Also wonder if you considered having something like a --empty flag instead which would be solely responsible for triggering an empty deployment whether there are changes or not.
So regular deployments behave the same way but with a revised error message like:
No new infrastructure changes for stack <stack-name>. Use '--empty' to trigger an empty deployment
And copilot deploy --empty is an explicit call to ignore any changes that was made and call a force-new-deployment with the changes ignored.
Disclaimer: I've barely written any .go code before and have little knowledge of how much effort this would take. Also 'empty' might not be the best name since it could be understood as deploying 'nothing', but I couldn't think of a better name :)
That said, the prior (--force) option probably makes more sense since it's more in sync with the existing force-new-deployment behavior on ecs cli.
👍 for this feature or something similar. I came across this situation by building and pushing to the ecr registry at the latest tag via build steps in my own CI pipeline, and then just deploying with copilot with the image.location field is set to the image latest url.
I wonder if another alternative solution to the --force flag might be parameterizing the copilot svc deploy command to accept the image.location field, or maybe just env vars in general that get applied to the manifest file (similar to how docker-compose files can be parameterized via env vars)
The feature is now released! https://github.com/aws/copilot-cli/releases/tag/v1.10.0 🥳