Beispiel #1
0
def deploy(
    plugin_id: str,
    context: "Context",
    team_context: "TeamContext",
    parameters: Dict[str, Any],
) -> None:
    _logger.debug("Running emr_on_eks deploy!")
    sh.run(f"echo 'Team name: {team_context.name} | Plugin ID: {plugin_id}'")
    cluster_name = f"orbit-{context.name}"
    virtual_cluster_name = f"orbit-{context.name}-{team_context.name}"
    delete_virtual_cluster(cluster_name, virtual_cluster_name)

    sh.run(
        f"eksctl create iamidentitymapping --cluster {cluster_name} "
        + f'--namespace {team_context.name} --service-name "emr-containers"'
    )
    if team_context.eks_pod_role_arn is None:
        raise ValueError("Pod Role arn required")
    role_name = (
        team_context.eks_pod_role_arn.split("/")[2]
        if context.role_prefix
        else team_context.eks_pod_role_arn.split("/")[1]
    )
    sh.run(
        f" aws emr-containers update-role-trust-policy \
       --cluster-name {cluster_name} \
       --namespace {team_context.name} \
       --role-name {role_name}"
    )
    emr = boto3.client("emr-containers")
    _logger.info("deploying emr on eks iam policy")
    cdk_deploy(
        stack_name=f"orbit-{context.name}-{team_context.name}-emr-on-eks",
        app_filename=os.path.join(ORBIT_EMR_ON_EKS_ROOT, "cdk.py"),
        context=context,
        team_context=team_context,
        parameters=parameters,
    )
    try:
        _logger.info(f"creating emr virtual cluster {virtual_cluster_name}")
        response = emr.create_virtual_cluster(
            name=virtual_cluster_name,
            containerProvider={
                "id": cluster_name,
                "type": "EKS",
                "info": {"eksInfo": {"namespace": team_context.name}},
            },
            tags={"Env": context.name, "TeamSpace": team_context.name},
        )

        _logger.debug("create_virtual_cluster:", response)
        parameters["virtual_cluster_id"] = response["id"]
        parameters["virtual_name"] = response["name"]
        parameters["virtual_arn"] = response["arn"]

    except Exception as e:
        if "A virtual cluster already exists in the given namespace" in str(e):
            pass
        else:
            raise
Beispiel #2
0
def deploy(plugin_id: str, context: "Context", team_context: "TeamContext", parameters: Dict[str, Any]) -> None:
    _logger.debug("Deploying Redshift plugin resources for team %s", team_context.name)
    sh.run(f"echo 'Team name: {team_context.name} | Plugin ID: {plugin_id}'")
    cdk_deploy(
        stack_name=f"orbit-{context.name}-{team_context.name}-{plugin_id}-redshift",
        app_filename=os.path.join(PLUGIN_ROOT_PATH, "orbit_redshift_stack.py"),
        context=context,
        team_context=team_context,
        parameters=parameters,
    )
def deploy(plugin_id: str, context: "Context", team_context: "TeamContext",
           parameters: Dict[str, Any]) -> None:
    _logger.debug("Deploying CodeCommit plugin resources for team %s",
                  team_context.name)
    cdk_deploy(
        stack_name=f"orbit-{context.name}-{team_context.name}-codecommit",
        app_filename=os.path.join(ORBIT_CODE_COMMIT_ROOT, "cdk.py"),
        context=context,
        team_context=team_context,
        parameters=parameters,
    )
Beispiel #4
0
def deploy(plugin_id: str, context: "Context", team_context: "TeamContext",
           parameters: Dict[str, Any]) -> None:
    _logger.debug("Running hello_world deploy!")
    sh.run(f"echo 'Team name: {team_context.name} | Plugin ID: {plugin_id}'")
    cdk_deploy(
        stack_name=f"orbit-{context.name}-{team_context.name}-hello",
        app_filename=os.path.join(PLUGIN_ROOT_PATH, "hello_cdk.py"),
        context=context,
        team_context=team_context,
        parameters=parameters,
    )
Beispiel #5
0
def deploy(
    plugin_id: str,
    context: "Context",
    team_context: "TeamContext",
    parameters: Dict[str, Any],
) -> None:
    _logger.debug(
        "Deploying Custom CloudFormation plugin resources for team %s",
        team_context.name,
    )
    if parameters["CfnTemplatePath"] and os.path.isfile(
            parameters["CfnTemplatePath"]):
        _logger.info(
            f"CloudFormation template found at {parameters['CfnTemplatePath']}"
        )
    else:
        raise FileNotFoundError(
            f"CloudFormation template not found at {parameters['CfnTemplatePath']}"
        )

    plugin_id = plugin_id.replace("_", "-")
    _logger.debug("plugin_id: %s", plugin_id)
    cfn_params: Dict[str, Any] = {
        "envname": context.name,
        "envdeployid": cast(str, context.toolkit.deploy_id),
        "envcognitouserpoolid": cast(str, context.user_pool_id),
    }
    cfn_params.update(parameters)
    _logger.debug(f"cfn_params={cfn_params}")
    cdk_deploy(
        stack_name=
        f"orbit-{context.name}-{team_context.name}-{plugin_id}-custom-demo-resources",
        app_filename=os.path.join(ORBIT_CUSTOM_CFN_ROOT, "cdk.py"),
        context=context,
        team_context=team_context,
        parameters=cfn_params,
    )
    _logger.debug("Custom Cfn plugin pre_hook compeleted")