Skip to content

Commit

Permalink
Merge pull request #5625 from wazuh/bug/5617-the-allocator-module-fai…
Browse files Browse the repository at this point in the history
…ls-to-allocate-instances-in-aws-due-to-volume-size

Fixed custom storage for AMIs
  • Loading branch information
juliamagan authored Jul 31, 2024
2 parents 545730d + d126e5a commit d7091ab
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions deployability/modules/allocation/aws/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,15 @@ def __create_ec2_instance(config: AWSConfig) -> str:
# Describe the AMI to get the root device name
ami = client.describe_images(ImageIds=[config.ami])
root_device_name = ami['Images'][0]['RootDeviceName']
ami_storage = ami['Images'][0]['BlockDeviceMappings'][0]['Ebs']['VolumeSize']

if ami_storage > config.storage:
config.storage = ami_storage

if config.platform == 'windows':
with open(windosUserData_file, 'r') as file:
userData = file.read()
userData = userData.replace('ChangeMe', config.key_name)
config.storage = 60
else:
with open(userData_file, 'r') as file:
userData = file.read()
Expand Down Expand Up @@ -279,12 +282,11 @@ def __parse_config(cls, params: CreationPayload, credentials: AWSCredentials, is
# Parse the configuration.
if platform == 'macos':
os_specs['zone'] = os_specs['zone'] + 'c'
config['storage'] = 0
if arch == 'arm64':
config['type'] = 'mac2.metal'
config['storage'] = 100
if arch == 'amd64':
config['type'] = 'mac1.metal'
config['storage'] = 100
else:
for spec in size_specs:
if fnmatch.fnmatch(arch, spec):
Expand Down

0 comments on commit d7091ab

Please sign in to comment.