Skip to content
This repository was archived by the owner on Sep 26, 2020. It is now read-only.

Commit 30d664b

Browse files
committed
Fix not creating an instance profile with the ec2 role
1 parent 5b59ef1 commit 30d664b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

axon/client.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,8 @@ def ensure_task_role(region):
254254

255255

256256
def ensure_ec2_role(region):
257-
role_name = "axon-ec2-role-manual"
257+
role_name = "axon-ec2-autogenerated-role"
258+
profile_name = "axon-ec2-autogenerated-instance-profile"
258259
client = make_client("iam", region)
259260
role_arn = ensure_role(client, role_name)
260261
if role_arn is None:
@@ -280,6 +281,15 @@ def ensure_ec2_role(region):
280281

281282
client.attach_role_policy(RoleName=role_name,
282283
PolicyArn="arn:aws:iam::aws:policy/AmazonS3FullAccess")
284+
285+
try:
286+
client.get_instance_profile(InstanceProfileName=profile_name)
287+
except:
288+
client.create_instance_profile(InstanceProfileName=profile_name)
289+
iam_resource = boto3.resource('iam')
290+
instance_profile = iam_resource.InstanceProfile(profile_name)
291+
instance_profile.add_role(RoleName=role_name)
292+
283293
return role_arn
284294

285295

0 commit comments

Comments
 (0)