Skip to content

feat: Add AWS external_id support in sigv4 configuration - #5157

Merged
siavashs merged 2 commits into
prometheus:mainfrom
dongjiang1989:update-sigv4
Jul 21, 2026
Merged

siavashs merged 2 commits into
prometheus:mainfrom
dongjiang1989:update-sigv4

Conversation

@dongjiang1989

@dongjiang1989 dongjiang1989 commented Apr 7, 2026 •

Copy link
Copy Markdown
Member

Pull Request Checklist

Which user-facing changes does this PR introduce?

[ENHANCEMENT] sigv4: Add AWS external_id support

@dongjiang1989
dongjiang1989 requested a review from a team as a code owner April 7, 2026 12:38
@coderabbitai

coderabbitai Bot commented Apr 7, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: ca5812b6-f67c-4fa4-b1be-61512d62ef4e

📥 Commits

Reviewing files that changed from the base of the PR and between 86ab742 and 323d736.

📒 Files selected for processing (3)
  • docs/configuration.md
  • notify/sns/sns.go
  • notify/sns/sns_test.go
🚧 Files skipped from review as they are similar to previous changes (3)
  • docs/configuration.md
  • notify/sns/sns.go
  • notify/sns/sns_test.go

📝 Walkthrough

Walkthrough

Adds optional external_id support to SNS SigV4 configuration, documents its relationship with role_arn, forwards it to STS role assumption, and updates SNS test configuration.

Changes

SNS SigV4 external ID

Layer / File(s) Summary
Configure and pass SigV4 external ID
docs/configuration.md, notify/sns/sns.go, notify/sns/sns_test.go
Documents the optional external_id, conditionally passes it to the STS assume-role provider, and adds it to SNS test setup.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and clearly describes the main change: adding AWS external_id support to sigv4 configuration.
Description check ✅ Passed The description follows the template well, includes checklist items and release notes, and is sufficiently complete for this change.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
notify/sns/sns.go (1)

143-158: ⚠️ Potential issue | 🟡 Minor

Enforce external_id + role_arn coupling at runtime.

external_id is only read inside the role_arn branch (Line 143), so a config with external_id but no role_arn is silently ignored. Since docs declare this constraint, add an explicit error to fail fast on invalid config.

Suggested guard
 func (n *Notifier) createSNSClient(ctx context.Context, tmpl func(string) string, tmplErr *error) (*sns.Client, error) {
+	if n.conf.Sigv4.ExternalID != "" && n.conf.Sigv4.RoleARN == "" {
+		return nil, fmt.Errorf("sns.sigv4.external_id requires sns.sigv4.role_arn")
+	}
+
 	// Base configuration options that apply to both STS (if used) and the final SNS client.
 	baseCfgOpts := []func(*awsconfig.LoadOptions) error{
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@notify/sns/sns.go` around lines 143 - 158, The code currently ignores
n.conf.Sigv4.ExternalID when n.conf.Sigv4.RoleARN is empty; add a runtime guard
before the STS branch (the block that creates stsClient/stsProvider) that
validates the coupling: if n.conf.Sigv4.ExternalID is set but
n.conf.Sigv4.RoleARN is empty, return an error (from the function that
initializes the SNS client) indicating invalid config. Reference the config
fields n.conf.Sigv4.ExternalID and n.conf.Sigv4.RoleARN and perform this check
prior to calling awsconfig.LoadDefaultConfig / sts.NewFromConfig /
stscreds.NewAssumeRoleProvider so the function fails fast on the invalid
configuration.
🧹 Nitpick comments (1)
notify/sns/sns_test.go (1)

121-123: Current test data includes ExternalID but does not verify the new behavior.

This case still only asserts template failures. Please add a focused test that verifies ExternalID is passed to STS AssumeRole when role_arn is set (and omitted when it is not), so the new feature is actually regression-protected.

Also applies to: 137-139

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@notify/sns/sns_test.go` around lines 121 - 123, Add a focused unit test that
asserts ExternalID is forwarded to STS.AssumeRole when a RoleARN is provided and
omitted when no RoleARN is set: in the sns_test.go tests that set
Region/RoleARN/ExternalID (symbols: RoleARN and ExternalID) create a mock STS
client and verify its AssumeRole invocation includes the ExternalId parameter
when RoleARN is set, and that AssumeRole is called without ExternalId (or not
called at all if implementation skips assume) when RoleARN is empty; update or
add two assertions (one for the positive case and one for the negative case) to
guard the new behavior so ExternalID regressions are caught.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@notify/sns/sns.go`:
- Around line 143-158: The code currently ignores n.conf.Sigv4.ExternalID when
n.conf.Sigv4.RoleARN is empty; add a runtime guard before the STS branch (the
block that creates stsClient/stsProvider) that validates the coupling: if
n.conf.Sigv4.ExternalID is set but n.conf.Sigv4.RoleARN is empty, return an
error (from the function that initializes the SNS client) indicating invalid
config. Reference the config fields n.conf.Sigv4.ExternalID and
n.conf.Sigv4.RoleARN and perform this check prior to calling
awsconfig.LoadDefaultConfig / sts.NewFromConfig / stscreds.NewAssumeRoleProvider
so the function fails fast on the invalid configuration.

---

Nitpick comments:
In `@notify/sns/sns_test.go`:
- Around line 121-123: Add a focused unit test that asserts ExternalID is
forwarded to STS.AssumeRole when a RoleARN is provided and omitted when no
RoleARN is set: in the sns_test.go tests that set Region/RoleARN/ExternalID
(symbols: RoleARN and ExternalID) create a mock STS client and verify its
AssumeRole invocation includes the ExternalId parameter when RoleARN is set, and
that AssumeRole is called without ExternalId (or not called at all if
implementation skips assume) when RoleARN is empty; update or add two assertions
(one for the positive case and one for the negative case) to guard the new
behavior so ExternalID regressions are caught.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f430d2ab-b5e7-4da1-9c8b-ada1ea7d1d05

📥 Commits

Reviewing files that changed from the base of the PR and between d4e8c87 and ca4674a829841f477bc692d238d55f185acb58f5.

📒 Files selected for processing (3)
  • docs/configuration.md
  • notify/sns/sns.go
  • notify/sns/sns_test.go

@dongjiang1989 dongjiang1989 changed the title Add AWS external_id support in sigv4 configuration feat: Add AWS external_id support in sigv4 configuration Apr 7, 2026
@dongjiang1989
dongjiang1989 force-pushed the update-sigv4 branch 2 times, most recently from eaf1544 to 6af0759 Compare April 14, 2026 03:25
@dongjiang1989

Copy link
Copy Markdown
Member Author

cc @simonpasquier PTAL

@dongjiang1989

Copy link
Copy Markdown
Member Author

@siavashs PTAL, thanks

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Note

The previously reviewed commits are no longer reachable (likely due to a force-push or rebase), so CodeRabbit is performing a full review instead of an incremental one. This review may take a little longer.

Signed-off-by: dongjiang <[email protected]>
Signed-off-by: dongjiang <[email protected]>
@siavashs
siavashs merged commit 949777a into prometheus:main Jul 21, 2026
7 checks passed
@dongjiang1989
dongjiang1989 deleted the update-sigv4 branch July 21, 2026 09:30
@SoloJacobs SoloJacobs mentioned this pull request Aug 14, 2026
Exikle pushed a commit to Exikle/home-infra that referenced this pull request Nov 16, 2026
….1 ➔ v0.34.0) (#224)

This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [quay.io/prometheus/alertmanager](https://github.com/prometheus/alertmanager) | minor | `v0.33.1` → `v0.34.0` |

---

> ⚠️ **Warning**
>
> Some dependencies could not be looked up. Check the [Dependency Dashboard](issues/13) for more information.

---

### Release Notes

<details>
<summary>prometheus/alertmanager (quay.io/prometheus/alertmanager)</summary>

### [`v0.34.0`](https://github.com/prometheus/alertmanager/releases/tag/v0.34.0): 0.34.0 / 2026-08-16

[Compare Source](prometheus/alertmanager@v0.33.1...v0.34.0)

- \[CHANGE] notify: The `reason` label on `alertmanager_notifications_failed_total` now distinguishes `authError` (HTTP 401/403) and `rateLimited` (HTTP 429) from the generic `clientError`. Dashboards/alerts matching `reason="clientError"` for these codes must be updated. [#&#8203;5332](prometheus/alertmanager#5332)
- \[FEATURE] Add optional templatable labels to alert routes. [#&#8203;5328](prometheus/alertmanager#5328)
- \[FEATURE] eventrecorder: Add inhibit rule names to `inhibition_muted_alert` events. [#&#8203;5315](prometheus/alertmanager#5315)
- \[FEATURE] eventrecorder: Add stdout output type. [#&#8203;5311](prometheus/alertmanager#5311)
- \[FEATURE] silences: Add active, expired, and pending boolean filter parameters to GET /api/v2/silences to allow filtering silences by state server-side. [#&#8203;5406](prometheus/alertmanager#5406)
- \[FEATURE] sns: Add aws `external_id` support in sigv4 configuration. [#&#8203;5157](prometheus/alertmanager#5157)
- \[FEATURE] template: Add `toDate` and `mustToDate` functions. [#&#8203;5327](prometheus/alertmanager#5327)
- \[ENHANCEMENT] doc: Add AlertmanagerClusterFailedPeers alertmanager-mixin. [#&#8203;5301](prometheus/alertmanager#5301)
- \[ENHANCEMENT] doc: Add description for Rocketchat parameters in global config. [#&#8203;5181](prometheus/alertmanager#5181)
- \[ENHANCEMENT] doc: Add top level tracing configuration key. [#&#8203;5314](prometheus/alertmanager#5314)
- \[ENHANCEMENT] doc: Fix Alertmanager port in amtool config routes example. [#&#8203;5312](prometheus/alertmanager#5312)
- \[ENHANCEMENT] eventrecorder: Add optional webhook batching. [#&#8203;5392](prometheus/alertmanager#5392)
- \[ENHANCEMENT] notify: The discord and webex integrations now report a failure `reason` on `alertmanager_notifications_failed_total`. [#&#8203;5332](prometheus/alertmanager#5332)
- \[ENHANCEMENT] ui: Improve responsiveness of UI when loading thousands of alerts. [#&#8203;5357](prometheus/alertmanager#5357)
- \[BUGFIX] eventrecorder: Fixed a minor performance regression when the event recorder is enabled. [#&#8203;5307](prometheus/alertmanager#5307)
- \[BUGFIX] msteamsv2: Inherit global `proxy_url` into partial `http_config`. [#&#8203;5379](prometheus/alertmanager#5379)
- \[BUGFIX] webhook: Keep custom `payload` string values verbatim instead of reinterpreting JSON leaves that look like YAML (e.g. values ending with a colon). [#&#8203;5304](prometheus/alertmanager#5304)

</details>

---

### Configuration

📅 **Schedule**: (in timezone America/Toronto)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these updates again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4zMC40IiwidXBkYXRlZEluVmVyIjoiNDQuMzIuMiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsicHJpb3JpdHkvbWVkaXVtIiwicmVub3ZhdGUvY29udGFpbmVyIiwidHlwZS9taW5vciJdfQ==-->

Reviewed-on: https://git.dcunha.io/Exikle/frostlink/pulls/224
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants