-
Notifications
You must be signed in to change notification settings - Fork 0
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
PRMDR-914 new IAM service for pre-sign url #374
Conversation
@@ -30,7 +30,8 @@ | |||
|
|||
class CreateDocumentReferenceService: | |||
def __init__(self): | |||
self.s3_service = S3Service() | |||
create_document_aws_role_arn = os.getenv("PRE_SIGN_ASSUME_ROLE") |
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.
probably better to add this new env var to the handler's decorator, so that in case this is missing we are notified
lambdas/services/base/s3_service.py
Outdated
self.custom_client = None | ||
if custom_aws_role: | ||
iam_service = IAMService() | ||
print(iam_service) |
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.
probably don't need this print anymore :)
create_document_aws_role_arn = os.getenv("PRE_SIGN_ASSUME_ROLE") | ||
self.s3_service = S3Service(custom_aws_role=create_document_aws_role_arn) |
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.
create_document_aws_role_arn = os.getenv("PRE_SIGN_ASSUME_ROLE") | |
self.s3_service = S3Service(custom_aws_role=create_document_aws_role_arn) | |
presign_url_aws_role_arn = os.getenv("PRE_SIGN_ASSUME_ROLE") | |
self.s3_service = S3Service(custom_aws_role=presign_url_aws_role_arn) |
suggest to rename as here the role isn't for creating document
@@ -12,41 +13,49 @@ | |||
class S3Service: | |||
_instance = None | |||
|
|||
def __new__(cls): | |||
def __new__(cls, *args, **kwargs): |
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.
Any reason for the args/kwargs addition?
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.
__new__
is run before __init__
and all the args are passed into both. So I need to be able to pass the custom role into __init__
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.
When new() returns an instance of cls it automatically invokes the [init()] method of that instance with the arguments passed to it.(https://www.codecademy.com/resources/docs/python/dunder-methods/new)
iam_service = IAMService() | ||
self.custom_client = iam_service.assume_role( | ||
custom_aws_role, "s3", config=config | ||
) | ||
|
||
# S3 Location should be a minimum of a s3_object_key but can also be a directory location in the form of |
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.
Wonder if we still need this comment? I know it's not part of your work but seems a bit unnecessary to me?
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.
I think we do. It's not clear without it.
No description provided.