GeezerVison is showing github.com — chore(cli): deploy and update task resources for `task run` by Louise15926 · Pull Request #1176 · aws/copilot-cli
This repository was archived by the owner on Jun 22, 2026. It is now read-only.
Conversation
This PR implements Execute for task run
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Louise15926
changed the title
chore(cli): execute taks run
chore(cli): deploy and update task resources for task run
Jul 22, 2020
Uh oh!
There was an error while loading. Please reload this page.
|
|
}
|
|
|
|
|
|
return &runTaskOpts{
|
|
|
sess, err := session.NewProvider().Default()
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a user provides an environment after Ask or with flags, we should instead use the environment manager role to create the task stack:
|
envSession, err := o.sessProvider.FromRole(o.targetEnvironment.ManagerRoleARN, o.targetEnvironment.Region) |
This is a role that Copilot creates when a user runs copilot env init for developers to assume and create/monitor their services or tasks.
The way we've been initializing clients that require data after the Ask method is with function fields, for example:
|
initCwLogsSvc: func(o *svcLogsOpts, envName string) error { |
|
env, err := o.configStore.GetEnvironment(o.AppName(), envName) |
|
if err != nil { |
|
return fmt.Errorf("get environment: %w", err) |
|
} |
|
sess, err := session.NewProvider().FromRole(env.ManagerRoleARN, env.Region) |
|
if err != nil { |
|
return err |
|
} |
|
o.cwlogsSvc[env.Name] = cloudwatchlogs.New(sess) |
|
return nil |
The reason is that in our tests we can override the initCwLogsSvc field to return a mock instead. This way we don't need to define global variables in the code.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the second one (initializing clients): that's exactly what I did! it's coming in the next PR.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
efekarakus reacted with thumbs up emoji
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually have coded everything for task_run.go but the PR got too large, so I split it into three smaller ones. This is the first of the smaller PR.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will use envSession to configure runtime clients in the next PR (since this PR doesn't involve any runtime clients yet)
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
|
|
}
|
|
|
|
|
|
func (o *runTaskOpts) deployTaskResources() error {
|
|
|
o.spinner.Start(fmt.Sprintf("Deploying resources for task %s", color.HighlightUserInput(o.groupName)))
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like it would be nice for users to get a sense of the type of resources that we need to create to run the task. What do you think of?
|
o.spinner.Start(fmt.Sprintf("Deploying resources for task %s", color.HighlightUserInput(o.groupName))) |
|
o.spinner.Start(fmt.Sprintf("Creating a task definition for %s and the necessary permissions", color.HighlightUserInput(o.groupName))) |
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that! Then should I also mention the ECR repo and log group that are also created?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't sure about that in case this step only did a stack update instead of create 🤔
Do you know which resource takes the longest to create? I feel like as long as we mention that one the rest shouldn't matter as much 8)
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact, neither of the stack resource (roles, ecr repo, log group) takes long to provision. From CloudFormation console, each of them takes about 1-2seconds to create lol.
Task definition is not created at the first call; it's only created/updated after the image is pushed, i.e. the second call. During the second call, it takes ~2 seconds to create the task definition - according to CloudFormation console.
So most of the waiting is spent on building and pushing images, and waiting for tasks to start.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't sure about that in case this step only did a stack update instead of create 🤔
We can perhaps use the word 'Preparing' instead of 'Creating' or 'Deploying', if we want to include ECR/log group.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
piradeepk
Jul 22, 2020
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to use Provisioning resources for task %s instead of preparing?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Louise15926 reacted with thumbs up emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A minor comment, but looks great! 💯
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
bvtujo
Awaiting requested review from bvtujo
2 more reviewers
Reviewers whose approvals may not affect merge requirements
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|