-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1329 from AlexsLemonade/dev
Deploy S3 bucket lockdown, change SRA downloads to HTTP
- Loading branch information
Showing
25 changed files
with
221 additions
and
38 deletions.
There are no files selected for viewing
This file contains 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 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
52 changes: 52 additions & 0 deletions
52
common/data_refinery_common/migrations/0020_update_qn_bucket.py
This file contains 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,52 @@ | ||
# Generated by Django 2.1.5 on 2019-04-04 14:27 | ||
|
||
import sys | ||
|
||
from django.conf import settings | ||
from django.db import migrations | ||
from data_refinery_common.utils import get_env_variable | ||
|
||
|
||
# We want this to throw if it can't access this, no point in running a | ||
# migration to set everything to a bad value. | ||
S3_QN_TARGET_BUCKET_NAME = get_env_variable("S3_QN_TARGET_BUCKET_NAME") | ||
|
||
|
||
def update_qn_bucket(apps, schema_editor): | ||
'''Sets the s3_bucket for QN Targets to a bucket just for them. | ||
Based off of: | ||
https://simpleisbetterthancomplex.com/tutorial/2017/09/26/how-to-create-django-data-migrations.html | ||
We can't import the ComputedFile model directly as it may be a newer | ||
version than this migration expects. We use the historical version. | ||
''' | ||
|
||
if not settings.RUNNING_IN_CLOUD: | ||
return | ||
|
||
# Pagination isn't necessary here because we have very few QN targets. | ||
ComputedFile = apps.get_model('data_refinery_common', 'ComputedFile') | ||
for computed_file in ComputedFile.objects.filter(is_qn_target=True): | ||
if not computed_file.s3_bucket or not computed_file.s3_key: | ||
continue | ||
|
||
if not computed_file.change_s3_location(S3_QN_TARGET_BUCKET_NAME, computed_file.s3_key): | ||
# The call to change_s3_location will already logs what | ||
# went wrong, so we don't need to log. If there's any kind | ||
# of network/AWS issue going on all we really need to do | ||
# is stop the migration from finishing successfully since | ||
# once a migration completes successfully it won't ever be | ||
# run again. | ||
sys.exit(1) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('data_refinery_common', '0019_sample_is_blacklisted'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(update_qn_bucket), | ||
] |
This file contains 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 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 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 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 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 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 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 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 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
Binary file not shown.
Binary file not shown.
This file contains 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 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 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 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 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
Oops, something went wrong.