Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 2 additions & 31 deletions batch-setup/batch_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,34 +148,6 @@ def batch_setup(region_name, run_id, vpc_id, securityGroupIds, computeEnvironmen
boto_iam, boto_ec2, instanceRoleName, instanceRoleName)
print("Using ECS instance profile %s" % instanceProfileArn)

# Create the spot fleet role
# https://docs.aws.amazon.com/batch/latest/userguide/spot_fleet_IAM_role.html
spotIamFleetRoleName = "AmazonEC2SpotFleetRole"
spotIamRoleDocument = {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "spotfleet.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
spotIamFleetRoleArn = get_or_create_role(
boto_iam, spotIamFleetRoleName, spotIamRoleDocument)
print("Using EC2 Spot Fleet role %s" % spotIamFleetRoleArn)

spotFleetTaggingRolePolicy = find_policy(
boto_iam, 'AmazonEC2SpotFleetTaggingRole')
boto_iam.attach_role_policy(
PolicyArn=spotFleetTaggingRolePolicy['Arn'],
RoleName=spotIamFleetRoleName,
)
print("Attached Spot Fleet Tagging Role to EC2 Spot Fleet role %s"
% spotIamFleetRoleArn)

# Create a compute environment for raw tile rendering
try:
response = boto_batch.describe_compute_environments(
Expand All @@ -192,11 +164,11 @@ def batch_setup(region_name, run_id, vpc_id, securityGroupIds, computeEnvironmen
state="ENABLED",
serviceRole=serviceRoleArn,
computeResources=dict(
type='SPOT',
type='EC2',
minvCpus=0,
maxvCpus=max_vcpus,
desiredvCpus=0,
instanceTypes=["r5"],
instanceTypes=["m5"],
# although this is called "instanceRole", it really wants an instance _profile_ ARN.
instanceRole=instanceProfileArn,
tags={
Expand All @@ -205,7 +177,6 @@ def batch_setup(region_name, run_id, vpc_id, securityGroupIds, computeEnvironmen
'cost_resource_group': run_id,
},
bidPercentage=60,
spotIamFleetRole=spotIamFleetRoleArn,
subnets=subnet_ids,
securityGroupIds=securityGroupIds,
)
Expand Down
Loading