Skip to content

fix: allow copilot to delete access logs s3 buckets on env delete#5184

Merged
mergify[bot] merged 29 commits intoaws:mainlinefrom
CaptainCarpensir:aiden/env-access-logs-bucket-delete
Aug 16, 2023
Merged

fix: allow copilot to delete access logs s3 buckets on env delete#5184
mergify[bot] merged 29 commits intoaws:mainlinefrom
CaptainCarpensir:aiden/env-access-logs-bucket-delete

Conversation

@CaptainCarpensir
Copy link
Copy Markdown
Contributor

@CaptainCarpensir CaptainCarpensir commented Aug 10, 2023

Makes four changes to env delete to allow copilot to delete S3 buckets managed by the environment, particularly the access logs bucket. These are the following changes:

  1. Remove the CreateALB condition from the access logs bucket. This will cause the bucket to be created as soon as it’s configured in the manifest and deployed to the environment, and not require any services to be deployed. This will then mean that the resource isn’t deleted as the final service is deleted from the environment.
  2. Add an EnvManagerRole permission to empty the access logs bucket.
  3. On env delete empty the bucket before the stack deletion. Then, the stack deletion should run normally and continue without errors.
  4. In the event env delete fails to delete a bucket, warn the user that they need to delete it manually.

If a user redeploys their environment before deleting an environment, this change fixes the problem completely. If not, it will warn them to delete the bucket manually.

Addresses #4218

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

@CaptainCarpensir CaptainCarpensir requested a review from a team as a code owner August 10, 2023 22:55
@CaptainCarpensir CaptainCarpensir requested review from dannyrandall and removed request for a team August 10, 2023 22:55
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Aug 10, 2023

🍕 Here are the new binary sizes!

Name New size (kiB) size (kiB) Delta (%)
macOS (amd) 51624 51488 +0.26
macOS (arm) 51828 51680 +0.29
linux (amd) 45444 45324 +0.26
linux (arm) 43716 43588 +0.29
windows (amd) 42252 42144 +0.26

Copy link
Copy Markdown
Contributor

@Lou1415926 Lou1415926 left a comment

Choose a reason for hiding this comment

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

This LGTM!! Great job

Comment thread internal/pkg/cli/env_delete.go
Comment thread internal/pkg/cli/env_delete.go Outdated
Comment thread internal/pkg/cli/env_delete.go Outdated
Comment thread internal/pkg/cli/env_delete.go Outdated
Comment thread internal/pkg/cli/env_delete.go Outdated
Comment thread internal/pkg/cli/env_delete.go Outdated
Comment thread internal/pkg/cli/env_delete.go Outdated
Comment thread internal/pkg/cli/errors.go Outdated
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Aug 11, 2023

Codecov Report

Merging #5184 (e44e43f) into mainline (a9f96c9) will decrease coverage by 0.02%.
Report is 1 commits behind head on mainline.
The diff coverage is 60.25%.

❗ Current head e44e43f differs from pull request most recent head 3d1e7b6. Consider uploading reports for the commit 3d1e7b6 to get more accurate results

@@             Coverage Diff              @@
##           mainline    #5184      +/-   ##
============================================
- Coverage     69.53%   69.52%   -0.02%     
============================================
  Files           295      295              
  Lines         43819    43896      +77     
  Branches        285      285              
============================================
+ Hits          30471    30517      +46     
- Misses        11863    11889      +26     
- Partials       1485     1490       +5     
Files Changed Coverage Δ
internal/pkg/cli/errors.go 61.29% <0.00%> (-7.81%) ⬇️
internal/pkg/deploy/cloudformation/stack/env.go 79.00% <ø> (ø)
internal/pkg/cli/env_delete.go 58.44% <66.19%> (+1.74%) ⬆️

@huanjani
Copy link
Copy Markdown
Contributor

👏🏼 Great job! And nice unit tests!

@huanjani huanjani added the do-not-merge Pull requests that mergify shouldn't merge until the requester allows it. label Aug 11, 2023
Copy link
Copy Markdown
Contributor

@huanjani huanjani left a comment

Choose a reason for hiding this comment

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

Feel free to remove the DNM label when you're done with the error-handling piece.

Comment thread internal/pkg/cli/env_delete.go Outdated
@CaptainCarpensir CaptainCarpensir marked this pull request as draft August 14, 2023 16:28
@CaptainCarpensir CaptainCarpensir marked this pull request as ready for review August 15, 2023 18:29
@CaptainCarpensir CaptainCarpensir removed the do-not-merge Pull requests that mergify shouldn't merge until the requester allows it. label Aug 15, 2023
Comment thread internal/pkg/cli/env_delete.go Outdated
Comment thread internal/pkg/cli/env_delete.go
Comment thread internal/pkg/cli/env_delete.go Outdated
Comment thread internal/pkg/cli/env_delete.go Outdated
Comment thread internal/pkg/cli/env_delete.go Outdated
Aiden Carpenter added 3 commits August 15, 2023 15:18
go doesn't like when i format strings without using a formatting directive
Copy link
Copy Markdown
Contributor

@Lou1415926 Lou1415926 left a comment

Choose a reason for hiding this comment

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

LGTM!

Comment thread internal/pkg/template/templates/environment/partials/environment-manager-role.yml Outdated
Comment thread internal/pkg/deploy/cloudformation/stack/env.go Outdated
Comment thread internal/pkg/cli/env_delete.go Outdated
Comment thread internal/pkg/cli/env_delete.go Outdated
Copy link
Copy Markdown
Contributor

@Lou1415926 Lou1415926 left a comment

Choose a reason for hiding this comment

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

lgtm, feel free to remove the label when you are ready!

Comment thread internal/pkg/deploy/cloudformation/stack/env.go Outdated
Comment thread internal/pkg/cli/env_delete.go
Comment thread internal/pkg/cli/env_delete.go
Comment thread internal/pkg/cli/errors.go
@Lou1415926 Lou1415926 added the do-not-merge Pull requests that mergify shouldn't merge until the requester allows it. label Aug 16, 2023
@CaptainCarpensir CaptainCarpensir removed the do-not-merge Pull requests that mergify shouldn't merge until the requester allows it. label Aug 16, 2023
@mergify mergify Bot merged commit 37a49be into aws:mainline Aug 16, 2023
mergify Bot pushed a commit that referenced this pull request Aug 29, 2023
Removes the spinner for emptying buckets. This is because most applications won't actually have any s3 buckets to delete, and showing this is highly misleading to users.


Follow up to #5184 

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the Apache 2.0 License.
@CaptainCarpensir CaptainCarpensir deleted the aiden/env-access-logs-bucket-delete branch September 14, 2023 18:28
KollaAdithya pushed a commit to KollaAdithya/copilot-cli that referenced this pull request Oct 18, 2023
Removes the spinner for emptying buckets. This is because most applications won't actually have any s3 buckets to delete, and showing this is highly misleading to users.


Follow up to aws#5184 

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

Archived in project

Development

Successfully merging this pull request may close these issues.

6 participants