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

chore: allow initializing and deploying environments with copilot deploy #5215

Merged
merged 45 commits into from
Aug 29, 2023

Conversation

bvtujo
Copy link
Contributor

@bvtujo bvtujo commented Aug 23, 2023

Milestone 2 of the deploy enhancements. This allows customers to initialize and deploy environments during copilot deploy.

for example

copilot deploy --deploy-env --env dev --name frontend

The new logic is as follows.

  1. Prompt for workload name, including uninitialized local workloads.
  2. Prompt for environment name, including uninitialized local environments.
  3. Check whether the selected environment exists and set some flags (envExistsInApp and envExistsINWs)
  4. If the env doesn't exist, initialize it.
  5. If the env was just initialized, immediately proceed to deploying it. Otherwise, prompt for deploying the environment.
  6. If the workload doesn't exist, prompt for initializing it.
  7. Deploy the workload.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the Apache 2.0 License.

@bvtujo bvtujo requested a review from a team as a code owner August 23, 2023 15:30
@bvtujo bvtujo requested review from KollaAdithya and removed request for a team August 23, 2023 15:30
@github-actions
Copy link

github-actions bot commented Aug 23, 2023

🍕 Here are the new binary sizes!

Name New size (kiB) size (kiB) Delta (%)
macOS (amd) 51712 51488 +0.44
macOS (arm) 51916 51684 +0.45
linux (amd) 45532 45324 +0.46
linux (arm) 43780 43588 +0.44
windows (amd) 42332 42144 +0.45

chore: fix compilation errors

chore: undo changes to LocalEnvSelector

chore: fix env selector
@codecov-commenter
Copy link

codecov-commenter commented Aug 24, 2023

Codecov Report

Merging #5215 (447787a) into mainline (d19b2af) will decrease coverage by 0.04%.
Report is 1 commits behind head on mainline.
The diff coverage is 60.76%.

@@             Coverage Diff              @@
##           mainline    #5215      +/-   ##
============================================
- Coverage     69.83%   69.80%   -0.04%     
============================================
  Files           296      296              
  Lines         44326    44518     +192     
  Branches        286      286              
============================================
+ Hits          30955    31074     +119     
- Misses        11875    11942      +67     
- Partials       1496     1502       +6     
Files Changed Coverage Δ
internal/pkg/cli/flag.go 90.47% <ø> (ø)
internal/pkg/cli/deploy.go 48.42% <57.59%> (+12.34%) ⬆️
internal/pkg/term/selector/selector.go 79.44% <92.85%> (+0.09%) ⬆️
internal/pkg/cli/init.go 24.13% <100.00%> (ø)
internal/pkg/cli/task_delete.go 59.53% <100.00%> (ø)
internal/pkg/cli/task_exec.go 57.71% <100.00%> (ø)
internal/pkg/cli/task_run.go 53.92% <100.00%> (ø)

Copy link
Contributor

@iamhopaul123 iamhopaul123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM awesome!

internal/pkg/cli/deploy.go Outdated Show resolved Hide resolved
internal/pkg/cli/deploy.go Outdated Show resolved Hide resolved
internal/pkg/cli/deploy.go Outdated Show resolved Hide resolved
internal/pkg/cli/deploy.go Outdated Show resolved Hide resolved
internal/pkg/cli/deploy.go Outdated Show resolved Hide resolved
internal/pkg/cli/deploy.go Outdated Show resolved Hide resolved
return fmt.Errorf("env %s does not exist in app %s", o.envName, o.appName)
}

func (o *deployOpts) maybeDeployEnv() error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think one case that this does not handle is this:

$copilot deploy
Which env?
> test (initted, but not in workspace and not-yet deployed)

# Error when trying to deploy svc to "test", because the test env isn't deployed yet.

I think it is fine to not handle this case, at least not for this release though! I just want to call out that this might be something that we want to support. But again, not a blocking issue at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

understood. I think there may be a big refactor of the init and deploy experiences coming soonish and we could better support this case. as of right now though I don't think we have special checks in place to see whether the env is initted but not deployed even in copilot svc deploy or the like.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is done here!

if currVersion == version.EnvTemplateBootstrap {

There were a few changes regarding what env init do in the last year. env init, in addition to create SSM parameters, it also deploys an environment stack that contains _only) env manager role and cfn execution role - sort of like the CDK bootstrap stack.

The bootstrap stack's template "version" is a special string and can be used to determine the state of an environment.

This is just a note for future refactor! Not a request to update this PR :shipit:

@Lou1415926 Lou1415926 added the do-not-merge Pull requests that mergify shouldn't merge until the requester allows it. label Aug 28, 2023
@bvtujo bvtujo removed the do-not-merge Pull requests that mergify shouldn't merge until the requester allows it. label Aug 29, 2023
@mergify mergify bot merged commit a50d809 into aws:mainline Aug 29, 2023
12 checks passed
KollaAdithya pushed a commit to KollaAdithya/copilot-cli that referenced this pull request Oct 18, 2023
…loy (aws#5215)

Milestone 2 of the deploy enhancements. This allows customers to initialize and deploy environments during copilot deploy. 

for example

```sh
copilot deploy --deploy-env --env dev --name frontend
```

The new logic is as follows. 
1. Prompt for workload name, including uninitialized local workloads.
2. Prompt for environment name, including uninitialized local environments.
3. Check whether the selected environment exists and set some flags (envExistsInApp and envExistsINWs)
4. If the env doesn't exist, initialize it. 
5. If the env was just initialized, immediately proceed to deploying it. Otherwise, prompt for deploying the environment.
6. If the workload doesn't exist, prompt for initializing it.
7. Deploy the workload. 



By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the Apache 2.0 License.
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

Successfully merging this pull request may close these issues.

None yet

4 participants