wing icon indicating copy to clipboard operation
wing copied to clipboard

wing apps can be deployed by a `wing deploy -t <platform>` command

Open tsuf239 opened this issue 1 year ago • 18 comments

Use Case

The deploy command compiles and deploys a wing project in a single command

Proposed Solution

No response

Implementation Notes

No response

Component

No response

Community Notes

  • Please vote by adding a 👍 reaction to the issue to help us prioritize.
  • If you are interested to work on this issue, please leave a comment.
  • If this issue is labeled needs-discussion, it means the spec has not been finalized yet. Please reach out on the #dev channel in the Wing Slack.

tsuf239 avatar Feb 05 '24 14:02 tsuf239

Just a note,

My initial thoughts are that platforms should also define how they are deployed with the wing deploy command. So perhaps we just add this as another platform hook called deploy(app: App)

hasanaburayyan avatar Feb 05 '24 14:02 hasanaburayyan

Yes! and also preDeploy and postDeploy could be good, (to remove the awscdk related from the wing test command for example, I have an issue open for that)

tsuf239 avatar Feb 05 '24 14:02 tsuf239

Adding a deploy CLI command increases the surface area of the CLI and the interface between the CLI and each platform provider implementation. I'd also anticipate a lot of users might want to customize wing deploy to ensure their environment is set up a certain way (like using certain cloud provider credentials), or running validation scripts, or customize the flags provided to terraform apply etc.

Is there a strong reason for adding this? I'm wondering if the value it adds to the user justifies the long term maintenance and support, especially if we are recommending users to deploy applications within CI/CD.

As a workaround, a user can create a bash script that runs wing compile and cd <folder> && terraform apply, and that will let them deploy in a single command while being infinitely customizable.

Chriscbr avatar Feb 06 '24 01:02 Chriscbr

Is there a strong reason for adding this?

@Chriscbr yea this is one of the requested features in the user story for use cases.

CLI command increases the surface area of the CLI and the interface between the CLI and each platform provider implementation.

I think if we pawn off the actual work of deploy to the platform then the long term maintenance of these deploy commands fall on the platform provider (of which we most are owned by the wing core 😁), which would be totally customizable by overriding the deploy logic with a custom platform. Which would mean the responsibility of the cli is to only call the deploy method that is extracted by the platform manager.

Personally I dont have a strong desire to see the feature, though I do imagine that its something that users would like to see over custom shell scripts or changing directories to deploy code, since it means that a user who just wants to use lets say tf-aws needs to be familiar with the deploy procedures of a platform, adding some friction to the process.

(I also dont have anything to back up the desire for the feature besides a hunch 😁)

hasanaburayyan avatar Feb 06 '24 01:02 hasanaburayyan

We already have are some open issues about DX problems related to running deployments on the user's behalf with wing test -t tf-aws (to be honest, I'm not sure how well this capability is holding water):

  • https://github.com/winglang/wing/issues/4073
  • https://github.com/winglang/wing/issues/4996
  • https://github.com/winglang/wing/issues/4909

Some other questions:

  • How would wing deploy be experienced by first-time Wing users who have no background with AWS or Terraform? Today, terraform apply and cdk deploy and pulumi up all have different CLI output. Some show the resources you're deploying or updating, some show you progress while you're performing a deployment, some require you to approve the deployment, they all likely use terminology specific to that provisioning engine, etc. Could this be confusing?
  • There could be compatibility issues -- for example, what if the Terraform CLI has differences between versions, or if a user wants to use OpenTofu instead of Terraform? Would each Wing platform provider need to supply a list of range of terraform CLI versions or cdk CLI versions that it's compatible with? This may be additional complexity that we would have to maintain and update going forward.

Chriscbr avatar Feb 06 '24 02:02 Chriscbr

I'll start with the most straightforward and simple way and we'll build it from there- based on users' complains/constraints/bugs/issues

tsuf239 avatar Feb 06 '24 12:02 tsuf239

@markmcculloh you are the owner of the CLI, so I'll defer to you to make this call.

eladb avatar Feb 06 '24 17:02 eladb

I wish we could take on the responsibility of a deploy command but yeah I agree with the concerns raised in this thread. I'd love to see this capability exposed on platforms someday in the future but I'm not convinced we should take it on right now.

In the short term, I wonder if we're just not providing enough help/information to the user. Unless you read the docs, it's not obvious where the deployment artifacts go and what to do with them.

Unlike sim compilation, users are expected to take responsibility for the next steps with the output themselves. We could output something in the CLI to convey this.

I'm not even sure if verbosity matters since compiling to a non-sim target should not be part of a dx hot-loop.


Not to blow up this comment too much, but this feels extremely related to a wing-based build/task system, which could include the ability for user's to define their own deploy command.

MarkMcCulloh avatar Feb 06 '24 18:02 MarkMcCulloh

I totally respect the decision to not take on the deploy command, I also stand by whatever you think is best @MarkMcCulloh

for my curiosity sake though I’m just not quite sure I understand the complexities that we’re discussing here. In my mind the platform providers know where the output artifacts go (unlike a first time wing user, who would need to understand a platforms deployment model) and there’s less complexity involved than the wing test command since it’s a single app deployment and no concerns around multiple isolated stacks.

If the user is missing a required cli or some incompatible version of some tool then the error could be bubbled up and the onus is on the user to resolve.

But yea maybe I’m missing something

hasanaburayyan avatar Feb 06 '24 19:02 hasanaburayyan

Overall I think it's about which responsibilities we're exposing ourselves to. Once we have a wing deploy, we're telling users that wing itself is responsible for (and opinionated about) deployments. This exposes us to a new area of work, both as bugs and desired features/gaps.

As you're saying, I don't think implementing this itself is very difficult. Just worried about what comes after.

MarkMcCulloh avatar Feb 06 '24 22:02 MarkMcCulloh

Ok, We have to update the user story and the tutorial accordingly

tsuf239 avatar Feb 07 '24 08:02 tsuf239

Reopening. @MarkMcCulloh your call if this is something we want to keep open or close for now.

eladb avatar Feb 14 '24 08:02 eladb

We decided not to do it. Closing.

staycoolcall911 avatar Feb 19 '24 14:02 staycoolcall911

Reopening per feedback from @eladb - we'll leave this open and see if we get feedback from the community. Changing to p3 for now

staycoolcall911 avatar Feb 19 '24 16:02 staycoolcall911

This feature seems to be the epitome of the "batteries included" philosophy. Not including it would be hanging a lot of non-expert users out to dry.

Just don't try to boil the ocean. Start with the simplest possible solution -- calling the IaC tool with default parameters -- and then provide a config property for developers to insert a custom deploy command.

JensRoland avatar Oct 17 '24 09:10 JensRoland

I agree with you and we are opening to taking a contribution to add this feature. Would you be interested in working on this?

eladb avatar Oct 18 '24 09:10 eladb

image

hasanaburayyan avatar Oct 18 '24 20:10 hasanaburayyan

As far as implementation is concerned I think this could work similar to how wing secrets was implemented. Assuming its still the same, been a while since Ive been under the hood 😁

hasanaburayyan avatar Oct 18 '24 20:10 hasanaburayyan