Registry / aws / aws-cdk-asset-node-proxy-agent-v5

aws-cdk-asset-node-proxy-agent-v5

JSON →
library2.0.166pypypiunverified

The `aws-cdk-asset-node-proxy-agent-v5` library provides an AWS CDK Construct that configures Node.js-based assets (e.g., Lambda functions) to use an HTTP/HTTPS proxy during their build and bundling phases. This is critical for CDK deployments in corporate environments where internet access requires going through a proxy, leveraging the `proxy-agent` Node.js library. It is an experimental construct from `cdklabs` and is currently at version 2.0.166, aligning with AWS CDK v2 releases, with updates tied to CDK's release cadence.

pip install aws-cdk-asset-node-proxy-agent-v5
INSTALL
IMPORT
SIG · AWS-CDK-ASSET-NODE
A
aws-cdk-asset-node-proxy-agent-v5
awspythonv2.0.166
Install
2.3s avg
Import
Disk
22MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.0.166 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 24.2MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 2.3s · import 0.000s · 25MB
22MB installed
● package 22MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

NodeProxyAgent
from aws_cdk.asset_node_proxy_agent_v5 import NodeProxyAgent
from aws_cdk.asset_node_proxy_agent_v5 import NodeProxyAgent

This quickstart demonstrates how to integrate `NodeProxyAgent` into your CDK application. It sets up an `NodeProxyAgent` instance to configure proxy settings for Node.js assets during synthesis, using environment variables for proxy URLs. A sample `NodejsFunction` is included, which will then use these proxy settings during its bundling process.

import os from aws_cdk import App, Stack, Environment from aws_cdk.aws_lambda_nodejs import NodejsFunction from aws_cdk_asset_node_proxy_agent_v5 import NodeProxyAgent class MyProxyStack(Stack): def __init__(self_stack, scope, id, **kwargs): super().__init__(scope, id, **kwargs) # Define proxy configuration - ensure these env vars are set in your build environment http_proxy = os.environ.get('HTTP_PROXY', '') https_proxy = os.environ.get('HTTPS_PROXY', '') no_proxy = os.environ.get('NO_PROXY', '') if http_proxy or https_proxy: # Instantiate the NodeProxyAgent construct NodeProxyAgent(self_stack, "NodeProxyAgent", http_proxy=http_proxy, https_proxy=https_proxy, no_proxy=no_proxy ) print(f"NodeProxyAgent configured with HTTP_PROXY: {http_proxy} and HTTPS_PROXY: {https_proxy}") else: print("No proxy environment variables found. NodeProxyAgent not configured.") # Example Node.js Lambda function, its bundling will use the configured proxy NodejsFunction( self_stack, "MyProxyEnabledFunction", entry="./lambda/index.ts", # Replace with your Node.js Lambda entry point handler="handler", memory_size=128 ) app = App() MyProxyStack(app, "MyProxyEnabledStack", env=Environment(account=os.environ.get('CDK_DEFAULT_ACCOUNT', '123456789012'), region=os.environ.get('CDK_DEFAULT_REGION', 'us-east-1')) ) app.synth()
Debug
Known issues
gotchaThe `NodeProxyAgent` configures proxy settings for Node.js *asset bundling* (e.g., when `NodejsFunction` builds its code package). It does NOT configure runtime proxy settings for the deployed Lambda function itself. If your Lambda needs to egress through a proxy at runtime, that must be configured separately.
fix
Understand the distinction between build-time and runtime proxying. For runtime proxying, use Lambda environment variables or a custom layer that configures `https-proxy-agent` or similar.
affects: All v2.x.x
breakingThis construct is specific to Node.js `proxy-agent` v5. If your project relies on an older or newer major version of `proxy-agent` in a custom build step, this construct might not be compatible or could override existing configurations unexpectedly.
fix
Ensure your Node.js asset's dependencies and build environment are compatible with `proxy-agent` v5. If using a different version, consider if this construct is necessary or if manual configuration is more appropriate.
affects: All v2.x.x
gotchaThe `http_proxy`, `https_proxy`, and `no_proxy` arguments to `NodeProxyAgent` override any existing `HTTP_PROXY`, `HTTPS_PROXY`, `NO_PROXY` environment variables *during the asset bundling process*. Ensure your construct parameters correctly reflect the desired proxy configuration.
fix
Explicitly pass all required proxy settings (including `no_proxy`) to the `NodeProxyAgent` constructor. Do not rely solely on environment variables if the construct is instantiated with parameters, as parameters take precedence.
affects: All v2.x.x
Upgrade
Version history
2.0.166latest on PyPI · released Jul 20, 2023
Audit
Dependencies
aws-cdk-librequiredThis is an AWS CDK Construct and requires the core CDK library.
constructsrequiredUnderlying dependency for all CDK constructs.
Agent activity
25 hits · last 30 days
node
24
Resources
aws-cdk-asset-node-proxy-agent-v5 — pip install aws-cdk-asset-node-proxy-agent-v5 · libregistry