Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DTT1 - Iteration 3 - Allocation module - Allow subscribing to a marketplace AMI for AWS deployments #4928

Closed
Tracked by #4855
c-bordon opened this issue Feb 7, 2024 · 2 comments
Assignees

Comments

@c-bordon
Copy link
Member

c-bordon commented Feb 7, 2024

It is necessary to add the possibility of subscribing to AMIs from the marketplace, when necessary, at the moment it happened to us when trying to use the openSUSE image

cbordon@cbordon-MS-7C88:~/Documents/wazuh/repositorios/wazuh-qa/deployability$ python3 launchers/allocation.py --composite-name linux-opensuse-15-amd64 --provider aws --size large
[2024-02-07 13:15:22] [INFO] ALLOCATOR: Creating instance at /tmp/wazuh-qa
[2024-02-07 13:15:22] [DEBUG] ALLOCATOR: No config provided. Generating from payload
[2024-02-07 13:15:22] [DEBUG] ALLOCATOR: Creating base directory: /tmp/wazuh-qa/AWS-0086354B-4F45-4609-AE1F-6C298B0CF481
Traceback (most recent call last):
  File "/home/cbordon/Documents/wazuh/repositorios/wazuh-qa/deployability/launchers/allocation.py", line 30, in <module>
    main()
  File "/home/cbordon/Documents/wazuh/repositorios/wazuh-qa/deployability/launchers/allocation.py", line 26, in main
    Allocator.run(InputPayload(**vars(parse_arguments())))
  File "/home/cbordon/Documents/wazuh/repositorios/wazuh-qa/deployability/modules/allocation/allocation.py", line 31, in run
    return cls.__create(payload)
  File "/home/cbordon/Documents/wazuh/repositorios/wazuh-qa/deployability/modules/allocation/allocation.py", line 50, in __create
    instance = provider.create_instance(
  File "/home/cbordon/Documents/wazuh/repositorios/wazuh-qa/deployability/modules/allocation/generic/provider.py", line 65, in create_instance
    return cls._create_instance(base_dir, params, config)
  File "/home/cbordon/Documents/wazuh/repositorios/wazuh-qa/deployability/modules/allocation/aws/provider.py", line 57, in _create_instance
    instance_id = cls.__create_ec2_instance(config)
  File "/home/cbordon/Documents/wazuh/repositorios/wazuh-qa/deployability/modules/allocation/aws/provider.py", line 107, in __create_ec2_instance
    instance = client.create_instances(ImageId=config.ami,
  File "/home/cbordon/.local/lib/python3.10/site-packages/boto3/resources/factory.py", line 580, in do_action
    response = action(self, *args, **kwargs)
  File "/home/cbordon/.local/lib/python3.10/site-packages/boto3/resources/action.py", line 88, in __call__
    response = getattr(parent.meta.client, operation_name)(*args, **params)
  File "/home/cbordon/.local/lib/python3.10/site-packages/botocore/client.py", line 535, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/home/cbordon/.local/lib/python3.10/site-packages/botocore/client.py", line 983, in _make_api_call
    raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (OptInRequired) when calling the RunInstances operation: In order to use this AWS Marketplace product you need to accept terms and subscribe. To do so please visit https://aws.amazon.com/marketplace/pp?sku=147aomaaws9zx4er41jp3mozy
@c-bordon
Copy link
Member Author

c-bordon commented Mar 21, 2024

Update report

This is not a fix that must be done by code, it is necessary to enter the URL indicated by the module itself and subscribe to the AMI in the account in question to then be able to use the AMI

Screenshot_20240321_165004

cbordon@cbordon-MS-7C88:~/Documents/wazuh/repositorios/wazuh-qa$ python3 deployability/modules/allocation/main.py --provider aws --size micro --label-team devops --label-termination-date "1d" --ssh-key ~/.ssh/allocation_test --composite-name linux-redhat-7-amd64
[2024-03-21 16:52:50] [INFO] ALLOCATOR: Creating instance at /tmp/wazuh-qa
[2024-03-21 16:52:50] [DEBUG] ALLOCATOR: No config provided. Generating from payload
[2024-03-21 16:52:50] [DEBUG] ALLOCATOR: Using provided key pair
[2024-03-21 16:52:51] [DEBUG] ALLOCATOR: Creating temp directory: /tmp/wazuh-qa/AWS-D9099269-DB79-4DC8-9E79-1BD5414B3E16
[2024-03-21 16:53:09] [DEBUG] ALLOCATOR: Renaming temp /tmp/wazuh-qa/AWS-D9099269-DB79-4DC8-9E79-1BD5414B3E16 directory to /tmp/wazuh-qa/i-0ecd292891df022c0
[2024-03-21 16:53:09] [INFO] ALLOCATOR: Instance i-0ecd292891df022c0 created.
[2024-03-21 16:53:10] [INFO] ALLOCATOR: Instance i-0ecd292891df022c0 started.
[2024-03-21 16:53:11] [INFO] ALLOCATOR: Inventory file generated at /tmp/wazuh-qa/i-0ecd292891df022c0/inventory.yml
[2024-03-21 16:53:11] [INFO] ALLOCATOR: Track file generated at /tmp/wazuh-qa/i-0ecd292891df022c0/track.yml

@c-bordon
Copy link
Member Author

All AMIs are reviewed and the necessary ones are subscribed, no changes were necessary at the code level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

2 participants