Fix Terraform recipe failure for AWS resources with empty account in ARN#11839
Fix Terraform recipe failure for AWS resources with empty account in ARN#11839
Conversation
S3 bucket ARNs have the format arn:aws:s3:::bucket-name where both the region and account fields are empty. The ToUCPResourceID function now validates that the account field is non-empty and returns a clear error. The Terraform driver's getDeployedOutputResources now gracefully skips AWS resources whose ARNs cannot be converted to UCP resource IDs (logging and continuing) instead of failing the entire recipe deployment. This is consistent with how Azure non-ARM resources are handled. Agent-Logs-Url: https://github.com/radius-project/radius/sessions/a435ef8d-4cf5-454e-8a93-631511b9816f Co-authored-by: Reshrahim <61033581+Reshrahim@users.noreply.github.com>
|
@nithyatsu and @sylvainsf - This is an issue with S3 buckets deployment via terraform Recipe where arn comes back with an empty account and UCP rejects the id. Copilot has made a fix to gracefully skip such id's which I am not sure is the right fix. This is similar to #9946 where UCP id is fixed to include |
|
This PR requires exactly 1 of the following labels: pr:standard, pr:important. Label descriptions:
@Copilot, please add the appropriate label to this PR before merging. |
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Radius functional test overviewClick here to see the test run details
Test Status⌛ Building Radius and pushing container images for functional tests... |
There was a problem hiding this comment.
Pull request overview
This pull request fixes Terraform recipe deployments failing when AWS resources produce ARNs with an empty account segment (notably S3 bucket ARNs like arn:aws:s3:::bucket-name). Instead of generating malformed UCP IDs and treating the conversion failure as fatal, the driver now skips unconvertible AWS ARNs (while logging) so the overall recipe deployment can succeed.
Changes:
- Add explicit validation in
aws.ToUCPResourceIDto error on ARNs with an empty account segment. - Update the Terraform recipe driver to log-and-skip AWS ARNs that can’t be converted to UCP resource IDs (rather than failing the deployment).
- Add/update tests covering empty-account S3 ARNs and the new “gracefully skipped” driver behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| pkg/ucp/resources/aws/aws.go | Reject ARNs with empty account field to avoid generating malformed UCP resource IDs. |
| pkg/ucp/resources/aws/aws_test.go | Add a test case for S3 bucket ARNs with empty account. |
| pkg/recipes/driver/terraform/terraform.go | Log and skip AWS ARN→UCP ID conversion failures instead of returning an error. |
| pkg/recipes/driver/terraform/terraform_test.go | Update expectations to ensure invalid/unconvertible AWS ARNs are skipped without failing the recipe output. |
Unit Tests 2 files ±0 420 suites ±0 6m 50s ⏱️ +7s Results for commit c39bf01. ± Comparison against base commit 073b796. This pull request removes 1 and adds 3 tests. Note that renamed tests count towards both. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #11839 +/- ##
==========================================
+ Coverage 51.20% 51.21% +0.01%
==========================================
Files 715 715
Lines 45074 45077 +3
==========================================
+ Hits 23079 23086 +7
+ Misses 19798 19796 -2
+ Partials 2197 2195 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Description
S3 bucket ARNs use the format
arn:aws:s3:::bucket-namewhere both region and account fields are empty. When a Terraform recipe provisions an S3 bucket,ToUCPResourceIDproduces an invalid UCP resource ID (empty account segment), and the driver treats this as a fatal error—failing the entire recipe deployment.Changes:
pkg/ucp/resources/aws/aws.go: Validate account field inToUCPResourceID; return explicit error for empty account instead of producing a malformed UCP ID.pkg/recipes/driver/terraform/terraform.go: HandleToUCPResourceIDerrors gracefully—log and skip unconvertible ARNs (consistent with how Azure non-ARM resources are handled) rather than failing the recipe.Type of change
Contributor checklist
Please verify that the PR meets the following requirements, where applicable:
eng/design-notes/in this repository, if new APIs are being introduced.