Skip to content

Commit

Permalink
[Backend] Add EC2 instance ID to challenge (#4093)
Browse files Browse the repository at this point in the history
  • Loading branch information
gchhablani authored Aug 10, 2023
1 parent 51161cf commit 61b44da
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
2 changes: 2 additions & 0 deletions apps/challenges/aws_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1538,6 +1538,8 @@ def setup_ec2(challenge):
],
UserData=ec2_worker_script,
)
challenge_obj.ec2_instance_id = response['Instances'][0]['InstanceId']
challenge_obj.save()
return response
except ClientError as e:
logger.exception(e)
Expand Down
23 changes: 23 additions & 0 deletions apps/challenges/migrations/0101_challenge_ec2_instance_id.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 2.2.20 on 2023-08-10 06:02

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('challenges', '0100_challenge_uses_ec2_worker'),
]

operations = [
migrations.AddField(
model_name='challenge',
name='ec2_instance_id',
field=models.CharField(blank=True, default='', max_length=200, null=True),
),
migrations.AlterField(
model_name='challenge',
name='uses_ec2_worker',
field=models.BooleanField(db_index=True, default=False, verbose_name='Uses EC2 worker instance'),
),
]
5 changes: 4 additions & 1 deletion apps/challenges/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ def __init__(self, *args, **kwargs):
default=False, verbose_name="Approved By Admin", db_index=True
)
uses_ec2_worker = models.BooleanField(
default=False, verbose_name="Uses separate EC2 worker instance", db_index=True
default=False, verbose_name="Uses EC2 worker instance", db_index=True
)
ec2_instance_id = models.CharField(
max_length=200, default="", null=True, blank=True
)
featured = models.BooleanField(
default=False, verbose_name="Featured", db_index=True
Expand Down

0 comments on commit 61b44da

Please sign in to comment.