Skip to content

Commit 9ce8d79

Browse files
author
Himani Anil Deshpande
committed
[DevSetting] Add install_proxy_url which will allow ParallelCluster to set Proxy environment for Build Image installation
* Adding a recipe to setup proxy env as part of cookbook to avoid Sizing issue in parallelcluster.yaml * Add s3 global endpoint to overcome cfn_bootstrap script installation * Add s3 enpoint for no proxy list so it goes to VPC endpoint * addding old style s3 naming convention bucket-name.s3-eu-west-1.amazonaws.com to handle S3 redirecting (307 Temporary Redirect) when we use non-us-east-1 region * Add cdn for amazonlinux in no_proxy list to re-direct to VPC endpoint
1 parent b00c861 commit 9ce8d79

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

cookbooks/aws-parallelcluster-entrypoints/recipes/install.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
return if node['conditions']['ami_bootstrapped']
1818

1919
include_recipe "aws-parallelcluster-shared::setup_envars"
20+
include_recipe "aws-parallelcluster-shared::detect_proxy" if node['cluster']['install_proxy_url']
2021

2122
include_recipe 'aws-parallelcluster-platform::install'
2223
include_recipe 'aws-parallelcluster-environment::install'
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# frozen_string_literal: true
2+
3+
#
4+
# Cookbook:: aws-parallelcluster
5+
# Recipe:: detect_proxy
6+
#
7+
# Copyright:: 2026 Amazon.com, Inc. or its affiliates. All Rights Reserved.
8+
#
9+
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the
10+
# License. A copy of the License is located at
11+
#
12+
# http://aws.amazon.com/apache2.0/
13+
#
14+
# or in the "LICENSE.txt" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
15+
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
18+
# This recipe configures proxy environment variables for build-image in isolated networks.
19+
#
20+
# It reads the proxy URL from node['cluster']['install_proxy_url'] (set via ExtraChefAttributes)
21+
# and configures http_proxy/https_proxy ENV vars for the Chef run. This makes all subsequent
22+
# Chef resources (remote_file, bash, execute, etc.) use the explicit proxy for HTTPS traffic
23+
# instead of trying direct connections that would fail in an isolated network.
24+
#
25+
# The no_proxy list excludes S3 endpoints so downloads from S3 go through the VPC Gateway
26+
# Endpoint directly, not through the proxy.
27+
# S3 endpoints are excluded so cookbook/dependency downloads from S3 go through
28+
# the S3 VPC Gateway Endpoint directly, not through the proxy.
29+
# Both regional (s3.{region}.amazonaws.com) and global (s3.amazonaws.com) endpoints
30+
# are included because some resources use the global endpoint (e.g., cloudformation-examples
31+
# bucket uses https://s3.amazonaws.com/cloudformation-examples/...).
32+
# Note: only the regional S3 endpoint is in no_proxy because the S3 VPC Gateway Endpoint
33+
# handles regional endpoints correctly. The global s3.amazonaws.com endpoint does NOT work
34+
# through the VPC Gateway Endpoint (SSL errors), so it is intentionally left out of no_proxy
35+
# and instead goes through the proxy which has internet access. The proxy allowlist in
36+
# proxy_stack.yaml must include s3.amazonaws.com for this to work.
37+
# IMDS (169.254.169.254) and ECS task metadata (169.254.170.2) are also excluded.
38+
#
39+
# This recipe only runs when install_proxy_url is set — normal builds are unaffected.
40+
41+
ruby_block 'configure proxy from install_proxy_url' do
42+
block do
43+
proxy_url = node['cluster']['install_proxy_url']
44+
45+
if proxy_url && !proxy_url.empty?
46+
region = node['cluster']['region']
47+
48+
# S3 endpoints bypass the proxy and use the VPC Gateway Endpoint.
49+
# Includes regional (s3.{region}), dash-style (s3-{region}), global (s3.amazonaws.com),
50+
# and dualstack (s3.dualstack.{region}) variants used by different AWS services and repos.
51+
no_proxy = [
52+
"localhost",
53+
"127.0.0.1",
54+
"169.254.169.254",
55+
"169.254.170.2",
56+
".s3.#{region}.amazonaws.com",
57+
"s3.#{region}.amazonaws.com",
58+
".s3-#{region}.amazonaws.com",
59+
"s3-#{region}.amazonaws.com",
60+
".s3.amazonaws.com",
61+
".s3.dualstack.#{region}.amazonaws.com",
62+
"s3.dualstack.#{region}.amazonaws.com",
63+
].join(",")
64+
65+
Chef::Log.info("Configuring proxy: #{proxy_url}")
66+
67+
ENV['http_proxy'] = proxy_url
68+
ENV['https_proxy'] = proxy_url
69+
ENV['HTTP_PROXY'] = proxy_url
70+
ENV['HTTPS_PROXY'] = proxy_url
71+
ENV['no_proxy'] = no_proxy
72+
ENV['NO_PROXY'] = no_proxy
73+
else
74+
Chef::Log.info("No install_proxy_url set, skipping proxy configuration")
75+
end
76+
end
77+
end

0 commit comments

Comments
 (0)