Path is an optional property of instance profile cloudformation resource (#1382)

* Path is an optional property of instance profile cloudformation resource

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iam-instanceprofile.html

* Path is also optional for iam role clouformation resources

Based on http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iam-role.html

* Use `properities.get` with a default instead of doing default handling myself
This commit is contained in:
William Richard 2017-12-14 07:06:04 -05:00 committed by Terry Cain
commit df7a7958c1
2 changed files with 71 additions and 31 deletions

View file

@ -122,7 +122,7 @@ class Role(BaseModel):
role = iam_backend.create_role(
role_name=resource_name,
assume_role_policy_document=properties['AssumeRolePolicyDocument'],
path=properties['Path'],
path=properties.get('Path', '/'),
)
policies = properties.get('Policies', [])
@ -173,7 +173,7 @@ class InstanceProfile(BaseModel):
role_ids = properties['Roles']
return iam_backend.create_instance_profile(
name=resource_name,
path=properties['Path'],
path=properties.get('Path', '/'),
role_ids=role_ids,
)