Merge pull request #1723 from Comcast/create_policy

Adding account id to ManagedPolicy ARN
This commit is contained in:
Steve Pulec 2018-07-19 10:55:22 -04:00 committed by GitHub
commit cc31f22bb5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 17 deletions

View file

@ -50,10 +50,6 @@ class Policy(BaseModel):
self.create_datetime = datetime.now(pytz.utc)
self.update_datetime = datetime.now(pytz.utc)
@property
def arn(self):
return 'arn:aws:iam::aws:policy{0}{1}'.format(self.path, self.name)
class PolicyVersion(object):
@ -82,6 +78,10 @@ class ManagedPolicy(Policy):
self.attachment_count -= 1
del obj.managed_policies[self.name]
@property
def arn(self):
return "arn:aws:iam::{0}:policy{1}{2}".format(ACCOUNT_ID, self.path, self.name)
class AWSManagedPolicy(ManagedPolicy):
"""AWS-managed policy."""
@ -93,6 +93,10 @@ class AWSManagedPolicy(ManagedPolicy):
path=data.get('Path'),
document=data.get('Document'))
@property
def arn(self):
return 'arn:aws:iam::aws:policy{0}{1}'.format(self.path, self.name)
# AWS defines some of its own managed policies and we periodically
# import them via `make aws_managed_policies`