Skip to content
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

added secretsmanager read only #66

Merged
merged 25 commits into from
Dec 3, 2024
Merged

Conversation

jnayak-moj
Copy link
Contributor

No description provided.

@jnayak-moj jnayak-moj marked this pull request as ready for review December 2, 2024 11:41
@jnayak-moj jnayak-moj requested a review from jhpyke December 2, 2024 11:41
Copy link
Contributor

@jhpyke jhpyke left a comment

Choose a reason for hiding this comment

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

I think the way we provide the secretsmanager key etc is fine if we add some error handling, but don't think the actual policy is going to achieve what we need it to as is.

"secretsmanager:ListSecrets",
],
"Effect": "Allow",
"Resource": f"arn:aws:secretsmanager:::secret:{secret_name}",
Copy link
Contributor

Choose a reason for hiding this comment

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

Expectation is that secret resource will be of the format arn:aws:secretsmanager:<region>:<account>:secret:<name_of_secret>-<hex_code>. As such, a user should be able to supply either the name of a specific secret, in which case we should be granting them access to ``arn:aws:secretsmanager:eu-west-1:㊙️<name_of_secret>-*`, or they should supply a wild_carded secret value which we can grant access to. Currently, this will fail to grant the access required I suspect.

@@ -91,6 +92,12 @@ def build_iam_policy(config: dict) -> dict: # noqa: C901
iam["Statement"].append(secrets_statement)
iam["Statement"].extend(iam_lookup["decrypt_statement"])

if "secretsmanager" in config:
secretsmanager_read_only = get_secretsmanager_read_only_policy(
config["secretsmanager"]["read_only"]
Copy link
Contributor

Choose a reason for hiding this comment

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

This is slightly weird given that we don't have a corresponding write access level. We should have specific error handling for if users try and pass in the same keys they do for S3 (e.g. write_only, read_write that throw errors to the end user that these levels of access have not been implemented in iam_builder.

@jnayak-moj jnayak-moj requested a review from jhpyke December 2, 2024 15:08
@jhpyke
Copy link
Contributor

jhpyke commented Dec 3, 2024

Newly added tests are not actually running - can you modify test_iam_builder.py to ensure you're properly testing this functionality

jhpyke
jhpyke previously approved these changes Dec 3, 2024
Copy link
Contributor

@jhpyke jhpyke left a comment

Choose a reason for hiding this comment

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

Other than one tiny suggestion it’s good to merge

@@ -85,6 +85,19 @@
"type": "string"
}
},
"secretsmanager": {
"description": "A secret that the iam_role should be able to acces.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"description": "A secret that the iam_role should be able to acces.",
"description": "A secret that the iam_role should be able to access.",

Copy link
Contributor

@jhpyke jhpyke left a comment

Choose a reason for hiding this comment

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

Let’s try it

@jnayak-moj jnayak-moj merged commit aaa527a into main Dec 3, 2024
20 checks passed
@jnayak-moj jnayak-moj deleted the add-secrest-manager-read-only branch December 3, 2024 17:07
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.

2 participants