-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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 #32
Comments
This comment was originally opened by @jmreicha as hashicorp/terraform#3263 (comment). It was migrated here as part of the provider split. The original comment is below. I just ran in to this issue as well. |
This comment was originally opened by @sean-brandt as hashicorp/terraform#3263 (comment). It was migrated here as part of the provider split. The original comment is below. 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. |
This comment was originally opened by @caarlos0 as hashicorp/terraform#3263 (comment). It was migrated here as part of the provider split. The original comment is below. Agreed! |
This comment was originally opened by @stolinzeev as hashicorp/terraform#3263 (comment). It was migrated here as part of the provider split. The original comment is below. Present in 0.6.8 as well |
This comment was originally opened by @catsby as hashicorp/terraform#3263 (comment). It was migrated here as part of the provider split. The original comment is below. There is no AWS API that will do this via the Spot Instance request itself. We would need to trap the |
This comment was originally opened by @cbarbour as hashicorp/terraform#3263 (comment). It was migrated here as part of the provider split. The original comment is below. 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. |
This comment was originally opened by @cbarbour as hashicorp/terraform#3263 (comment). It was migrated here as part of the provider split. The original comment is below. Another option: Use autoscaling groups. Tags applied to the launch_configuration will be passed on to the resulting spot instance. |
This comment was originally opened by @rehmanzile as hashicorp/terraform#3263 (comment). It was migrated here as part of the provider split. The original comment is below. This issue seems to be open for a year now. Any luck with the fix. |
This comment was originally opened by @jalkjaer as hashicorp/terraform#3263 (comment). It was migrated here as part of the provider split. The original comment is below. Until there is explicit support, we are getting by with the following user-data snippet to clone the spot-request tags to the instance.
|
This comment was originally opened by @alextbrandwatch as hashicorp/terraform#3263 (comment). It was migrated here as part of the provider split. The original comment is below. Issue still seems to be present in 0.9.4. Causing problems - will attempt the workaround solutions posted here |
This comment was originally opened by @kostyrev as hashicorp/terraform#3263 (comment). It was migrated here as part of the provider split. The original comment is below. Workarounds are good but not always applicable. |
This is a nice workaround I just implemented with local-exec
update_spotinstance_tags.sh
|
I would expect that this can be implemented via something similar to |
And I just realized that |
Are you guys planning on fixing this? |
Any news on this? Thanks |
+1 |
Please fix this. Currently implementing ugly workarounds in order to resolve this issue. |
+1 to some implementation here |
@birkoff Saved my life. I had to modify a bit to avoid file creation. Tks!
|
The new(ish) data "aws_ami" "amzn-ami-minimal-hvm-ebs" {
most_recent = true
owners = ["amazon"]
filter {
name = "name"
values = ["amzn-ami-minimal-hvm-*"]
}
filter {
name = "root-device-type"
values = ["ebs"]
}
}
data "aws_ec2_instance_type_offering" "available" {
filter {
name = "instance-type"
values = ["t3.micro", "t2.micro"]
}
preferred_instance_types = ["t3.micro", "t2.micro"]
}
resource "aws_spot_instance_request" "example" {
ami = data.aws_ami.amzn-ami-minimal-hvm-ebs.id
instance_type = data.aws_ec2_instance_type_offering.available.instance_type
spot_price = "0.05"
wait_for_fulfillment = true
}
locals {
tags = {
Environment = "Test"
Name = "Example"
}
}
resource "aws_ec2_tag" "example" {
resource_id = aws_spot_instance_request.example.spot_instance_id
for_each = local.tags
key = each.key
value = each.value
} |
Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label. If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you! |
Still relevant. |
This functionality has been released in v5.2.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
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. |
This issue was originally opened by @caarlos0 as hashicorp/terraform#3263. It was migrated here as part of the provider split. The original body of the issue is below.
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: