Skip to content

Commit 8b5ab97

Browse files
Add tags parameter to create_default_security_group function (#471)
1 parent eebe726 commit 8b5ab97

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

dask_cloudprovider/aws/ecs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1163,7 +1163,7 @@ async def _create_cloudwatch_logs_group(self):
11631163
async def _create_security_groups(self):
11641164
async with self._client("ec2") as client:
11651165
group = await create_default_security_group(
1166-
client, self.cluster_name, self._vpc
1166+
client, self.cluster_name, self._vpc, self.tags
11671167
)
11681168
weakref.finalize(self, self.sync, self._delete_security_groups)
11691169
return [group]

dask_cloudprovider/aws/helper.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Helper functions for working with AWS services."""
2+
23
from datetime import datetime
34

45
DEFAULT_SECURITY_GROUP_NAME = "dask-default"
@@ -93,11 +94,21 @@ async def get_security_group(client, vpc, create_default=True):
9394
)
9495

9596

96-
async def create_default_security_group(client, group_name, vpc):
97+
async def create_default_security_group(client, group_name, vpc, tags):
9798
response = await client.create_security_group(
9899
Description="A default security group for Dask",
99100
GroupName=group_name,
100101
VpcId=vpc,
102+
TagSpecifications=[
103+
{
104+
"ResourceType": "security-group",
105+
"Tags": [
106+
{"Key": k, "Value": v}
107+
for k, v in (tags or {}).items()
108+
if k and v # Filter out empty tags
109+
],
110+
}
111+
],
101112
DryRun=False,
102113
)
103114

0 commit comments

Comments
 (0)