AWS CDK Node.js Asset Proxy Agent v6
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
- gotcha This library is primarily an environmental utility, not a Python library with direct callable APIs. Its effect is on the `cdk` CLI's behavior when bundling Node.js assets, rather than through direct Python code execution.
- gotcha Requires Node.js and the AWS CDK CLI to be installed and correctly configured in your environment. This package acts as an add-on for existing CDK development workflows behind a proxy.
- breaking The `v6` in the package name indicates compatibility with a specific version or approach of the underlying Node.js proxy agent. Future major versions of AWS CDK or Node.js might introduce breaking changes that require an updated version of this proxy agent.
- gotcha The package requires Python 3.9 or higher. Using it with older Python versions will result in an installation error.
Install
-
pip install aws-cdk-asset-node-proxy-agent-v6
Imports
- aws_cdk_asset_node_proxy_agent_v6
import aws_cdk_asset_node_proxy_agent_v6
Quickstart
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'.