Skip to content

Commit

Permalink
Configure server access logging for an S3 bucket. This enables access…
Browse files Browse the repository at this point in the history
… logging, directing logs to the specified target bucket and prefix.
  • Loading branch information
Chrystinne committed Oct 19, 2023
1 parent 9c8c528 commit 079da44
Show file tree
Hide file tree
Showing 5 changed files with 288 additions and 229 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,14 @@ AWS_CLOUD_FORMATION=url

# AWS credentials (Access Key and Secret Key): Configure AWS credentials in the AWS CLI profile using the 'aws configure' command.
AWS_PROFILE=
AWS_ACCOUNT_ID=
# Path to the file containing credentials for AWS
# (https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html#shared-credentials-file)
AWS_SHARED_CREDENTIALS_FILE=
# The default bucket name to store projects with an 'OPEN' access policy.
S3_OPEN_ACCESS_BUCKET=
# The default bucket name to store logs and metrics related to project usage.
S3_SERVER_ACCESS_LOGS=

# Datacite
# Used to assign the DOIs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ <h5 class="card-title mt-3 mb-1">AWS</h5>
are set.)
</p>
{% elif not project.aws.bucket_name %}
<p>Create a bucket on AWS to store the files associated with this project. dsjkbjak {{project.id}} {{project.aws.bucket_name}} {{project.aws.sent_files}}</p>
<p>Create a bucket on AWS to store the files associated with this project.</p>
<form action="" method="post">
{% csrf_token %}
<button class="btn btn-primary" name="aws-bucket" value='{{project.slug}}'
Expand Down
10 changes: 5 additions & 5 deletions physionet-django/console/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -797,13 +797,13 @@ def send_files_to_aws(pid):
"""
project = PublishedProject.objects.get(id=pid)
# Create or get the associated AWS object
aws_instance = AWS.objects.get_or_create(project=project)
AWS.objects.get_or_create(project=project)
upload_project_to_S3(project)
aws_instance.sent_files = True
aws_instance.finished_datetime = timezone.now()
project.aws.sent_files = True
project.aws.finished_datetime = timezone.now()
if project.compressed_storage_size:
aws_instance.sent_zip = True
aws_instance.save()
project.aws.sent_zip = True
project.aws.save()


@associated_task(PublishedProject, "pid", read_only=True)
Expand Down
4 changes: 4 additions & 0 deletions physionet-django/physionet/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,14 @@
AWS_SHARED_CREDENTIALS_FILE = None

AWS_PROFILE = config('AWS_PROFILE', default=False)
AWS_ACCOUNT_ID = config('AWS_ACCOUNT_ID', default=False)

# Bucket name for the S3 bucket containing the open access data
S3_OPEN_ACCESS_BUCKET = config('S3_OPEN_ACCESS_BUCKET', default=False)

# Bucket name to store logs and metrics related to project usage.
S3_SERVER_ACCESS_LOGS = config('S3_SERVER_ACCESS_LOGS', default=False)

# Header tags for the AWS lambda function that grants access to S3 storage
AWS_HEADER_KEY = config('AWS_KEY', default=False)
AWS_HEADER_VALUE = config('AWS_VALUE', default=False)
Expand Down
Loading

0 comments on commit 079da44

Please sign in to comment.