-
Notifications
You must be signed in to change notification settings - Fork 978
(feat): adds publish support for aws secrets manager and parameter store #1953
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
Open
bruce-szalwinski-he
wants to merge
23
commits into
getsops:main
Choose a base branch
from
bruce-szalwinski-he:feature/aws-publishing-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
05e6728
support for aws secrets manager and parameter store
bruce-szalwinski-he 40b95a1
parameter store is json-based storage
bruce-szalwinski-he 047e3b6
feat: add AWS Secrets Manager key/value format testing and comprehens…
bruce-szalwinski-he bdd4676
remove unused
bruce-szalwinski-he 09d51b7
fix: make AWS Parameter Store Upload method consistent with other des…
bruce-szalwinski-he 217cb1b
throw not implemented for upload
bruce-szalwinski-he 7dd858e
test: update Parameter Store integration test to match new Upload beh…
bruce-szalwinski-he 292c9b0
remove unused
bruce-szalwinski-he 88fe4ae
remove unused
bruce-szalwinski-he 8a54645
docs on systems manager and parameter store
bruce-szalwinski-he cf02b0b
parameter store is always secureString
bruce-szalwinski-he 9427fab
words matter
bruce-szalwinski-he 60d2dba
Merge branch 'main' into feature/aws-publishing-support
bruce-szalwinski-he b3880aa
Merge branch 'main' into feature/aws-publishing-support
bruce-szalwinski-he 6381192
Merge branch 'main' into feature/aws-publishing-support
bruce-szalwinski-he 8c372ed
Merge branch 'main' into feature/aws-publishing-support
bruce-szalwinski-he 92b333d
tidy
bruce-szalwinski-he 8b6814b
Merge branch 'main' into feature/aws-publishing-support
bruce-szalwinski-he e5ea0d9
Merge branch 'main' into feature/aws-publishing-support
bruce-szalwinski-he 2a9721a
Merge branch 'main' into feature/aws-publishing-support
bruce-szalwinski-he 5510949
Merge branch 'main' into feature/aws-publishing-support
bruce-szalwinski-he e6f0dc4
Merge branch 'main' into feature/aws-publishing-support
bruce-szalwinski-he 7d5dddd
tidy
bruce-szalwinski-he 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
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,123 @@ | ||
| package config | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| ) | ||
|
|
||
| var sampleConfigWithAWSSecretsManagerDestinationRules = []byte(` | ||
| creation_rules: | ||
| - path_regex: foobar* | ||
| kms: "arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012" | ||
| destination_rules: | ||
| - aws_secrets_manager_region: "us-east-1" | ||
| aws_secrets_manager_secret_name: "myapp/database" | ||
| path_regex: "^secrets/.*" | ||
| - aws_secrets_manager_region: "us-west-2" | ||
| path_regex: "^west-secrets/.*" | ||
| `) | ||
|
|
||
| var sampleConfigWithAWSParameterStoreDestinationRules = []byte(` | ||
| creation_rules: | ||
| - path_regex: foobar* | ||
| kms: "arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012" | ||
| destination_rules: | ||
| - aws_parameter_store_region: "us-east-1" | ||
| aws_parameter_store_path: "/myapp/config" | ||
| aws_parameter_store_type: "SecureString" | ||
| path_regex: "^parameters/.*" | ||
| - aws_parameter_store_region: "us-west-2" | ||
| aws_parameter_store_path: "/myapp/west/" | ||
| aws_parameter_store_type: "String" | ||
| path_regex: "^west-parameters/.*" | ||
| `) | ||
|
|
||
| var sampleConfigWithMixedAWSDestinationRules = []byte(` | ||
| creation_rules: | ||
| - path_regex: foobar* | ||
| kms: "arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012" | ||
| destination_rules: | ||
| - aws_secrets_manager_region: "us-east-1" | ||
| aws_secrets_manager_secret_name: "myapp/database" | ||
| path_regex: "^secrets/.*" | ||
| - aws_parameter_store_region: "us-east-1" | ||
| aws_parameter_store_path: "/myapp/config" | ||
| path_regex: "^parameters/.*" | ||
| - s3_bucket: "mybucket" | ||
| path_regex: "^s3/.*" | ||
| `) | ||
|
|
||
| func TestLoadConfigFileWithAWSSecretsManagerDestinationRules(t *testing.T) { | ||
| conf, err := parseDestinationRuleForFile(parseConfigFile(sampleConfigWithAWSSecretsManagerDestinationRules, t), "secrets/database.yaml", nil) | ||
| assert.Nil(t, err) | ||
| assert.NotNil(t, conf.Destination) | ||
| path := conf.Destination.Path("database.yaml") | ||
| assert.Contains(t, path, "arn:aws:secretsmanager:us-east-1:*:secret:myapp/database") | ||
|
|
||
| // Test with region but no specific secret name - this should match the second rule | ||
| conf, err = parseDestinationRuleForFile(parseConfigFile(sampleConfigWithAWSSecretsManagerDestinationRules, t), "west-secrets/api.yaml", nil) | ||
| assert.Nil(t, err) | ||
| assert.NotNil(t, conf.Destination) | ||
| path = conf.Destination.Path("api.yaml") | ||
| assert.Contains(t, path, "arn:aws:secretsmanager:us-west-2:*:secret:api.yaml") | ||
| } | ||
|
|
||
| func TestLoadConfigFileWithAWSParameterStoreDestinationRules(t *testing.T) { | ||
| conf, err := parseDestinationRuleForFile(parseConfigFile(sampleConfigWithAWSParameterStoreDestinationRules, t), "parameters/app.yaml", nil) | ||
| assert.Nil(t, err) | ||
| assert.NotNil(t, conf.Destination) | ||
| assert.Equal(t, "/myapp/config", conf.Destination.Path("app.yaml")) | ||
|
|
||
| // Test with path ending with slash | ||
| conf, err = parseDestinationRuleForFile(parseConfigFile(sampleConfigWithAWSParameterStoreDestinationRules, t), "west-parameters/config.yaml", nil) | ||
| assert.Nil(t, err) | ||
| assert.NotNil(t, conf.Destination) | ||
| assert.Equal(t, "/myapp/west/config.yaml", conf.Destination.Path("config.yaml")) | ||
| } | ||
|
|
||
| func TestLoadConfigFileWithMixedAWSDestinationRules(t *testing.T) { | ||
| // Test AWS Secrets Manager | ||
| conf, err := parseDestinationRuleForFile(parseConfigFile(sampleConfigWithMixedAWSDestinationRules, t), "secrets/database.yaml", nil) | ||
| assert.Nil(t, err) | ||
| assert.NotNil(t, conf.Destination) | ||
| assert.Contains(t, conf.Destination.Path("database.yaml"), "arn:aws:secretsmanager:us-east-1:*:secret:myapp/database") | ||
|
|
||
| // Test AWS Parameter Store | ||
| conf, err = parseDestinationRuleForFile(parseConfigFile(sampleConfigWithMixedAWSDestinationRules, t), "parameters/config.yaml", nil) | ||
| assert.Nil(t, err) | ||
| assert.NotNil(t, conf.Destination) | ||
| assert.Equal(t, "/myapp/config", conf.Destination.Path("config.yaml")) | ||
|
|
||
| // Test S3 | ||
| conf, err = parseDestinationRuleForFile(parseConfigFile(sampleConfigWithMixedAWSDestinationRules, t), "s3/backup.yaml", nil) | ||
| assert.Nil(t, err) | ||
| assert.NotNil(t, conf.Destination) | ||
| assert.Contains(t, conf.Destination.Path("backup.yaml"), "s3://mybucket/backup.yaml") | ||
| } | ||
|
|
||
| func TestValidateMultipleDestinationsInRule(t *testing.T) { | ||
| invalidConfig := []byte(` | ||
| destination_rules: | ||
| - aws_secrets_manager_region: "us-east-1" | ||
| aws_parameter_store_region: "us-east-1" | ||
| path_regex: "^invalid/.*" | ||
| `) | ||
|
|
||
| _, err := parseDestinationRuleForFile(parseConfigFile(invalidConfig, t), "invalid/test.yaml", nil) | ||
| assert.NotNil(t, err) | ||
| assert.Contains(t, err.Error(), "more than one destinations were found") | ||
| } | ||
|
|
||
| func TestValidateConflictingAWSDestinations(t *testing.T) { | ||
| invalidConfig := []byte(` | ||
| destination_rules: | ||
| - aws_secrets_manager_region: "us-east-1" | ||
| s3_bucket: "mybucket" | ||
| path_regex: "^invalid/.*" | ||
| `) | ||
|
|
||
| _, err := parseDestinationRuleForFile(parseConfigFile(invalidConfig, t), "invalid/test.yaml", nil) | ||
| assert.NotNil(t, err) | ||
| assert.Contains(t, err.Error(), "more than one destinations were found") | ||
| } | ||
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.
config_test was getting a little long, so added aws config tests as separate file.