ansible-community / ansible-community/molecule-plugins

Unable to create ec2 instance with default create template with error `The filter '<' is invalid`

Open
#40 1 comment 0 reactions 0 assignees View on GitHub
ec2
Dominant language
Python
Stars
164
Forks
113
Avg merge
4d 20h
Merged PRs (30d)
1

Description

Hello,

I tried to create a new scenario with `molecule init scenario -d ec2`, and then running `molecule create`:

```
PLAY [Create] **********************************************************************************************************

TASK [Validate platform configurations] ********************************************************************************
ok: [localhost] => (item=instance)

TASK [Write run config to file] ****************************************************************************************
ok: [localhost]

TASK [Generate local key pairs] ****************************************************************************************
ok: [localhost] => (item=instance)

TASK [Look up EC2 AMI(s) by owner and name (if image not set)] *********************************************************
skipping: [localhost] => (item=instance)

TASK [Look up subnets to determine VPCs (if needed)] *******************************************************************
ok: [localhost] => (item=instance)

TASK [Validate discovered information] *********************************************************************************
ok: [localhost] => (item=instance)

TASK [Create ephemeral EC2 keys (if needed)] ***************************************************************************
skipping: [localhost] => (item=instance)

TASK [Create ephemeral security groups (if needed)] ********************************************************************
ok: [localhost] => (item=instance)

TASK [Create ephemeral EC2 instance(s)] ********************************************************************************
changed: [localhost] => (item=instance)

TASK [Wait for instance creation to complete] **************************************************************************
FAILED - RETRYING: Wait for instance creation to complete (300 retries left).
```

I always get an AWS client exception (truncate output for readability):

```
return self._method(**current_kwargs)", " File \"/Users/Giovanni.Toraldo/.pyenv/versions/3.9.0/lib/python3.9/site-packages/botocore/client.py\", line 391, in _api_call", " return self._make_api_call(operation_name, kwargs)", " File \"/Users/Giovanni.Toraldo/.pyenv/versions/3.9.0/lib/python3.9/site-packages/botocore/client.py\", line 719, in _make_api_call", " raise error_class(parsed_response, operation_name)", "botocore.exceptions.ClientError: An error occurred (InvalidParameterValue) when calling the DescribeInstances operation: The filter '<' is invalid"]}
```

Relevant dependencies:
```
ansible==2.9.21
molecule==3.5.2
molecule-docker==1.1.0
molecule-ec2==0.4
boto3==1.20.46
botocore==1.23.46
```

Workaround is to remove the `filters` attribute in the `ec2_instance` resource in the `Create ephemeral EC2 instance(s)` step in `create.yml`:

```
- name: Create ephemeral EC2 instance(s)
ec2_instance:
profile: "{{ item.aws_profile | default(omit) }}"
region: "{{ item.region | default(omit) }}"
#filters: "{{ platform_filters }}"
instance_type: "{{ item.instance_type }}"
image_id: "{{ platform_image_id }}"
vpc_subnet_id: "{{ item.vpc_subnet_id }}"
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the default `molecule init scenario -d ec2` flow, then inspect `create.yml` and the `ec2_instance` task in the `Create ephemeral EC2 instance(s)` step. Trace how `platform_filters` is passed to the AWS call and verify that the default `molecule create` completes without the invalid `<` filter error.

Written by the indexing model from the issue text.

Assessment

Tech stack
ansible, aws, python
Domain
cloud
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.