Skip to content

Commit

Permalink
Merge pull request #5275 from wazuh/bug/5228-ddt1-allocatiton-module-…
Browse files Browse the repository at this point in the history
…bug-macos-host-dediicated

Fixed deploy for macOS in AWS
  • Loading branch information
teddytpc1 authored Apr 19, 2024
2 parents ea0a03f + 2988be0 commit 8e24f34
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions deployability/modules/allocation/aws/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,19 +299,23 @@ def _generate_dedicated_host(config: AWSConfig, arch: str) -> str:
client = boto3.client('ec2')
dedicated_host_name = str(config.name) + '-Host-' + arch
logger.info(f"Creating dedicated host: {dedicated_host_name}")
host = client.allocate_hosts(InstanceType=config.type,
AutoPlacement='on',
AvailabilityZone=config.zone,
Quantity=1,
TagSpecifications=[{
'ResourceType': 'dedicated-host',
'Tags': [
{'Key': 'Name', 'Value': dedicated_host_name},
{'Key': 'termination_date', 'Value': config.termination_date},
{'Key': 'issue', 'Value': config.issue},
{'Key': 'team', 'Value': config.team}
]
}])
params = {
'InstanceType': config.type,
'AutoPlacement': 'on',
'AvailabilityZone': config.zone,
'Quantity': 1,
'TagSpecifications': [{
'ResourceType': 'dedicated-host',
'Tags': [
{'Key': 'Name', 'Value': config.name},
{'Key': 'termination_date', 'Value': config.termination_date},
{'Key': 'team', 'Value': config.team}
]
}]
}
if config.issue:
params['TagSpecifications'][0]['Tags'].append({'Key': 'issue', 'Value': config.issue})
host = client.allocate_hosts(**params)
logger.info(f"Dedicated host created: {host['HostIds'][0]}")
return host['HostIds'][0]

Expand All @@ -332,7 +336,7 @@ def _release_dedicated_host(host_identifier: str) -> str:
if host['Unsuccessful']:
unsuccessful_messages = [item['Error']['Message'] for item in host['Unsuccessful']]
for message in unsuccessful_messages:
logger.info(f"{message}")
logger.warning(f"{message}")
else:
logger.info(f"Dedicated host released: {host_identifier}")

Expand Down

0 comments on commit 8e24f34

Please sign in to comment.