-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
aws_spot_instance_request tags won't apply to instance #3263
Comments
I just ran in to this issue as well. |
Definitely an issue, also in 0.6.8. Need a way to apply those tags to the new instance, or allow for an aws_instance_tag resource that will allow arbitrary tags to be set on ec2 instances. |
Agreed! |
Present in 0.6.8 as well |
There is no AWS API that will do this via the Spot Instance request itself. We would need to trap the |
This is the expected behavior as per AWS documentation, unfortunately. I did find a solution. I created an IAM role with a policy that grants CreateTag permissions. I added an instance_profile to the role, and a ruleset allowing it to be assigned to the instances. Using cloud init, I have a script that looks up the instances metadata, and using the result, tags itself based on arguments passed to the script. There are a few moving parts, unfortunately. It helps if you're already familiar with cloud-init. |
Another option: Use autoscaling groups. Tags applied to the launch_configuration will be passed on to the resulting spot instance. |
This issue seems to be open for a year now. Any luck with the fix. |
Until there is explicit support, we are getting by with the following user-data snippet to clone the spot-request tags to the instance.
|
Issue still seems to be present in 0.9.4. Causing problems - will attempt the workaround solutions posted here |
Workarounds are good but not always applicable. |
Still a problem in 0.11.3. No errors, but tags seem to just be being disregarded. |
@DanielMarquard did you the workaround above: #3263 (comment) |
@drorata I haven't, but it seems like it would work. I'll have Terraform execute that command in the CI script. Thanks. |
Still an issue on 0.11.7, but the workaround posted above works well. |
Here's my workaround. I use environment variables, but your use case might not require them.
|
Hi, adopted above workaround for count >=1
|
If you also want tags applied to your volumes:
|
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
I have an
aws_spot_instance_request
like this:The tags are being applied only to the spot request itself, not to the underlying instance. Is this an expected behavior? How can I change this?
Thanks!
The text was updated successfully, but these errors were encountered: