Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
67 lines (61 sloc) 1.53 KB
from troposphere import (
AWS_ACCOUNT_ID,
AWS_REGION,
AWS_STACK_NAME,
Join,
Ref,
Output,
)
from troposphere.ecr import Repository
from awacs.aws import (
Allow,
Policy,
AWSPrincipal,
Statement,
)
import awacs.ecr as ecr
from .template import template
# Create an `ECR` docker repository
repository = Repository(
"ApplicationRepository",
template=template,
RepositoryName=Ref(AWS_STACK_NAME),
# Allow all account users to manage images.
RepositoryPolicyText=Policy(
Version="2008-10-17",
Statement=[
Statement(
Sid="AllowPushPull",
Effect=Allow,
Principal=AWSPrincipal([
Join("", [
"arn:aws:iam::",
Ref(AWS_ACCOUNT_ID),
":root",
]),
]),
Action=[
ecr.GetDownloadUrlForLayer,
ecr.BatchGetImage,
ecr.BatchCheckLayerAvailability,
ecr.PutImage,
ecr.InitiateLayerUpload,
ecr.UploadLayerPart,
ecr.CompleteLayerUpload,
],
),
]
),
)
# Output ECR repository URL
template.add_output(Output(
"RepositoryURL",
Description="The docker repository URL",
Value=Join("", [
Ref(AWS_ACCOUNT_ID),
".dkr.ecr.",
Ref(AWS_REGION),
".amazonaws.com/",
Ref(repository),
]),
))