Example #1
0
    def aws_assume_role(self, aws_role, aws_account_id):
        click.echo('Assuming role %s at %s' % (aws_role, aws_account_id))
        container = Container()
        image = Image()

        AWS_IMAGE = image.get_image('aws')
        envs = {
            'AWS_ROLE': aws_role,
            'AWS_ACCOUNT_ID': aws_account_id,
        }
        envs.update(self.env_auth)

        command = 'assume-role.sh'
        output = container.create(image=AWS_IMAGE,
                                  entrypoint='/bin/bash -c',
                                  command=command,
                                  volumes=['.:/work'],
                                  environment=envs,
                                  tty=False,
                                  stdin_open=False)

        self.env_assume = parse_env('\n'.join(output.splitlines()))
        return self.env_assume
Example #2
0
import click
from one.one import cli
from one.docker.container import Container
from one.docker.image import Image
from one.utils.environment.aws import EnvironmentAws
from one.utils.config import get_config_value

container = Container()
image = Image()
environment = EnvironmentAws()
AWS_IMAGE = image.get_image('aws')
KUBE_TOOLS_IMAGE = 'dnxsolutions/docker-kube-tools:0.3.2'


def __init__():
    cli.add_command(kubectl)
    cli.add_command(helm)
    cli.add_command(kube_shell)
    cli.add_command(kube_proxy)


def get_kube_config(aws_default_region, cluster_name, envs):
    kubeconfig = get_config_value('plugins.kube.parameters.kubeconfig', '') or '/work/.kube-config'
    command = 'eks --region %s update-kubeconfig --name %s --kubeconfig %s' % (aws_default_region, cluster_name, kubeconfig)
    container.create(
        image=AWS_IMAGE,
        command=command,
        volumes=['.:/work'],
        environment=envs
    )
Example #3
0
import click
from one.docker.container import Container
from one.docker.image import Image
from one.utils.environment.aws import EnvironmentAws
from one.utils.config import get_config_value, get_workspace_value
from one.utils.app.common import app_deploy_factory, app_registry_factory

image = Image()
container = Container()
environment = EnvironmentAws()

ECS_DEPLOY_IMAGE = image.get_image('ecs_deploy')
AWS_IMAGE = image.get_image('aws')


@click.group(help='Group of app commands wrapped inside docker.')
def app():
    pass


@app.command(name='docker-build', help='Build docker image for deployment.')
@click.option('--build-version',
              default='latest',
              help='Build version, used as tag for docker image.')
def docker_build(build_version):
    app_registry = app_registry_factory(
        get_config_value('app.docker.registry_type', 'ecr'))
    app_registry.docker_build(build_version)


@app.command(name='docker-login', help='Login into docker registry.')
Example #4
0
import click
from one.docker.container import Container
from one.docker.image import Image
from one.utils.environment.aws import EnvironmentAws

container = Container()
image = Image()
environment = EnvironmentAws()
AWS_IMAGE = image.get_image('aws')
AWS_V2_IMAGE = image.get_image('aws_v2')


@click.command(help='AWS CLI alias.')
@click.argument('args', nargs=-1)
@click.option('-w',
              '--workspace',
              default=None,
              type=str,
              help='Workspace to use.')
@click.option('-r',
              '--aws-role',
              'aws_role',
              default=None,
              type=str,
              help='AWS role to use.')
def aws(args, workspace, aws_role):
    envs = environment.build(workspace, aws_role).get_env()
    command = ''
    for arg in args:
        command += '%s ' % (arg)
    container.create(image=AWS_IMAGE,
Example #5
0
import click
import yaml
from one.__init__ import CONFIG_FILE
from one.docker.container import Container
from one.docker.image import Image
from one.utils.environment.aws import EnvironmentAws
from one.one import cli

container = Container()
image = Image()
SHELL_IMAGE = image.get_image('shell')


def make_callback(image, command, ports, entrypoint, volumes, environment):
    def callback():
        secrets_envs = EnvironmentAws().build(
            workspace='default',
            aws_account_id='none',
            aws_role='none',
            aws_assume_role='false').get_env()
        environment.update(secrets_envs)
        container.create(image=image,
                         command=command,
                         ports=ports,
                         entrypoint=entrypoint,
                         volumes=volumes,
                         environment=environment)

    return callback

Example #6
0
import click
from one.docker.container import Container
from one.docker.image import Image
from one.utils.environment.aws import EnvironmentAws
from one.utils.terraform_modules import terraform_modules_check
from one.utils.config import get_config_value, str2bool

image = Image()
container = Container()
environment = EnvironmentAws()
TERRAFORM_IMAGE = image.get_image('terraform')


@click.group(help='Group of terraform commands wrapped inside docker.')
def terraform():
    pass


@terraform.command(help='Run terraform init inside the docker container.')
@click.option('-w',
              '--workspace',
              default=None,
              type=str,
              help='Workspace to use.')
@click.option('-r',
              '--aws-role',
              'aws_role',
              default=None,
              type=str,
              help='AWS role to use.')
@click.option('-c',