AWS CDK Node.js Asset Proxy Agent v6

2.1.1 · active · verified Thu Apr 09

This Python package provides a proxy agent for AWS CDK applications that build Node.js assets (e.g., Lambda functions) behind an HTTP/HTTPS proxy. It wraps the `@aws-cdk/asset-node-proxy-agent-v6` Node.js package, enabling the `cdk` CLI to automatically route Node.js asset bundling traffic through configured proxy servers. The current version is 2.1.1, with releases typically aligning with updates to the underlying Node.js agent or CDK ecosystem.

Warnings

Install

Imports

Quickstart

This package primarily functions by being installed in the Python environment where `cdk` commands are run, and by the presence of standard proxy environment variables (e.g., `HTTPS_PROXY`). The `cdk` CLI automatically detects and uses it when building Node.js assets. The example below shows a basic CDK app with a Node.js Lambda, which would implicitly benefit from the proxy agent if environment variables are set.

import os
from aws_cdk import App, Stack
from aws_cdk.aws_lambda_nodejs import NodejsFunction
from aws_cdk import aws_lambda as _lambda
from constructs import Construct

# This package's functionality relies on its installation and environment variables.
# No direct Python code interaction with aws_cdk_asset_node_proxy_agent_v6 is typical.

# Simulate proxy environment variables that the CDK CLI will pick up.
# In a real scenario, these would be set in your shell before running 'cdk deploy'.
os.environ['HTTPS_PROXY'] = os.environ.get('HTTPS_PROXY', 'http://your.proxy.server:8080')
os.environ['NO_PROXY'] = os.environ.get('NO_PROXY', 'localhost,127.0.0.1,.internal.domain')

class MyProxyAwareNodejsStack(Stack):
    def __init__(self, scope: Construct, id: str, **kwargs) -> None:
        super().__init__(scope, id, **kwargs)

        # A Node.js Lambda function, which will trigger the asset bundling process.
        # If this package is installed and proxy env vars are set, the bundling
        # process will automatically use the proxy agent.
        NodejsFunction(
            self, "MyProxyAwareLambda",
            entry="lambda/handler.ts", # Placeholder: this file would need to exist for a real deploy
            handler="handler",
            runtime=_lambda.Runtime.NODEJS_18_X,
            # Bundling will automatically pick up proxy settings if configured
        )

# Create a CDK app and synthesize the stack
app = App()
MyProxyAwareNodejsStack(app, "ProxyTestStack")
app.synth()

# Note: For a real deployment, ensure 'lambda/handler.ts' exists, Node.js and the
# AWS CDK CLI are installed, and proxy environment variables are correctly set.
# This package should be installed in the same Python environment where you run 'cdk synth' or 'cdk deploy'.

view raw JSON →