-
Notifications
You must be signed in to change notification settings - Fork 51
feat(mqconfig): support IAM role auth for SQS MQ provider #996
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
Merged
alexluong
merged 2 commits into
hookdeck:main
from
ambroziepaval:feat/sqs-iam-role-credentials
Jul 22, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| package config_test | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/hookdeck/outpost/internal/config" | ||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func TestAWSSQSConfig_IsConfigured(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| tests := []struct { | ||
| name string | ||
| cfg config.AWSSQSConfig | ||
| want bool | ||
| }{ | ||
| { | ||
| name: "region only (IAM role via default credential chain)", | ||
| cfg: config.AWSSQSConfig{Region: "us-east-1"}, | ||
| want: true, | ||
| }, | ||
| { | ||
| name: "region with static keys", | ||
| cfg: config.AWSSQSConfig{AccessKeyID: "AKID", SecretAccessKey: "SECRET", Region: "us-east-1"}, | ||
| want: true, | ||
| }, | ||
| { | ||
| name: "keys without region", | ||
| cfg: config.AWSSQSConfig{AccessKeyID: "AKID", SecretAccessKey: "SECRET"}, | ||
| want: false, | ||
| }, | ||
| { | ||
| name: "empty", | ||
| cfg: config.AWSSQSConfig{}, | ||
| want: false, | ||
| }, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| t.Parallel() | ||
| assert.Equal(t, tt.want, tt.cfg.IsConfigured()) | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func TestAWSSQSConfig_ToQueueConfig(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| tests := []struct { | ||
| name string | ||
| cfg config.AWSSQSConfig | ||
| wantErr bool | ||
| }{ | ||
| { | ||
| name: "both keys set (static credentials)", | ||
| cfg: config.AWSSQSConfig{AccessKeyID: "AKID", SecretAccessKey: "SECRET", Region: "us-east-1"}, | ||
| }, | ||
| { | ||
| name: "both keys empty (default credential chain)", | ||
| cfg: config.AWSSQSConfig{Region: "us-east-1"}, | ||
| }, | ||
| { | ||
| name: "only access key set", | ||
| cfg: config.AWSSQSConfig{AccessKeyID: "AKID", Region: "us-east-1"}, | ||
| wantErr: true, | ||
| }, | ||
| { | ||
| name: "only secret key set", | ||
| cfg: config.AWSSQSConfig{SecretAccessKey: "SECRET", Region: "us-east-1"}, | ||
| wantErr: true, | ||
| }, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| t.Parallel() | ||
| cfg, err := tt.cfg.ToQueueConfig(t.Context(), "deliverymq") | ||
| if tt.wantErr { | ||
| require.Error(t, err) | ||
| assert.Nil(t, cfg) | ||
| return | ||
| } | ||
| require.NoError(t, err) | ||
| require.NotNil(t, cfg) | ||
| }) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| package config_test | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/hookdeck/outpost/internal/config" | ||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func TestPublishMQConfig_GetInfraType_AWSSQS(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| tests := []struct { | ||
| name string | ||
| cfg config.PublishAWSSQSConfig | ||
| want string | ||
| }{ | ||
| { | ||
| name: "region only (IAM role via default credential chain)", | ||
| cfg: config.PublishAWSSQSConfig{Region: "us-east-1"}, | ||
| want: "awssqs", | ||
| }, | ||
| { | ||
| name: "region with static keys", | ||
| cfg: config.PublishAWSSQSConfig{AccessKeyID: "AKID", SecretAccessKey: "SECRET", Region: "us-east-1"}, | ||
| want: "awssqs", | ||
| }, | ||
| { | ||
| name: "keys without region", | ||
| cfg: config.PublishAWSSQSConfig{AccessKeyID: "AKID", SecretAccessKey: "SECRET"}, | ||
| want: "", | ||
| }, | ||
| { | ||
| name: "empty", | ||
| cfg: config.PublishAWSSQSConfig{}, | ||
| want: "", | ||
| }, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| t.Parallel() | ||
| cfg := config.PublishMQConfig{AWSSQS: tt.cfg} | ||
| assert.Equal(t, tt.want, cfg.GetInfraType()) | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func TestPublishMQConfig_Validate(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| tests := []struct { | ||
| name string | ||
| cfg config.PublishMQConfig | ||
| wantErr bool | ||
| }{ | ||
| { | ||
| name: "aws sqs both keys set", | ||
| cfg: config.PublishMQConfig{AWSSQS: config.PublishAWSSQSConfig{AccessKeyID: "AKID", SecretAccessKey: "SECRET", Region: "us-east-1"}}, | ||
| }, | ||
| { | ||
| name: "aws sqs both keys empty (default credential chain)", | ||
| cfg: config.PublishMQConfig{AWSSQS: config.PublishAWSSQSConfig{Region: "us-east-1"}}, | ||
| }, | ||
| { | ||
| name: "aws sqs only access key set", | ||
| cfg: config.PublishMQConfig{AWSSQS: config.PublishAWSSQSConfig{AccessKeyID: "AKID", Region: "us-east-1"}}, | ||
| wantErr: true, | ||
| }, | ||
| { | ||
| name: "aws sqs only secret key set", | ||
| cfg: config.PublishMQConfig{AWSSQS: config.PublishAWSSQSConfig{SecretAccessKey: "SECRET", Region: "us-east-1"}}, | ||
| wantErr: true, | ||
| }, | ||
| { | ||
| name: "no publish provider configured", | ||
| cfg: config.PublishMQConfig{}, | ||
| }, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| t.Parallel() | ||
| err := tt.cfg.Validate() | ||
| if tt.wantErr { | ||
| require.Error(t, err) | ||
| return | ||
| } | ||
| require.NoError(t, err) | ||
| }) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
While this is correct, I discovered a config data issue where if only 1 of AWS_SQS_ACCESS_KEY_ID or AWS_SQS_SECRET_ACCESS_KEY is provided, it is accepted and led to a runtime auth error at a later stage even though this is invalid.
I don't think
IsConfigured()is the right place but maybe we can apply this validation check atToQueueConfig()?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.
Thanks @alexluong! addressed both points:
ToQueueConfig()as suggested so it fails at startup viavalidateMQsinstead of deferring to a runtime error