#! /bin/sh

echo >&2 "running: $0 $*"
echo >&2 '$'"RESALLOC_NAME: $RESALLOC_NAME"

# moved from i3.large to i4i.large because
# https://bugzilla.redhat.com/show_bug.cgi?id=2144249

# 2022-11-23, trying to move from a1.xlarge => c7g.xlarge
# (price goes up by 40%)
# https://lists.fedoraproject.org/archives/list/buildsys@lists.fedoraproject.org/thread/VUAOXQ3BNXDZMVFR2PJCBQYWGWOIYMPD/

cmd=(
    /usr/bin/resalloc-aws-new
      --aws-profile default
      --ami {{ copr_builder_images.aws[item] }}
      --ssh-key-name copr-builder
      --security-group-id sg-0c3efdb681ced5d4f
      --debug
{% for subnet in aws_arch_subnets[item] %}
      --possible-subnet {{ subnet }}
{% endfor %}
      --tag FedoraGroup=copr
      --tag CoprPurpose=builder
      --tag CoprInstance={% if devel %}devel{% else %}production{% endif %}
      --tag arch={{ item }}
      --additional-volume-size 160
      --playbook /var/lib/resallocserver/provision/builderpb-aws.yml
)

set -x
# execute the command + additional arguments
exec "${cmd[@]}" "$@"
