Skip to content

Commit 9478a6f

Browse files
committed
feature: support inter container traffic encryption for processing jobs
1 parent 3bf569e commit 9478a6f

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

src/sagemaker/network.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,35 @@ class NetworkConfig(object):
2020
"""Accepts network configuration parameters and provides a method to turn these parameters
2121
into a dictionary."""
2222

23-
def __init__(self, enable_network_isolation=False, security_group_ids=None, subnets=None):
23+
def __init__(
24+
self,
25+
enable_network_isolation=False,
26+
encrypt_inter_container_traffic=False,
27+
security_group_ids=None,
28+
subnets=None,
29+
):
2430
"""Initialize a ``NetworkConfig`` instance. NetworkConfig accepts network configuration
2531
parameters and provides a method to turn these parameters into a dictionary.
2632
2733
Args:
2834
enable_network_isolation (bool): Boolean that determines whether to enable
2935
network isolation.
36+
encrypt_inter_container_traffic (bool): Boolean that determines whether to
37+
encrypt inter-container traffic.
3038
security_group_ids ([str]): A list of strings representing security group IDs.
3139
subnets ([str]): A list of strings representing subnets.
3240
"""
3341
self.enable_network_isolation = enable_network_isolation
42+
self.encrypt_inter_container_traffic = encrypt_inter_container_traffic
3443
self.security_group_ids = security_group_ids
3544
self.subnets = subnets
3645

3746
def _to_request_dict(self):
3847
"""Generates a request dictionary using the parameters provided to the class."""
39-
network_config_request = {"EnableNetworkIsolation": self.enable_network_isolation}
48+
network_config_request = {
49+
"EnableNetworkIsolation": self.enable_network_isolation,
50+
"EnableInterContainerTrafficEncryption": self.encrypt_inter_container_traffic,
51+
}
4052

4153
if self.security_group_ids is not None or self.subnets is not None:
4254
network_config_request["VpcConfig"] = {}

tests/unit/test_processing.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ def test_sklearn_with_all_parameters(exists_mock, isfile_mock, ecr_prefix, sagem
141141
subnets=["my_subnet_id"],
142142
security_group_ids=["my_security_group_id"],
143143
enable_network_isolation=True,
144+
encrypt_inter_container_traffic=True,
144145
),
145146
sagemaker_session=sagemaker_session,
146147
)
@@ -330,6 +331,7 @@ def test_script_processor_with_all_parameters(exists_mock, isfile_mock, sagemake
330331
subnets=["my_subnet_id"],
331332
security_group_ids=["my_security_group_id"],
332333
enable_network_isolation=True,
334+
encrypt_inter_container_traffic=True,
333335
),
334336
sagemaker_session=sagemaker_session,
335337
)
@@ -405,6 +407,7 @@ def test_processor_with_all_parameters(sagemaker_session):
405407
subnets=["my_subnet_id"],
406408
security_group_ids=["my_security_group_id"],
407409
enable_network_isolation=True,
410+
encrypt_inter_container_traffic=True,
408411
),
409412
)
410413

@@ -580,6 +583,7 @@ def _get_expected_args_all_parameters(job_name):
580583
"environment": {"my_env_variable": "my_env_variable_value"},
581584
"network_config": {
582585
"EnableNetworkIsolation": True,
586+
"EnableInterContainerTrafficEncryption": True,
583587
"VpcConfig": {
584588
"SecurityGroupIds": ["my_security_group_id"],
585589
"Subnets": ["my_subnet_id"],

tests/unit/test_session.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ def test_process(boto_session):
131131
},
132132
"environment": {"my_env_variable": 20},
133133
"network_config": {
134+
"EnableInterContainerTrafficEncryption": True,
134135
"EnableNetworkIsolation": True,
135136
"VpcConfig": {
136137
"SecurityGroupIds": ["my_security_group_id"],
@@ -219,6 +220,7 @@ def test_process(boto_session):
219220
},
220221
"Environment": {"my_env_variable": 20},
221222
"NetworkConfig": {
223+
"EnableInterContainerTrafficEncryption": True,
222224
"EnableNetworkIsolation": True,
223225
"VpcConfig": {
224226
"SecurityGroupIds": ["my_security_group_id"],

0 commit comments

Comments
 (0)