Skip to content

Commit

Permalink
Add support for CodeCommit Repository
Browse files Browse the repository at this point in the history
  • Loading branch information
enzbang committed May 9, 2019
1 parent a54e7d7 commit 39fe6ea
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
2 changes: 2 additions & 0 deletions e3/aws/cfn/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class AWSType(Enum):
S3_BUCKET_POLICY = 'AWS::S3::BucketPolicy'
SERVICE_DISCOVERY_PRIVATE_DNS_NAMESPACE = \
'AWS::ServiceDiscovery::PrivateDnsNamespace'
CODE_COMMIT_REPOSITORY = \
'AWS::CodeCommit::Repository'


class GetAtt(object):
Expand Down
37 changes: 37 additions & 0 deletions e3/aws/cfn/codecommit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from e3.aws.cfn import AWSType, Resource
import re


class Repository(Resource):
"""CodeCommit Repository."""

ATTRIBUTES = ("Arn", "CloneUrlHttp", "CloneUrlSsh", "Name")

def __init__(self, name, description):
"""Initialize a Repository.
:param name: name of the repository
:type name: str
:param description: description of the repository content
:type description: str
"""
resource_name = re.sub(r"[^a-zA-Z0-9]+", "", name)
super(Repository, self).__init__(
resource_name, kind=AWSType.CODE_COMMIT_REPOSITORY
)
self.name = resource_name
self.repository_name = name
self.description = description

@property
def properties(self):
"""Serialize the object as a simple dict.
Can be used to transform to CloudFormation Yaml format.
:rtype: dict
"""
return {
"RepositoryName": self.repository_name,
"RepositoryDescription": self.description,
}

0 comments on commit 39fe6ea

Please sign in to comment.