-
Notifications
You must be signed in to change notification settings - Fork 427
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
fix: KMS access denied errors when downloading the static env file #5514
Conversation
This workaround worked for fixing deployments for a Backend Service with Copilot 1.32.0: - op: replace
path: /Resources/ExecutionRole/Properties/Policies/0/PolicyDocument/Statement/2/Resource/0
value: arn:aws:kms:....:key/... # the KMS key's ARN, which you see exported on the app's CloudFormation stack |
🍕 Here are the new binary sizes!
|
This line might also be buggy copilot-cli/internal/pkg/template/templates/workloads/partials/cf/instancerole.yml Line 60 in cce61ba
UPDATE: yes, it was, fixed it in a later commit. |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## mainline #5514 +/- ##
=========================================
Coverage 70.03% 70.04%
=========================================
Files 302 302
Lines 46064 46078 +14
Branches 309 309
=========================================
+ Hits 32263 32277 +14
- Misses 12234 12237 +3
+ Partials 1567 1564 -3 ☔ View full report in Codecov by Sentry. |
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.
Awesome! Thank you for fixing this bug!
@@ -11,6 +11,7 @@ | |||
"LogRetention": "30", | |||
"ContainerPort": "8080", | |||
"EnvFileARN": "", | |||
"ArtifactKeyARN": "", |
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.
Can we in at least one integ test verifying ArtifactKeyARN
can be rendered correctly with the app stackset resource info?
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.
Sure, will address your points tomorrow, @iamhopaul123 |
@iamhopaul123 I believe I have resolved both of your remarks, see my last 2 commits |
Looks good! Thank you! |
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.
Changes look good to me! Thanks so much for contributing ❤️
Bug description
Since Copilot 1.32.0 cross account deployments are broken for all services (except static website) due to lacking permissions on the task execution role to perform the
kms:Decrypt
operation on the required key.Background
Since #5329 the artifacts are encrypted with a Kms Key, which belongs to the App stack.
Due to the wrong configuration of the
ExecutionRole
resource if one deploys the workload to a different account than where the app stack is located, the download of the env file fails due to the lackingkms:Decrypt
permission on the corresponding key.https://github.com/bencehornak/copilot-cli/blob/67db7a2d4f94c69c836586f714341e587b1b8220/internal/pkg/template/templates/workloads/partials/cf/executionrole.yml#L39-L43
Note that this policy grants access to all keys in the workload's account (which is not a great practice either, see #4628), which is wrong, considering that the key is located in the app's account.
Fix
The policy was changed to the following:
where
ArtifactKeyARN
is the ARN of the Kms Key.TODO
Conclusion
Fixes partially: #4628.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the Apache 2.0 License.