Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be neat if we could think of a way to keep support for spot instance types for folks where Spot is cheaper than on-demand. On the other hand, it might be enough to point to this commit and say "undo this one".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can certainly do it, it's just some plumbing

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,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can probably be removed, too.

spotIamFleetRole=spotIamFleetRoleArn,
subnets=subnet_ids,
securityGroupIds=securityGroupIds,
)
Expand Down
Loading