Skip to content

Commit

Permalink
feat: refactor / additional flag autoGenerateIamPermissions (#1089)
Browse files Browse the repository at this point in the history
* feat: refactor / additional flag autoGenerateIamPermissions
- remove CreationType (Single, Multi)
- replace with ResourceType (PARAMETER_MULTI) and move it to properties
   fixes: #1076
- add property 'autoGenerateIamPermissions'
   fixes: #1087
- add property 'role' for SopsSyncProvider
   fixes: #1087
- move resourceType from syncOptions to syncProperties, as it shouldn't be set by users
- move permissionhandling to own functions, to reduce cyclomatic compexity

* chore: self mutation

Signed-off-by: github-actions <[email protected]>

* chore(Tests): add more tests for permissions testing

* fix: autogenerate

* fix: init s3Api

* fix: remove CreationType everywhere

* fix: contribution guide, error messages and sha1sum

Signed-off-by: lennartrommeiss <[email protected]>

* fix: tests

* chore: self mutation

Signed-off-by: github-actions <[email protected]>

---------

Signed-off-by: github-actions <[email protected]>
Signed-off-by: lennartrommeiss <[email protected]>
Co-authored-by: github-actions <[email protected]>
Co-authored-by: lennartrommeiss <[email protected]>
  • Loading branch information
3 people authored Jan 20, 2025
1 parent 1e69765 commit 7f8a318
Show file tree
Hide file tree
Showing 42 changed files with 771 additions and 541 deletions.
40 changes: 40 additions & 0 deletions .gitleaks.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[extend]
useDefault = true

[[rules]]
id = "generic-api-key"
# all the other attributes from the default rule are inherited

[[rules.allowlists]]
regexTarget = "line"
regexes = [
'''objectKey''',
'''S3Key''',
'''SopsAgeKey''',
'''s3Key''',
]

[[rules]]
id = "private-key"

[[rules.allowlists]]
regexTarget = "line"
regexes = [
'''(.*)OAdqlMznWINBDoyR\+PESgQJlUptwnh(.*)''',
]

[allowlist]
description = "global allow list"
paths = [
'''\.gitleaks\.toml''',
'''lambda/events/(.*?)json''',
'''lambda/__snapshots__/(.*?)snap''',
'''test-secrets/(.*?)(json|yaml|yml|env|binary)''',
'''test/(.*)\.integ\.snapshot/(.*?)json'''
]

regexTarget = "match"
regexes = [
'''AGE-SECRET-KEY-1EFUWJ0G2XJTJFWTAM2DGMA4VCK3R05W58FSMHZP3MZQ0ZTAQEAFQC6T7T3''',
]

233 changes: 94 additions & 139 deletions API.md

Large diffs are not rendered by default.

24 changes: 23 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,26 @@

Thanks for your interest in our project. Contributions are welcome. Feel free to [open an issue](issues) with questions or reporting ideas and bugs, or [open pull requests](pulls) to contribute code.

We are committed to fostering a welcoming, respectful, and harassment-free environment. Be kind!
We are committed to fostering a welcoming, respectful, and harassment-free environment. Be kind!

## How to buidl/deploy local

Install all necessary tools with `yarn install` and others manually like `go`

Build the go Lambda code:
```
./scripts/build.sh
```
Build the package (for CDK development only the first `js` build has to complete):
```
yarn projen build
```
Link the package:
```
yarn link
```
Switch to the path/project where you would like to use cdk-sops-secrets. \
Link the package to your local build source:
```
yarn link "cdk-sops-secrets"
```
3 changes: 2 additions & 1 deletion lambda/__snapshots__/handler_parameter_raw_test.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions lambda/__snapshots__/handler_parameter_yaml_multi_test.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions lambda/__snapshots__/handler_secret_env_test.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions lambda/__snapshots__/handler_secret_json_test.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion lambda/__snapshots__/handler_secret_raw_test.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 14 additions & 7 deletions lambda/__snapshots__/handler_secret_yaml_test.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion lambda/events/event_create_s3_parameter_raw_simple.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"LogicalResourceId": "LogicalResourceId",
"ResourceProperties": {
"ResourceType": "PARAMETER",
"CreationType": "SINGLE",
"ParameterName": "arn:aws:ssm:eu-central-1:123456789012:parameter/testsecret",
"SopsS3File": {
"Bucket": "..",
Expand Down
3 changes: 1 addition & 2 deletions lambda/events/event_create_s3_parameter_yaml_complex.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
"RequestType": "Create",
"LogicalResourceId": "LogicalResourceId",
"ResourceProperties": {
"ResourceType": "PARAMETER",
"CreationType": "MULTI",
"ResourceType": "PARAMETER_MULTI",
"ParameterName": "arn:aws:ssm:eu-central-1:123456789012:parameter/testsecret",
"SopsS3File": {
"Bucket": "..",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
"RequestType": "Create",
"LogicalResourceId": "LogicalResourceId",
"ResourceProperties": {
"ResourceType": "PARAMETER",
"CreationType": "MULTI",
"ResourceType": "PARAMETER_MULTI",
"ParameterName": "arn:aws:ssm:eu-central-1:123456789012:parameter/testsecret",
"SopsS3File": {
"Bucket": "..",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"LogicalResourceId": "LogicalResourceId",
"ResourceProperties": {
"ResourceType": "SECRET",
"CreationType": "SINGLE",
"FlattenSeparator": ".",
"SecretARN": "arn:aws:secretsmanager:eu-central-1:123456789012:secret:testsecret",
"SopsS3File": {
Expand Down
1 change: 0 additions & 1 deletion lambda/events/event_create_s3_secret_env_simple.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"LogicalResourceId": "LogicalResourceId",
"ResourceProperties": {
"ResourceType": "SECRET",
"CreationType": "SINGLE",
"FlattenSeparator": ".",
"SecretARN": "arn:aws:secretsmanager:eu-central-1:123456789012:secret:testsecret",
"SopsS3File": {
Expand Down
1 change: 0 additions & 1 deletion lambda/events/event_create_s3_secret_json_complex.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"LogicalResourceId": "LogicalResourceId",
"ResourceProperties": {
"ResourceType": "SECRET",
"CreationType": "SINGLE",
"FlattenSeparator": ".",
"SecretARN": "arn:aws:secretsmanager:eu-central-1:123456789012:secret:testsecret",
"SopsS3File": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"LogicalResourceId": "LogicalResourceId",
"ResourceProperties": {
"ResourceType": "SECRET",
"CreationType": "SINGLE",
"FlattenSeparator": ".",
"SecretARN": "arn:aws:secretsmanager:eu-central-1:123456789012:secret:testsecret",
"SopsS3File": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"LogicalResourceId": "LogicalResourceId",
"ResourceProperties": {
"ResourceType": "SECRET",
"CreationType": "SINGLE",
"FlattenSeparator": ".",
"SecretARN": "arn:aws:secretsmanager:eu-central-1:123456789012:secret:testsecret",
"SopsS3File": {
Expand Down
1 change: 0 additions & 1 deletion lambda/events/event_create_s3_secret_json_simple.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"LogicalResourceId": "LogicalResourceId",
"ResourceProperties": {
"ResourceType": "SECRET",
"CreationType": "SINGLE",
"FlattenSeparator": ".",
"SecretARN": "arn:aws:secretsmanager:eu-central-1:123456789012:secret:testsecret",
"SopsS3File": {
Expand Down
1 change: 0 additions & 1 deletion lambda/events/event_create_s3_secret_raw_simple.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"LogicalResourceId": "LogicalResourceId",
"ResourceProperties": {
"ResourceType": "SECRET",
"CreationType": "SINGLE",
"FlattenSeparator": ".",
"SecretARN": "arn:aws:secretsmanager:eu-central-1:123456789012:secret:testsecret",
"SopsS3File": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"LogicalResourceId": "LogicalResourceId",
"ResourceProperties": {
"ResourceType": "SECRET",
"CreationType": "SINGLE",
"FlattenSeparator": ".",
"SecretARN": "arn:aws:secretsmanager:eu-central-1:123456789012:secret:testsecret",
"SopsS3File": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"LogicalResourceId": "LogicalResourceId",
"ResourceProperties": {
"ResourceType": "SECRET",
"CreationType": "SINGLE",
"FlattenSeparator": ".",
"SecretARN": "arn:aws:secretsmanager:eu-central-1:123456789012:secret:testsecret",
"SopsS3File": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"LogicalResourceId": "LogicalResourceId",
"ResourceProperties": {
"ResourceType": "SECRET",
"CreationType": "SINGLE",
"FlattenSeparator": ".",
"SecretARN": "arn:aws:secretsmanager:eu-central-1:123456789012:secret:testsecret",
"SopsS3File": {
Expand Down
1 change: 0 additions & 1 deletion lambda/events/event_create_s3_secret_yaml_complex.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"LogicalResourceId": "LogicalResourceId",
"ResourceProperties": {
"ResourceType": "SECRET",
"CreationType": "SINGLE",
"FlattenSeparator": ".",
"SecretARN": "arn:aws:secretsmanager:eu-central-1:123456789012:secret:testsecret",
"SopsS3File": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"LogicalResourceId": "LogicalResourceId",
"ResourceProperties": {
"ResourceType": "SECRET",
"CreationType": "SINGLE",
"FlattenSeparator": ".",
"SecretARN": "arn:aws:secretsmanager:eu-central-1:123456789012:secret:testsecret",
"SopsS3File": {
Expand Down
1 change: 0 additions & 1 deletion lambda/events/event_create_s3_secret_yaml_simple.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"LogicalResourceId": "LogicalResourceId",
"ResourceProperties": {
"ResourceType": "SECRET",
"CreationType": "SINGLE",
"FlattenSeparator": ".",
"SecretARN": "arn:aws:secretsmanager:eu-central-1:123456789012:secret:testsecret",
"SopsS3File": {
Expand Down
Loading

0 comments on commit 7f8a318

Please sign in to comment.