• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

elastic / cloudbeat / 41634405209
63%
main: 76%

Build:
Build:
LAST BUILD BRANCH: mergify/bp/9.5/pr-9230
DEFAULT BRANCH: main
Ran 03 Nov 2026 12:37PM UTC
Jobs 1
Files 245
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

03 Nov 2026 12:16PM UTC coverage: 62.781% (+1.7%) from 61.032%
41634405209

push

github

web-flow
fix(aws): use the partition of the caller identity in organization mode (GovCloud, CSPM, CAD) (#9230)

### Summary of your changes

Organization mode fails in AWS GovCloud for CSPM and CAD. Cloudbeat
writes the role ARNs with the commercial partition (`arn:aws:iam::`). In
GovCloud, the role ARNs must start with `arn:aws-us-gov:iam::`. STS
cannot assume a role in a different partition. Thus, the `AssumeRole`
call fails for the root role and for each member role.

This PR gets the partition from the ARN of the caller identity
(`GetCallerIdentity`). Cloudbeat then uses this partition for all role
ARNs in organization mode.

Changes:

- `awslib/partition.go` (new file): `PartitionFromARN` and `IAMRoleARN`.
These functions replace the two copies of `fmtIAMRole`. If the ARN is
empty or not valid, `PartitionFromARN` returns `aws`. Thus, the behavior
in the commercial partition does not change. `PartitionFromRegion` uses
the same partition constants (new constant `ChinaPartition`).
- `cloud.Identity`: new field `Partition`. The AWS providers always set
it.
- `awslib.IdentityProvider.GetIdentity`: sets `Partition` from the
caller ARN.
- `awslib.AccountProvider.ListAccounts`: sets `Partition` of each member
account from the ARN of the account in the Organizations `ListAccounts`
response.
- `awslib/govcloud.go` (new file): `WithGovCloudFallback`. If the
identity call fails and the configuration has no default region, it
tries again in `us-gov-east-1`. If the second call also fails, the error
contains the errors of the two calls. CSPM (`benchmark/aws.go`,
`benchmark/aws_org.go`) and CAD use this helper.
- `iam.Provider`: the ARN of the AWS managed policy `AWSSupportAccess`
uses the partition of the region
(`arn:aws-us-gov:iam::aws:policy/AWSSupportAccess` in GovCloud). Before,
`GetPolicy` failed in GovCloud, and `GetPolicies` returned no policies.
- CSPM (`benchmark/aws_org.go`):
- The ARN of the `cloudbeat-root` role uses the partition of the caller
ARN.
- The A... (continued)

50 of 75 new or added lines in 10 files covered. (66.67%)

1 existing line in 1 file now uncovered.

7437 of 11846 relevant lines covered (62.78%)

10.11 hits per line

Uncovered Changes

Lines Coverage ∆ File
14
46.77
39.23% internal/flavors/assetinventory/strategy_aws.go
6
41.83
1.83% internal/flavors/benchmark/aws_org.go
5
3.77
0.07% internal/flavors/benchmark/aws.go

Coverage Regressions

Lines Coverage ∆ File
1
79.42
-0.36% internal/resources/providers/gcplib/inventory/provider.go
Jobs
ID Job ID Ran Files Coverage
1 41634405209.1 03 Nov 2026 12:37PM UTC 245
62.78
GitHub Action Run
Source Files on build 41634405209
  • Tree
  • List 245
  • Changed 23
  • Source Changed 0
  • Coverage Changed 23
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • d89131c7 on github
  • Prev Build on gh-readonly-queue/main/pr-9719-895541e9615a07ae565aaca9225274658a749e44 (#41596020436)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc