예제 #1
0
def lambda_deploy(
    ctx,
    verbose,
    nocache,
    yes,
    warn,
    disable_validation,
    quiet_changes_only,
    hooks_only,
    cfn_lint,
    config_scope,
    home='.',
):
    """
    Deploy Lambda code to AWS.
    """
    paco_ctx = ctx.obj
    command = 'lambda deploy'
    controller_type, obj = init_cloud_command(command, paco_ctx, verbose,
                                              nocache, yes, warn,
                                              disable_validation,
                                              quiet_changes_only, hooks_only,
                                              cfn_lint, config_scope, home)
    controller = paco_ctx.get_controller(controller_type, command, obj)
    controller.lambda_deploy_command(obj)
예제 #2
0
def set_command(
    paco_ctx,
    verbose,
    nocache,
    yes,
    warn,
    disable_validation,
    quiet_changes_only,
    config_scope,
    home='.',
):
    """Set the value of a cloud resource"""
    command = 'set'
    controller_type, obj = init_cloud_command(
        command,
        paco_ctx,
        verbose,
        nocache,
        yes,
        warn,
        disable_validation,
        quiet_changes_only,
        config_scope,
        home
    )
    controller = paco_ctx.get_controller(controller_type, command, obj)
    controller.set_command(obj)
예제 #3
0
def validate_command(
    paco_ctx,
    verbose,
    nocache,
    yes,
    warn,
    disable_validation,
    quiet_changes_only,
    hooks_only,
    config_scope,
    home='.'
):
    "Validate resources"
    command = 'validate'
    controller_type, obj = init_cloud_command(
        command,
        paco_ctx,
        verbose,
        nocache,
        yes,
        warn,
        disable_validation,
        quiet_changes_only,
        hooks_only,
        config_scope,
        home
    )
    controller = paco_ctx.get_controller(controller_type, 'validate', obj)
    controller.validate()
예제 #4
0
def delete_command(paco_ctx,
                   verbose,
                   nocache,
                   yes,
                   warn,
                   disable_validation,
                   quiet_changes_only,
                   hooks_only,
                   config_scope,
                   home='.'):
    """Deletes provisioned Cloud Resources"""
    command = 'delete'
    controller_type, obj = init_cloud_command(command, paco_ctx, verbose,
                                              nocache, yes, warn,
                                              disable_validation,
                                              quiet_changes_only, hooks_only,
                                              config_scope, home)
    answer = paco_ctx.input_confirm_action(
        "Proceed with deletion of {}?".format(config_scope))
    if answer == False:
        print("Aborted delete operation.")
        return

    controller = paco_ctx.get_controller(controller_type, 'delete', obj)
    controller.delete()
예제 #5
0
def lambda_invoke(
    ctx,
    verbose,
    nocache,
    yes,
    warn,
    disable_validation,
    quiet_changes_only,
    hooks_only,
    config_scope,
    home='.',
    event='',
    event_file='',
):
    """
    Invoke a provisioned Lambda
    """
    paco_ctx = ctx.obj
    command = 'lambda invoke'

    if event_file != '' and event != '':
        print(
            "Can not supply both -e,--event and -f,--event-file options. Event must be one or the other."
        )
        sys.exit()

    if event_file != '':
        try:
            with open(event_file, 'r') as fh:
                event = fh.read()
        except FileNotFoundError:
            print(
                f"No file exists at the location supplied with the -f,--event-file option:\n\n  {event_file}\n"
            )
            sys.exit()

    if event != '':
        # validate the JSON
        try:
            json.loads(event)
        except json.decoder.JSONDecodeError:
            print("Event supplied is not in valid JSON format.")
            sys.exit()
    else:
        event = None

    controller_type, obj = init_cloud_command(command, paco_ctx, verbose,
                                              nocache, yes, warn,
                                              disable_validation,
                                              quiet_changes_only, hooks_only,
                                              config_scope, home)
    controller = paco_ctx.get_controller(controller_type, command, obj)
    controller.lambda_invoke_command(obj, event)
예제 #6
0
def provision_command(paco_ctx,
                      verbose,
                      nocache,
                      yes,
                      disable_validation,
                      quiet_changes_only,
                      config_scope,
                      home='.'):
    """Provision Cloud Resources"""
    command = 'provision'
    controller_type, obj = init_cloud_command(command, paco_ctx, verbose,
                                              nocache, yes, disable_validation,
                                              quiet_changes_only, config_scope,
                                              home)
    controller = paco_ctx.get_controller(controller_type, command, obj)
    controller.provision()
예제 #7
0
def provision_command(
    paco_ctx,
    verbose,
    nocache,
    yes,
    warn,
    disable_validation,
    quiet_changes_only,
    hooks_only,
    config_scope,
    home='.',
    auto_publish_code=False,
):
    """Provision Cloud Resources"""
    paco_ctx.auto_publish_code = auto_publish_code
    command = 'provision'
    controller_type, obj = init_cloud_command(command, paco_ctx, verbose,
                                              nocache, yes, warn,
                                              disable_validation,
                                              quiet_changes_only, hooks_only,
                                              config_scope, home)
    controller = paco_ctx.get_controller(controller_type, command, obj)
    controller.provision()