-
Notifications
You must be signed in to change notification settings - Fork 342
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
Cannot use launch_template name in ec2_instance module #451
Comments
Files identified in the description:
If these files are inaccurate, please update the |
maybe the implementation is not that difficult at the end. One possibility is, that they are only applied when if not module.params.get('launch_template'):
instance_type = 't2.micro' But that means that they must remove from Removing the default value in general will be the easiest fix. But that must be made in some iteration steps with deprecation warnings? |
I would love to see this implemented. IMO, the best behavior would be to apply the values in the following order:
I have 0 knowledge of boto, so I don't know how easy that is to make happen, though. |
I think its vice-versa :)
If launch template is defined
I think it's not that difficult, but a lot of time consuming (adjust and expand integration tests). |
I was thinking of the numbers from least important to most, and you were going vice versa, I think. In any case, I agree with you. I'd be interested in getting involved, but I don't know how much time I'd have to maintain stuff. Also, at my work, we're tied to ansible 2.9, unfortunately, so I wouldn't be able to use and test the thing very much. I'll definitley look into it, though, if we ever get things sorted out so that we can upgrade our ansible. |
Two issues (TL;DR)
launch_template
paremeter with otherec2_instance
parameters in the same task (e.g.instance_type
).ec2_instance
is making this even more diffcult to handleSummary
Origin Issue: ansible/ansible#51941
First trial of fix: ansible-collections/community.aws#111
Broken condition still exists: https://github.com/ansible-collections/amazon.aws/blob/main/plugins/modules/ec2_instance.py#L1165
However. It's not that easy.
Imo, LaunchTemplate parameters are not changeable in the context of
run_instance
.You must read-out the launch_template parameters and throw them aginst
run_instance
to pretend they came frommodule.params
."Failed to create new EC2 instance: An error occurred (Unsupported) when calling the RunInstances operation: The requested configuration is currently not supported. Please check the documentation for supported configurations."
One issues are the default values the modules applies.
{'BlockDeviceMappings': [], 'ClientToken': '37d405af374948e2bd427ff4a7a7fc04', 'InstanceType': 't2.micro', 'LaunchTemplate': {'LaunchTemplateName': 'ubuntu-20.04'}, 'MaxCount': 1, 'MinCount': 1, 'NetworkInterfaces': [{'DeviceIndex': 0, 'SubnetId': 'subnet-3e5fe743'}], 'TagSpecifications': [{'ResourceType': 'volume', 'Tags': [{'Key': 'Name', 'Value': 'lttest01'}]}, {'ResourceType': 'instance', 'Tags': [{'Key': 'Name', 'Value': 'lttest01'}]}]}
This happen when you run
ec2_instance
without any parameters, just with aLaunchTemplateName
.So the module applies
BlockDeviceMappings: []
InstanceType:
t2.micro`basically when I run
I expect that all values are taken from the launch_template, only the requested will be overwritten (
instance_type
andvpc_subnet_id
.)but because of the default values, when I request
what instance_type will be choosen? I expect the one that is defined in the launch_template (e.g. t3a.small). But the module will request a t2.micro instance (default value in
ec2_instance
).so one point that must be reworked are the parameters that breaks the launch_template when no extra parameters are requested.
that might be the easiert part.
the harder part is to read-out launch_template parameters and compare them to ec2_instance parameters if requested and throw everything against
run_instance
withoutLaunchTemplate
parameter.Issue Type
Bug Report
Component Name
ec2_instance
Ansible Version
Collection Versions
AWS SDK versions
Configuration
OS / Environment
Linux rocket 5.11.22-2-MANJARO #1 SMP PREEMPT Fri May 21 17:45:54 UTC 2021 x86_64 GNU/Linux
Steps to Reproduce
Expected Results
Deploy an ec2 instance with lauch_template parameters for all parameters that are not requested by
ec2_instance
module.Actual Results
Code of Conduct
The text was updated successfully, but these errors were encountered: