def ec2_params()

in aws/hhvm1/lambdas/activities.py [0:0]


  def ec2_params(self):
    if not self.ec2_iam_arn or not self.activity_arn or not self.script_name:
      raise Exception('missing config in ' + type(self).__name__)

    script_url = common.url(
      'aws/hhvm1/worker/dummy-task.sh' if self.fake_ec2
      else 'aws/userdata/' + self.script_name
    )
    init_url = (
      common.url(self.init_script)
        if self.init_script and not self.fake_ec2
        else ''
    )
    after_task_url = (
      common.url(self.after_task_script)
        if self.after_task_script and not self.fake_ec2
        else ''
    )
    return {
      'ImageId': 'ami-03d5c68bab01f3496',  # ubuntu 20.04
      'MaxCount': 1,
      'MinCount': 1,
      'InstanceType': 't2.micro',
      'SecurityGroups': ['hhvm-binary-package-builders'],
      'InstanceInitiatedShutdownBehavior': 'terminate',
      'IamInstanceProfile': {'Arn': self.ec2_iam_arn},
      'KeyName': 'hhvm-package-builders',
      'TagSpecifications': [{
        'ResourceType': 'instance',
        'Tags': [
          {
            'Key': 'Name',
            'Value': 'ww-0-' + type(self).__name__,
          },
          {
            'Key': 'ActivityArn',
            'Value': self.activity_arn,
          },
        ],
      }],
      'UserData': f'''#!/bin/bash
        ACTIVITY_ARN="{self.activity_arn}"
        SCRIPT_URL="{script_url}"
        INIT_URL="{init_url}"
        AFTER_TASK_URL="{after_task_url}"
        {common.format_env(self.worker_env())}
        {common.fetch('aws/hhvm1/worker/worker.sh')}
      ''',
    }