Exemplo n.º 1
0
import base64
import pulumi
import pulumi_aws as aws
import pulumi_docker as docker
from pulumi_aws import ecr

def get_registry_info(rid):
    creds = aws.ecr.get_credentials(rid)
    decoded = base64.b64decode(creds.authorization_token).decode()
    parts = decoded.split(':')
    if len(parts) != 2:
        raise Exception("Invalid credentials")
    return docker.ImageRegistry(creds.proxy_endpoint, parts[0], parts[1])


repository = ecr.Repository("test-repository", name="test-repository")
registry = repository.registry_id.apply(get_registry_info)


image = docker.Image(
    'my-image',
    build=docker.DockerBuild(context='.', args={}),
    image_name=repository.repository_url.apply(lambda url: url + ':latest'),
    registry=registry)
Exemplo n.º 2
0
def create_repository(repo_name):
    # create repository
    repository = ecr.Repository(repo_name)
    pulumi.export('repository_name', repository.name)
    pulumi.export('repository_url', repository.repository_url)
Exemplo n.º 3
0
import base64
from pulumi_aws import ecr
import pulumi_docker as docker
import pulumi

app = 'my-app'

# Create repository
repo = ecr.Repository(app)


def create_image_registry(rid):
    creds = ecr.get_credentials(rid)
    decoded = base64.b64decode(creds.authorization_token).decode('utf-8')
    username, password = decoded.split(':')
    return docker.ImageRegistry(creds.proxy_endpoint, username, password)


# Get credentials and create an ImageRegistry from that
registry = repo.registry_id.apply(lambda rid: create_image_registry(rid))

# Create image
image = docker.Image(app,
                     image_name=pulumi.Output.concat(repo.repository_url, ':',
                                                     '1.0.0'),
                     build=docker.DockerBuild(context=f'./{app}'),
                     registry=registry)
Exemplo n.º 4
0
vpc = ec2.Vpc("myvpc", cidr_block="10.0.0.0/16")

igw = ec2.InternetGateway("myinternetgateway", vpc_id=vpc.id)

public_route_table = ec2.RouteTable("myroutetable",
                                    routes=[
                                        ec2.RouteTableRouteArgs(
                                            cidr_block="0.0.0.0/0",
                                            gateway_id=igw.id)
                                    ],
                                    vpc_id=vpc.id)

## ECR

repository = ecr.Repository("myrepository")

repository_policy = ecr.RepositoryPolicy(
    "myrepositorypolicy",
    repository=repository.id,
    policy=json.dumps({
        "Version":
        "2012-10-17",
        "Statement": [{
            "Sid":
            "new policy",
            "Effect":
            "Allow",
            "Principal":
            "*",
            "Action": [