spotinst / terraform-provider-spotinst Goto Github PK
View Code? Open in Web Editor NEWTerraform Spotinst provider.
Home Page: https://registry.terraform.io/providers/spotinst/spotinst/latest/docs
License: Mozilla Public License 2.0
Terraform Spotinst provider.
Home Page: https://registry.terraform.io/providers/spotinst/spotinst/latest/docs
License: Mozilla Public License 2.0
Hi guys, I've faced issue when I'm trying to use template_cloudinit_config
resource with gzip or base64 enabled. Spotinst is always trying to update userdata of elastic_group which is not what I expect.
Apparently after I apply gziped/base64 userdata first time second time when I update state spotinst is responding with ungziped/unbase64 data (which makes sense for users, but not for terraform). So terraform sees userdata doesn't match and tries to update it again.
Let me know if you need some additional info.
0.11.10
spotinst_elastigroup_aws
data "template_cloudinit_config" "infra-config" {
gzip = true
base64_encode = true
part {
content_type = "text/cloud-config"
content = "teststring"
}
}
resource "spotinst_elastigroup_aws" "infra" {
name = "Infra group"
description = "created by Terraform"
product = "Linux/UNIX"
user_data = "${data.template_cloudinit_config.infra-config.rendered}"
...
}
I expect that when I do not update cloud-init template provider doesn't try to update userdata
Provider updates userdata every time I use gzip = true
or base64_encode = true
.
headroom
block currently support setting up is_auto_config
but doesn't allow configuring the headroom percentage.
The parameter autoHeadroomPercentage
let you define that percentage but it is not yet supported by the provider.
Kindly provide this feature to set it configurable.
Hello!
In my organization, we have been successfully using spotinst with terraform 0.11. Recently we started 0.12 upgrade and I just stumbled upon a problem with spotinst provider and terraform 0.12 - terraform can not find provider version compatible with 0.12
$ terraform -version
Terraform v0.12.5
The only resource we're using is:
https://gist.github.com/paranoidd/0ae2e4a1cf672bc0e5c708b85c00968c
Partially censored: https://gist.github.com/paranoidd/6be91e7191faf59e1870b0342d3e671c
Terraform should download spotinst provider and allow me to plan with 0.12
Terraform fails to download provider:
Error: no available version is compatible with this version of Terraform
terraform init
Fails on macos installed via brew
Fails on linux with official terraform binary
No provider version restrictions/selectors in place
According to the issue: hashicorp/terraform#21235 your provider is compatible with 0.12, yet no luck for me :(
Terraform v0.10.7 (bug present in 0.9.X versions also)
No custom config
Plan: https://gist.github.com/k3ypad/3661f9522724bffbb0acc3a42a9996f0
Apply: https://gist.github.com/k3ypad/f016f5f4df01f32ba94caf63ccb90db6
No panic.
When this is specified:
# Scale down on weeknights
scheduled_task {
task_type = "scale"
cron_expression = "00 20 * * 1-5"
scale_target_capacity = 0
scale_min_capacity = 0
scale_max_capacity = 0
}
The elastigroup should have no instances at the specified time.
In the spotinst console the values for this scheduled action are blank. This also causes a input validation error in the console when you go to edit, despite Terraform planning and applying fine.
terraform plan
terraform apply
We using terraform to create spotinst groups, while destroying, spotinst doesn't remove spotinst AMIs, volumes, network interfaces and snapshots.
Hello!
When defining custom_attributes
for ECS integration, every subsequent terraform plan still shows that said attributes have to be added, while they do exist in elastigroup configuration already.
Terraform v0.12.26
https://gist.github.com/paranoidd/8f45de6b777f235251ddb9c747f0ceb0
https://gist.github.com/paranoidd/e86a84b64cd3b8bfc1ece1610336f14e
Terraform plan not displaying changes in custom attributes for ECS integration when there aren't any
Despite successful creation of custom attributes for ECS integration, any subsequent plans still show changes
terraform plan
terraform apply
terraform plan
This issue was originally opened by @spa-87 as hashicorp/terraform#15014. It was migrated here as part of the provider split. The original body of the issue is below.
0.9.5
variable "env" {}
variable "chef_bootstrap_sns_arn" {}
variable "spotinst_email" {}
variable "spotinst_token" {}
variable "spotinst_elastigroup_name" {}
variable "spotinst_capacity_min" {}
variable "spotinst_capacity_max" {}
variable "spotinst_capacity_target" {}
variable "spotinst_ondemand_count" {}
variable "spotinst_availability_vs_costs" { default = "balanced" }
variable "spotinst_draining_timeout" { default = "60" }
variable "spotinst_grace_period" { default = "60" }
variable "aws_elbs" { default = [], type = "list" }
variable "aws_iam_role" {}
variable "aws_instance_type" {}
variable "aws_region_id" {}
variable "aws_region_name" {}
variable "aws_security_groups" { type = "list" }
variable "aws_spot_product" {}
variable "aws_ssh_key" {}
variable "aws_availability_zones" { type = "list" }
variable queues { type="list", default = ["test", "test2", "test3"] }
data "template_file" "dimensions_keys" {
count = "${length(var.queues)}"
template = "QueueName${count.index}"
}
provider "spotinst" {
email = "${var.spotinst_email}"
token = "${var.spotinst_token}"
}
resource "spotinst_aws_group" "spotinst_elastigroup" {
name = "${var.spotinst_elastigroup_name}"
description = "${var.spotinst_elastigroup_name}"
availability_zones = [ "${var.aws_availability_zones}" ]
product = "${var.aws_spot_product}"
capacity {
minimum = "${var.spotinst_capacity_min}"
maximum = "${var.spotinst_capacity_max}"
target = "${var.spotinst_capacity_target}"
}
ebs_block_device {
delete_on_termination = true
device_name = "/dev/sda1"
volume_type = "gp2"
volume_size = 15
}
instance_types {
ondemand = "${var.aws_instance_type}"
spot = "${var.od2spot["${var.aws_instance_type}"]}"
}
launch_specification {
health_check_type = "EC2"
health_check_grace_period = "${var.spotinst_grace_period}"
iam_instance_profile = "${var.aws_iam_role}"
image_id = "${var.region2ami["${var.aws_region_id}"]}"
key_pair = "${var.aws_ssh_key}"
load_balancer_names = [ "${var.aws_elbs}" ]
monitoring = false
security_group_ids = [ "${var.aws_security_groups}" ]
}
strategy {
availability_vs_cost = "${var.spotinst_availability_vs_costs}"
draining_timeout = "${var.spotinst_draining_timeout}"
ondemand_count = "${var.spotinst_ondemand_count}"
}
tags {
Name = "${var.spotinst_elastigroup_name}-default"
}
scaling_up_policy {
policy_name = "test"
metric_name = "ApproximateNumberOfMessagesVisible",
statistic = "average"
unit = "count"
threshold = 10
adjustment = 2
namespace = "AWS/SQS"
operator = "gte"
evaluation_periods = 2
period = 300
cooldown = 300
dimensions = "${zipmap(data.template_file.dimensions_keys.*.rendered, var.queues)}"
}
}
resource "spotinst_subscription" "chef_bootstrap" {
resource_id = "${spotinst_aws_group.spotinst_elastigroup.id}"
event_type = "AWS_EC2_INSTANCE_LAUNCH"
protocol = "aws-sns"
endpoint = "${var.chef_bootstrap_sns_arn}"
format {
event = "%event%"
instanceId = "%instance-id%"
resourceId = "%resource-id%"
resourceName = "%resource-name%"
}
}
https://gist.github.com/spa-87/5fdfe168268137eead14089ea1917778
Spotinst elastigroup should be created normally with one scaling policy based on provided set of dimensions (specified at queues
list).
Panic Output
section.Please list the steps required to reproduce the issue, for example:
terraform apply
Terraform v0.12.13
All resources related to the spotinst provider.
Refer to this gist.
Spotinst provider should work using a ~/.spotinst/credentials
file such as:
default:
token: "<token>"
account: "<account>"
I'm unable to deploy any spotinst related resources using a plain credentials
file. Hardcoding my credentials works just fine:
provider "spotinst" {
token = "<token>"
account = "<key>"
}
Setting environment variables (SPOTINST_TOKEN and SPOTINST_ACCOUNT) also makes the spotinst provider behave correctly
Currently running terraform
on Windows Powershell.
This resource: spotinst_ocean_gke_launch_spec_import reports during the plan phase for a non-interrupting change
~ resource "spotinst_ocean_gke_launch_spec_import" "dynamic_pods" {
id = "ols-*****"
~ node_pool_name = "terraform-20200625134819133100000002" -> (known after apply)
ocean_id = "o-*****"
}
but during the apply phase, it throws an immutable error. This means that the terraform provider is not correctly indicating that a delete and re-create is required.
Trying to create Multai HTTPS listener as follows:
resource "spotinst_multai_listener" "ext_https_listener" {
balancer_id = "${spotinst_multai_balancer.external_app_mlb.id}"
protocol = "https"
port = 443
}
Get error:
Error: Error applying plan:
1 error(s) occurred:
* module.ext_mlb.spotinst_multai_listener.ext_https_listener: 1 error(s) occurred:
* spotinst_multai_listener.ext_https_listener: [ERROR] failed to create listener: POST https://api.spotinst.io/loadBalancer/listener?accountId=act-6b7ccf67: 500 (request: "36a1606b-fe73-41ba-928b-91811a30c0a1") GENERAL_ERROR: Please contact your account manager.
I've got a hunch this is since there is no certificate specified.
However in multai_listener
documentation cannot see option for attaching certificate.
Can you add/fix ?
Terraform v0.11.13
Created resource spotinst_multai_listener
spotinst_multai_listener not created
terraform apply
Hi there,
Thank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests. For general usage questions, please see: https://www.terraform.io/community.html.
0.12.12
Use case:
I would like to dynamically create or import spotinst_organization resources and attach spotinst_account resources with Terraform.
Example config:
provider "aws" {
version = "2.32.0"
region = "us-west-2"
alias = "global"
}
provider "spotinst" {
token = var.spotinst_token
key = var.spotinst_key
}
data "aws_organizations_organization" "my_org" {}
data "spotinst_organization" "spoinst_org" {}
locals {
root_id = data.aws_organizations_organization.my_org.roots[0].id
aws_ous = [
"admin",
"sandbox",
"suspended",
"service"
]
aws_accounts = {
staging = { ou = "service", spotinst_organization = "my_org" },
prod = { ou = "service", spotinst_organization = "my_org" },
dev = { ou = "service", spotinst_organization = "my_org" },
}
}
resource "aws_organizations_organizational_unit" "ous" {
for_each = toset(local.aws_ous)
name = title(each.value)
parent_id = local.root_id
}
resource aws_organizations_account "accounts" {
for_each = local.aws_accounts
name = each.key
email = "awsroots+${each.key}@my_org.com"
parent_id = lookup(each.value, "ou", "root") == "root" ? local.root_id : aws_organizations_organizational_unit.ous[each.value["ou"]].id
role_name = "OrganizationAccountAccessRole"
# There is no AWS Organizations API for reading role_name
lifecycle {
ignore_changes = ["role_name"]
}
}
resource spotinst_account "spotinst_accounts" {
for_each = local.aws_accounts
name = each.key
aws_account_id = each.value["id"]
spotinst_organization = lookup(each.value, "spotinst_orgnization", "my_org")
}
Terraform v0.12.18
Please list the resources as a list, for example:
What should have happened?
Following the documentation https://www.terraform.io/docs/providers/spotinst/r/elastigroup_aws_beanstalk.html , beanstalk_environment_name is not required (it actually is required), description is optional (it is not a valid parameter), deployment_preferences and strategy are variables but they are block variables:
Wrong: strategy = {}
Correct: strategy {}
Lack of options from spotinst console like scheduling scaling and auto scaling options.
The compatibility between terraform and spotinst console is poor, I can't change via console the Elastigroup created by Terraform.
Please provide support for strategy.spotPercentage
in ocean_ecs resource. Curently, we're using null resource to circumvent this limitation but would be great if tf provider support it at first place
Terraform v0.12.21
+ provider.aws v2.48.0
+ provider.null v2.1.2
+ provider.spotinst v1.14.2
+ provider.template v2.1.2
the problem happens whenever I change the product
value in spotinst_elastigroup_aws
.
It complains that property is immutable, hence terraform should destroy and recreate the resource for me.
resource "spotinst_elastigroup_aws" "default-elastigroup" {
# redacted
product = "Linux/UNIX"
}
to
resource "spotinst_elastigroup_aws" "default-elastigroup" {
# redacted
product = "Linux/UNIX (Amazon VPC)"
}
Error: field [product] is immutable, cannot be changed post creation
on ../modules_tf12/ec2_spotinst/ec2_spotinst.tf line 423, in resource "spotinst_elastigroup_aws" "default-elastigroup":
423: resource "spotinst_elastigroup_aws" "default-elastigroup" {
Terraform should destroy and create the resource for me again
I receive an error
terraform apply
terraform apply
Yes, I know a workaround is to taint my resources, and I am doing exactly that.
That being said, I messed up because the documentation is also misleading:
https://www.terraform.io/docs/providers/spotinst/r/elastigroup_aws.html#product
product - (Required) Operation system type. Valid values: "Linux/UNIX", "SUSE Linux", "Windows". For EC2 Classic instances: "Linux/UNIX (Amazon VPC)", "SUSE Linux (Amazon VPC)", "Windows (Amazon VPC)".
I would write:
product - (Required) Operation system type. Valid values for EC2 Instances in Amazon VPC: "Linux/UNIX (Amazon VPC)", "SUSE Linux (Amazon VPC)", "Windows (Amazon VPC)". For the old EC2 Classic instances, use "Linux/UNIX", "SUSE Linux", "Windows".
And since I read somewhere that this setting affects your algorithm of getting the cheapest instances, which is your core business, this bug might be important.
After provisioning ocean cluster and setting up a few pods inside it. Upon destroying resources using terraform I'm always stuck at deleting the worker security groups because of dangling ENIs.
When creating health checks for MLB routing rules, it creates the checks only with the override
port.
There is no option to use traffic port
like can be done through the Spotinst Console.
Example:
$ terraform version
Terraform v0.11.14
+ provider.spotinst v1.13.3
Please list the resources as a list, for example:
resource "spotinst_multai_target_set" "my_mlb_ts" {
count = "${length(var.my_target_sets)}"
name = "my${element(var.mlb_otp_target_sets, count.index)}_mlb_ts"
balancer_id = "${var.my_mlb_id}"
deployment_id = "${var.my_deployment_id}"
protocol = "http"
port = 8080
weight = 1
health_check {
protocol = "http"
path = "/my-servlet/ws/serverinfo"
**port = 8080**
interval = 10
timeout = 5
healthy_threshold = 2
unhealthy_threshold = 3
}
}
In the health_check
block, have the option to use the MLB traffic port
Only able to create an override
port
terraform apply
This issue was originally opened by @caiounderscore as hashicorp/terraform#20107. It was migrated here as a result of the provider split. The original body of the issue is below.
Terraform v0.11.11
spotinst_elastigroup_aws
"provider" "spotinst" {
"token" = "$[var.token]"
"account" = "$[var.account]"
}
resource "spotinst_elastigroup_aws" "default-elastigroup" {
name = "default-elastigroup"
description = "created by Terraform"
product = "Linux/UNIX"
"desired_capacity" = 2
"min_size" = 2
"max_size" = 4
"capacity_unit" = "instance"
region = "us-east-1"
subnet_ids = ["$[var.subnets]"]
image_id = "${var.ami]"
# iam_instance_profile = "iam-profile"
key_name = "${var.key]"
security_groups = "[${var.sg]"
user_data = "echo hello world"
enable_monitoring = false
ebs_optimized = false
placement_tenancy = "default"
instance_types_ondemand = "t3.small"
instance_types_spot = ["t2.small", "t3.small"]
instance_types_preferred_spot = ["t3.small"]
orientation = "balanced"
fallback_to_ondemand = false
cpu_credits = "unlimited"
wait_for_capacity = 2
wait_for_capacity_timeout = 900
spotinst_elastigroup_aws.default-elastigroup: Refreshing state... (ID: sig-983162cc)
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
~ update in-place
Terraform will perform the following actions:
~ spotinst_elastigroup_aws.default-elastigroup
instance_types_ondemand: "t3.micro" => "t3.small"
Plan: 0 to add, 1 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
spotinst_elastigroup_aws.default-elastigroup: Modifying... (ID: sig-983162cc)
instance_types_ondemand: "t3.micro" => "t3.small"
Error: Error applying plan:
1 error(s) occurred:
* spotinst_elastigroup_aws.default-elastigroup: 1 error(s) occurred:
* spotinst_elastigroup_aws.default-elastigroup: unexpected EOF
Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.
panic: runtime error: invalid memory address or nil pointer dereference
2019-01-24T17:17:43.282-0200 [DEBUG] plugin.terraform-provider-spotinst_v1.6.0_x4: [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xbca76e]
2019-01-24T17:17:43.282-0200 [DEBUG] plugin.terraform-provider-spotinst_v1.6.0_x4:
2019-01-24T17:17:43.282-0200 [DEBUG] plugin.terraform-provider-spotinst_v1.6.0_x4: goroutine 106 [running]:
2019-01-24T17:17:43.282-0200 [DEBUG] plugin.terraform-provider-spotinst_v1.6.0_x4: github.com/terraform-providers/terraform-provider-spotinst/spotinst.updateGroup(0xc0002d8000, 0xc0001e4230, 0xc3d840, 0xc0003ec3c0, 0x1, 0xc0002d8000)
2019-01-24T17:17:43.282-0200 [DEBUG] plugin.terraform-provider-spotinst_v1.6.0_x4: /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-spotinst/spotinst/resource_spotinst_elastigroup_aws.go:306 +0x69e
2019-01-24T17:17:43.282-0200 [DEBUG] plugin.terraform-provider-spotinst_v1.6.0_x4: github.com/terraform-providers/terraform-provider-spotinst/spotinst.resourceSpotinstElastigroupAwsUpdate(0xc0001e4230, 0xc3d840, 0xc0003ec3c0, 0x24, 0x15f5860)
2019-01-24T17:17:43.282-0200 [DEBUG] plugin.terraform-provider-spotinst_v1.6.0_x4: /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-spotinst/spotinst/resource_spotinst_elastigroup_aws.go:254 +0x306
2019-01-24T17:17:43.282-0200 [DEBUG] plugin.terraform-provider-spotinst_v1.6.0_x4: github.com/terraform-providers/terraform-provider-spotinst/vendor/github.com/hashicorp/terraform/helper/schema.(*Resource).Apply(0xc0006bee40, 0xc00050e050, 0xc0000bc480, 0xc3d840, 0xc0003ec3c0, 0x40b801, 0xc000458b80, 0x4c046c)
2019-01-24T17:17:43.282-0200 [DEBUG] plugin.terraform-provider-spotinst_v1.6.0_x4: /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-spotinst/vendor/github.com/hashicorp/terraform/helper/schema/resource.go:199 +0x257
2019-01-24T17:17:43.282-0200 [DEBUG] plugin.terraform-provider-spotinst_v1.6.0_x4: github.com/terraform-providers/terraform-provider-spotinst/vendor/github.com/hashicorp/terraform/helper/schema.(*Provider).Apply(0xc000330770, 0xc00050e000, 0xc00050e050, 0xc0000bc480, 0xc000368e00, 0x18, 0x7f6c5c8996c0)
2019-01-24T17:17:43.282-0200 [DEBUG] plugin.terraform-provider-spotinst_v1.6.0_x4: /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-spotinst/vendor/github.com/hashicorp/terraform/helper/schema/provider.go:259 +0x9c
2019-01-24T17:17:43.283-0200 [DEBUG] plugin.terraform-provider-spotinst_v1.6.0_x4: github.com/terraform-providers/terraform-provider-spotinst/vendor/github.com/hashicorp/terraform/plugin.(*ResourceProviderServer).Apply(0xc0003c0160, 0xc0000bc020, 0xc000490370, 0x0, 0x0)
2019-01-24T17:17:43.283-0200 [DEBUG] plugin.terraform-provider-spotinst_v1.6.0_x4: /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-spotinst/vendor/github.com/hashicorp/terraform/plugin/resource_provider.go:488 +0x57
2019-01-24T17:17:43.283-0200 [DEBUG] plugin.terraform-provider-spotinst_v1.6.0_x4: reflect.Value.call(0xc000076720, 0xc000300000, 0x13, 0xde9674, 0x4, 0xc000458f18, 0x3, 0x3, 0xc000191740, 0x4131b7, ...)
2019-01-24T17:17:43.283-0200 [DEBUG] plugin.terraform-provider-spotinst_v1.6.0_x4: /opt/goenv/versions/1.11.4/src/reflect/value.go:447 +0x454
2019-01-24T17:17:43.283-0200 [DEBUG] plugin.terraform-provider-spotinst_v1.6.0_x4: reflect.Value.Call(0xc000076720, 0xc000300000, 0x13, 0xc0002d0f18, 0x3, 0x3, 0x12a05f200, 0xc0002d0f10, 0xc0002d0fb8)
2019-01-24T17:17:43.283-0200 [DEBUG] plugin.terraform-provider-spotinst_v1.6.0_x4: /opt/goenv/versions/1.11.4/src/reflect/value.go:308 +0xa4
2019-01-24T17:17:43.283-0200 [DEBUG] plugin.terraform-provider-spotinst_v1.6.0_x4: net/rpc.(*service).call(0xc0003ea000, 0xc0005f21e0, 0xc00057a050, 0xc00057a060, 0xc0002d8880, 0xc00057c5a0, 0xc40980, 0xc0000bc020, 0x16, 0xc409c0, ...)
2019-01-24T17:17:43.283-0200 [DEBUG] plugin.terraform-provider-spotinst_v1.6.0_x4: /opt/goenv/versions/1.11.4/src/net/rpc/server.go:384 +0x14e
2019-01-24T17:17:43.283-0200 [DEBUG] plugin.terraform-provider-spotinst_v1.6.0_x4: created by net/rpc.(*Server).ServeCodec
2019-01-24T17:17:43.283-0200 [DEBUG] plugin.terraform-provider-spotinst_v1.6.0_x4: /opt/goenv/versions/1.11.4/src/net/rpc/server.go:481 +0x47e
2019-01-24T17:17:43.285-0200 [DEBUG] plugin: plugin process exited: path=/home/caio/projects/spotinst-elastigroup-module/.terraform/plugins/linux_amd64/terraform-provider-spotinst_v1.6.0_x4
2019/01/24 17:17:43 [TRACE] root: eval: *terraform.EvalWriteState
2019/01/24 17:17:43 [TRACE] root: eval: *terraform.EvalApplyProvisioners
2019/01/24 17:17:43 [TRACE] root: eval: *terraform.EvalIf
2019/01/24 17:17:43 [TRACE] root: eval: *terraform.EvalWriteState
2019/01/24 17:17:43 [TRACE] root: eval: *terraform.EvalWriteDiff
2019/01/24 17:17:43 [TRACE] root: eval: *terraform.EvalApplyPost
2019/01/24 17:17:43 [ERROR] root: eval: *terraform.EvalApplyPost, err: 1 error(s) occurred:
* spotinst_elastigroup_aws.default-elastigroup: unexpected EOF
2019/01/24 17:17:43 [ERROR] root: eval: *terraform.EvalSequence, err: 1 error(s) occurred:
* spotinst_elastigroup_aws.default-elastigroup: unexpected EOF
2019/01/24 17:17:43 [TRACE] [walkApply] Exiting eval tree: spotinst_elastigroup_aws.default-elastigroup
2019/01/24 17:17:43 [TRACE] dag/walk: upstream errored, not walking "provider.spotinst (close)"
2019/01/24 17:17:43 [TRACE] dag/walk: upstream errored, not walking "meta.count-boundary (count boundary fixup)"
2019/01/24 17:17:43 [TRACE] dag/walk: upstream errored, not walking "root"
2019/01/24 17:17:43 [TRACE] Preserving existing state lineage "5d9f79d6-de40-6585-03da-7e273f4eb8dc"
2019/01/24 17:17:43 [TRACE] Preserving existing state lineage "5d9f79d6-de40-6585-03da-7e273f4eb8dc"
2019/01/24 17:17:43 [TRACE] Preserving existing state lineage "5d9f79d6-de40-6585-03da-7e273f4eb8dc"
2019/01/24 17:17:43 [TRACE] Preserving existing state lineage "5d9f79d6-de40-6585-03da-7e273f4eb8dc"
2019/01/24 17:17:43 [DEBUG] plugin: waiting for all plugin processes to complete...
2019-01-24T17:17:43.303-0200 [WARN ] plugin: error closing client during Kill: err="connection is shut down"
!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!
Terraform crashed! This is always indicative of a bug within Terraform.
A crash log has been placed at "crash.log" relative to your current
working directory. It would be immensely helpful if you could please
report the crash with Terraform[1] so that we can fix this.
When reporting bugs, please include your terraform version. That
information is available on the first line of crash.log. You can also
get it by running 'terraform --version' on the command line.
[1]: https://github.com/hashicorp/terraform/issues
!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!-->
Create elastigroup and update new changes.
Creates elastigroup normally but, when i run terraform apply any change in resource, terraform will crash
Please list the full steps required to reproduce the issue, for example:
terraform init
terraform apply
terraform apply
When creating spotinst_subscription
resource it's failing with error message:
CANT_CREATE_SUBSCRIPTION: Resource 'sig-XXXX' doesn't exist
However when searching for this Elastigroup sig in the console I can see it exists.
$ terraform version
Terraform v0.11.14
+ provider.azurerm v1.27.1
+ provider.spotinst v1.13.3
spotinst_subscription
resource "spotinst_subscription" "subscription" {
resource_id = "${var.elastigroup_id}"
event_type = "AZURE_VM_TERMINATE"
protocol = "web"
endpoint = "https://${var.endpoint}"
format = {
event = "%event%"
instance_id = "%instance-id%"
}
}
Create the spotinst_notification resource
Failed with error message of non-existent Elastigroup although elastigroup with this ID exists
terraform apply
Most resources for Terraform describe how you would run a terraform import
to import an existing object into the state. None of the spotinst resources have that in their documentation.
Hi,
We're currently running into issues when running tflint and tfsec against our config when using this provider.
tflint: The argument "tags" was already set at :51,3-7. Each argument may be set only once.
tfsec: Attribute redefined; The argument "tags" was already set at
Our current config looks a little like this:
tags = {
key = "Key1"
value = "Value1"
}
tags = {
key = "Key2"
value = "Value2"
}
tags = {
key = "Key3"
value = "Value3"
}
It would be great to be able to do something like this:
tags = [
{
key = "Name"
value = "${var.customer}-${var.envname}-eks-spotinst-green"
},
{
key = "k8s.io/cluster-autoscaler/enabled"
value = "true"
},
{
key = "kubernetes.io/cluster/${var.customer}-${var.envname}"
value = "owned"
}
]
This would mean "tags" are only defined once and would prevent tools like tflint and tfsec from throwing errors.
Thanks!
Hi there, we have encountered an issues since using v1.8.0 of this provider. When we run the script everything will progress as usual until roughly 5 minutes in when we are presented with the following error:
This issue has only developed since v1.8.0 has been released. If we roll back the provider to v1.7.0 and run the same script everything will work correctly as it was doing before the update.
Also an unrelated note is the documentation correct on elastigroups as it seems there is a duplicated version of the wait_for_roll_percentage or am I just not understanding it correctly
update_policy = {
should_resume_stateful = false
should_roll = false
auto_apply_tags = false
wait_for_pct_complete = 10
wait_for_pct_timeout = 1500
roll_config = {
batch_size_percentage = 33
health_check_type = "ELB"
grace_period = 300
wait_for_roll_percentage = 10
wait_for_roll_timeout = 1500
}
}
Any help would be appreciated with this.
Terraform Version
Terraform v0.11.8
Affected Resource(s)
Terraform Configuration Files
resource "spotinst_elastigroup_aws" "corporate" {
name = "${var.octopus_project_safe}-${var.octopus_environment} - ${var.version}"
description = "created by Terraform"
product = "Windows"
subnet_ids = ["${var.aws_subnet1}", "${var.aws_subnet2}", "${var.aws_subnet3}"]
max_size = "${var.asg_max_instances}"
min_size = "${var.asg_min_instances}"
desired_capacity = "${var.asg_desired_capacity}"
capacity_unit = "instance"
region = "${var.region}"
image_id = "${var.aws_ami}"
iam_instance_profile = "webserver"
key_name = "cloudit"
security_groups = ["${var.aws_securitygroups}"]
user_data = "${file("StartService.ps1")}"
enable_monitoring = false
ebs_optimized = false
instance_types_ondemand = "${var.aws_instance_type}"
instance_types_spot = ["${var.spotinst_instance_types}"]
instance_types_preferred_spot = ["${var.aws_instance_type}"]
orientation = "costOriented"
fallback_to_ondemand = true
spot_percentage = 100
wait_for_capacity = "${var.asg_min_instances}"
wait_for_capacity_timeout = 900
scheduled_task = [
{
task_type = "scale"
cron_expression = "${var.asg_recurrence_night}"
scale_target_capacity = "${var.asg_desired_capacity_night}"
scale_min_capacity = "${var.asg_min_instances_night}"
scale_max_capacity = "${var.asg_max_instances_night}"
is_enabled = true
},
{
task_type = "scale"
cron_expression = "${var.asg_recurrence_day}"
scale_target_capacity = "${var.asg_min_instances}"
scale_min_capacity = "${var.asg_min_instances}"
scale_max_capacity = "${var.asg_max_instances}"
is_enabled = true
},
]
scaling_up_policy = {
policy_name = "corporate-CPU-scaling-up"
metric_name = "CPUUtilization"
statistic = "average"
unit = "percent"
threshold = 75
action_type = "adjustment"
adjustment = "1"
namespace = "AWS/EC2"
dimensions = {
name = "AutoScalingGroupName"
value = "${var.octopus_project_safe}-${var.octopus_environment}-Up"
}
period = 300
evaluation_periods = 2
cooldown = 300
operator = "gte"
}
scaling_down_policy = {
policy_name = "corporate-CPU-scaling-down"
metric_name = "CPUUtilization"
statistic = "average"
unit = "percent"
threshold = 35
action_type = "adjustment"
adjustment = "1"
namespace = "AWS/EC2"
dimensions = {
name = "AutoScalingGroupName"
value = "${var.octopus_project_safe}-${var.octopus_environment}-Down"
}
period = 300
evaluation_periods = 2
cooldown = 300
operator = "lte"
}
health_check_grace_period = "${var.asg_health_check_grace_period}"
health_check_type = "TARGET_GROUP"
target_group_arns = ["${aws_alb_target_group.corporate.arn}"]
update_policy = {
should_resume_stateful = false
should_roll = true
roll_config = {
batch_size_percentage = 100
health_check_type = "TARGET_GROUP"
grace_period = 900
wait_for_roll_percentage = 100
wait_for_roll_timeout = 900
}
}
tags = [
{
key = "Name"
value = "${var.octopus_project_safe}-${var.octopus_environment}-${var.version}"
},
{
key = "OctopusProject"
value = "${var.octopus_project}"
},
{
key = "OctopusEnvironment"
value = "${var.octopus_environment}"
},
]
lifecycle {
ignore_changes = [
"desired_capacity",
]
}
}
Panic Output
2019-03-04T13:18:41.603Z [DEBUG] plugin.terraform-provider-spotinst_v1.8.0_x4.exe: ===> waiting for at least 100% of batches to complete, currently 0% <===
2019-03-04T13:18:41.603Z [DEBUG] plugin.terraform-provider-spotinst_v1.8.0_x4.exe: [TRACE] Waiting 10s before next try
2019-03-04T13:18:41.649Z [DEBUG] plugin.terraform-provider-spotinst_v1.8.0_x4.exe: [ERROR] WaitForState exceeded refresh grace period
2019-03-04T13:18:41.649Z [DEBUG] plugin.terraform-provider-spotinst_v1.8.0_x4.exe: [ERROR] Group [sig-ccc57383] roll failed, error: timeout while waiting for state to become 'success' (timeout: 5m0s)
2019/03/04 13:18:41 [TRACE] root: eval: *terraform.EvalWriteState
2019/03/04 13:18:41 [TRACE] root: eval: *terraform.EvalApplyProvisioners
2019/03/04 13:18:41 [TRACE] root: eval: *terraform.EvalIf
2019/03/04 13:18:41 [TRACE] root: eval: *terraform.EvalWriteState
2019/03/04 13:18:41 [TRACE] root: eval: *terraform.EvalWriteDiff
2019/03/04 13:18:41 [TRACE] root: eval: *terraform.EvalApplyPost
2019/03/04 13:18:41 [ERROR] root: eval: *terraform.EvalApplyPost, err: 1 error(s) occurred:
* spotinst_elastigroup_aws.corporate: timeout while waiting for state to become 'success' (timeout: 5m0s)
2019/03/04 13:18:41 [ERROR] root: eval: *terraform.EvalSequence, err: 1 error(s) occurred:
* spotinst_elastigroup_aws.corporate: timeout while waiting for state to become 'success' (timeout: 5m0s)
Expected Behavior
Executed without timeout error
Actual Behavior
Timeout error appears
Steps to Reproduce
terraform apply using v1.8.0
0.12.29
When the ocean cluster starts from desired_capacity = 0 and VNGs are spinning new nodes via ocean autoscaler, another terraform apply will not touch the capacity on the cluster itself.
When the ocean cluster starts from desired_capacity = 0 and VNGs are spinning new nodes via ocean autoscaler, another terraform apply will scale the VNGs to 0.
If the value is omitted, the default is also 0
This provider is wildly out of date, and well behind the spotinst official terraform provider.
It no longer can destroy spotinst groups created in Terraform, which causes any configuration using this provider to break horribly.
Is this being maintained anymore?
The following page doesn't show any outputs for the resource:
I suspect this is true in many places.
Hi,
the changelog has a date against it for v1.14.0 but yet it isn't available in the releases
Is this an oversight somewhere?
Paul
Terraform v0.13.5
spotinst_elastigroup_aws_beanstalk
When creating an Elasigroup for AWS Beanstalk with product = "Linux/UNIX", in Spotinst console should show product "Linux/UNIX".
Product inside Spotinst console is empty.
Create an Elastigroup for AWS Beanstalk using Spoinst terraform provider with product = "Linux/UNIX" and in Spotinst console, the Product configuration is empty
When using following image
properties in spotinst_elastigroup_azure
resource
image = {
marketplace = {
publisher = "Canonical"
offer = "UbuntuServer"
sku = "16.04-LTS"
}
}
Running terraform plan
succeeds
But terraform apply
fails
$ terraform version
Terraform v0.11.12-beta1
+ provider.spotinst v1.7.0
Reproduces with Spotinst provider version: latest V2 as well. (installed manually)
Error: Error applying plan:
1 error(s) occurred:
* spotinst_elastigroup_azure.qa_core_app: 1 error(s) occurred:
* spotinst_elastigroup_azure.qa_core_app: [ERROR] failed to create group: POST https://api.spotinst.io/compute/azure/group: 400 (request: "abdb76af-94a0-444b-86ca-b437c659789f") INVALID_MARKETPLACE_IMAGE: Invalid Marketplace Image:
Canonical:UbuntuServer:16.04-LTS with version: null
fail on terraform plan
failed on terraform apply
terraform apply
resource "spotinst_ocean_aws" "spotinst" {
tags {
key = "KubernetesCluster"
value = "eks-tagging-resources2.k8s.remitly.com"
}
}
Error: timed out waiting for the condition
It should execute without any problem
Crashing
Just use the long tag
Terraform v0.13.2
- Using previously-installed terraform-providers/spotinst v1.25.0
Please list the resources as a list, for example:
spotinst_ocean_aws
it seems the terraform documentation for Spot is out of date:
https://www.terraform.io/docs/providers/spotinst/r/ocean_aws.html
this does not mention a variable that I found when exporting a cluster from the Spot UI which is spot_percentage
Hi there,
I am unable to pass down load_balancer
from a module to spotinst_aws_group
resource.
I am getting "load_balancer.0.type": required field is not set
Please list the resources as a list, for example:
source tree:
repo
|-- elastigroup
| |-- main.tf
| `-- io.tf
`-- module.tf
module.tf
module "my_module" {
source = "./elastigroup"
load_balancer = [{
name = "${aws_lb.some_load_balancer.name}"
type = "target_group"
arn = "${aws_lb_target_group.some_target_group.arn}"
}]
# more module attributes
}
elastigroup/main.tf
resource "spotinst_aws_group" "nodes" {
# resource attributes
load_balancer = ["${var.load_balancer}"]
# more resource attributes
}
elastigroup/io.tf
variable "load_balancer" {
type = "list"
default = []
}
What should have happened?
The load balancer should have been accepted
What actually happened?
Got an error saying: "load_balancer.0.type": required field is not set
See the configuration above
It appears that after a successful creation of a spotinst_ocean_ecs
cluster with desired settings that subsequent modifications to the desired_capacity
never take effect.
spotinst_ocean_ecs
resource.desired_capacity
to 1
terraform apply
and verify successful state in Spotinstdesired_capacity
. In my case, I changed from 1
to 0
.terraform apply
.terraform apply
detects the existing capacity as 1 every time and tries to set to 0; however, it's not working.Terraform v0.12.24
+ provider.aws v2.61.0
+ provider.spotinst v1.15.0
+ provider.template v2.1.2
spotinst_ocean_ecs
2020/05/10 23:28:32 [WARN] Provider "registry.terraform.io/-/spotinst" produced an unexpected new value for
spotinst_ocean_ecs.default, but we are tolerating it because it is using the legacy plugin SDK.
The following problems may be the cause of any confusing errors from downstream operations:
- .desired_capacity: was cty.NumberIntVal(0), but now cty.NumberIntVal(1)
resource "spotinst_ocean_ecs" "default" {
name = "XXX-ocean-ecs-cluster"
cluster_name = "XXX-ecs-cluster"
region = "us-west-2"
min_size = 0
max_size = 2
desired_capacity = 1 # Initially 1, then re-run back to 0
subnet_ids = module.vpc.public_subnets
whitelist = ["t3a.nano"]
security_group_ids = [aws_security_group.ecs_instance.id]
image_id ="ami-088bb4cd2f62fc0e1"
iam_instance_profile = aws_iam_instance_profile.instance.name
associate_public_ip_address = true
monitoring = false
ebs_optimized = true
utilize_reserved_instances = false
draining_timeout = 30
}
The problem was observed numerous times during testing of only 2 fields in terraform. Specifically the desired_capacity
and whitelist
. It may also be denying other attribute changes as I also noticed the whitelist not taking effect as well.
Howdy folks,
At the moment as far as I can see in the docs, in the spotinst_elastigroup_aws
resource, the ebs_block_device
block doesn't supporting tagging.
As our EC2 running costs are quite low now (due to using spotinst ๐), a large part of our bill is spent on EBS volumes. We break this down using tags.
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html#tag-resources
It would be great to have this feature as it would mean we have feature parity (in terms of billing analysis) managing our instance fleets with spotinst as we would in AWS.
@nadavnaor
numBatch is causing issues and appears should be removed.
Example, running:
spotinst_elastigroup_aws.steven-c5-us-east-2: Modifying... [id=sig-6b0adb55]
Error: PUT https://api.spotinst.io/aws/ec2/group/sig-6b0adb55/roll?accountId=act-61e1c107: 400 (request: "26608a5e-2a1d-4aa4-9da6-f23aefed6ade") ValidationError: "batchNum" must be larger than or equal to 1 (field: body:strategy.onFailure.batchNum)
Based on our deployment documentation this is not even part of the API Body: https://docs.spot.io/api/#operation/elastigroupAwsDeploy
Please review.
Terraform v0.13.5
provider.spotinst: v1.27.0
According to the provider documentation, there is no way to establish which profile to use in case of using a credentials file.
An organization with several environments, each of them in a different account. The operator has a spotinst credentials file in its filesystem:
default:
token: <redacted>
account: <redacted>
production:
token: <redacted>
account: <redacted>
It would be great to be able to establish the profile in use in the provider configuration.
Given the credentials file listed before, a provider could be configured the following way:
provider "spotinst" {
profile = "production"
}
The spotinst-sdk-go seems to already have support for profiles in credentials files.
TL;DR - When integration_nomad {}
is specified for an AWS Elastigroup, the provider doesn't properly translate autoscaler_constraints
blocks into JSON for the API request.
Terraform v0.12.21 (latest available in Chocolatey)
Provider versions:
Truncated to relevant section:
integration_nomad {
autoscale_constraints {
key = "node.class"
value = "test"
}
}
When Terraform displays the plan
output, it shows the correct projected actions for the resource:
Truncated to relevant section:
+ integration_nomad {
+ autoscale_constraints {
+ key = "${node.class}"
+ value = "test"
}
}
However, the debug output shows improper JSON being sent to the API:
Truncated to relevant section:
"thirdPartiesIntegration": {
"nomad": {
"autoScale": {
"constraints": [
{
"key": "${node.class}",
"value": ""
},
{
"key": "${${node.class}}",
"value": "test"
}
]
}
}
}
This results in a ValidationError being returned from the API:
[ERROR] failed to create group: POST https://api.spotinst.io/aws/ec2/group: 400 (request: "566d5d84-eac3-4e7d-8e6d-fa59d770594f") ValidationError: "value" is not allowed to be empty (field: body:group.thirdPartiesIntegration.nomad.autoScale.constraints.0.value)
spotinst_elastigroup_aws
resource that contains an autoscale_constraints{}
block.This seems like this may have been introduced with Terraform 12. I have access to another configuration repository which uses TF11, and this issue does not occur.
Terraform v0.14.9
spotinst_managed_instance_aws
terraform {
required_providers {
spotinst = {
source = "spotinst/spotinst"
version = "1.37.0"
}
}
backend "s3" {
bucket = "bucket-name"
key = "tf-state"
region = "ap-southeast-1"
}
}
provider "spotinst" {
# use SPOTINST_TOKEN and SPOTINST_ACCOUNT environment variables
# token = "XXXXXXXXX"
# account = "XXXXXXXXX"
}
# Create a Manged Instance
resource "spotinst_managed_instance_aws" "elasticsearch" {
name = "es-dev"
description = "elasticsearch"
product = "Linux/UNIX"
region = "ap-southeast-1"
subnet_ids = ["subnet-090b504d797eeaf7f"]
vpc_id = "vpc-0b689935850729055"
optimization_windows = ["Sat:20:00-Sat:22:00", "Sun:20:00-Sun:22:00"]
auto_healing = "true"
grace_period = "120"
unhealthy_duration = "120"
revert_to_spot {
perform_at = "timeWindow"
}
persist_private_ip = "true"
persist_block_devices = "true"
persist_root_device = "true"
block_devices_mode = "reattach"
health_check_type = "EC2"
private_ip = "172.21.2.215"
instance_types = [
"t3.medium",
"t2.medium",
"t3a.medium"
]
preferred_type = "t3a.medium"
image_id = "ami-01f7527546b557442"
security_group_ids = ["sg-0e0ca50f1363003e8"]
key_pair = "nfs-server"
cpu_credits = "standard"
tags {
key = "app"
value = "elastcisearch"
}
tags {
key = "role"
value = "server"
}
tags {
key = "environment"
value = "staging"
}
block_device_mappings {
device_name = "/dev/xvdb"
ebs {
delete_on_termination = false
volume_type = "GP3"
volume_size = 210
iops = 3000
throughput = 125
}
}
network_interface {
associate_ipv6_address = false
associate_public_ip_address = false
device_index = "0"
}
}
Block device volume size resized according to specified config
Block device volume size remains the same
terraform apply
Terraform v0.10.7
No custom config.
https://gist.github.com/k3ypad/cf1b7449207593c496179504924b409d
No panic.
On deletion of a resource outside of terraform, the terraform provider should not error on plan and plan to re-create the resource.
terraform plan
errors with a 400 error complaining that the deleted elastigroup doesn't exist.
Re
terraform plan
- it should error complaining that the group doesn't exist.Not doing anything special.
No other issues found.
This is probably a Feature Request.
In Spotinst console/API there is option to add Managed Service Identity to Azure Elastigroup.
"managedServiceIdentities": [
{
"name": "my-Managed-Identity",
"resourceGroupName": "my-Resource-Group"
}
]
However it seems to be missing from the terraform-provider-spotinst
options
Terraform v0.11.13
+ provider.azurerm v1.23.0
+ provider.spotinst v1.9.0
have option in provider for managedServiceIdentities
no such option AFAIK
$ terraform version
Terraform v0.9.7
resource "spotinst_aws_group" "workers" {
name = "workers-group"
description = "created by Terraform"
product = "Linux/UNIX"
count = "${var.use_spotinst == true ? 1 : 0}"
capacity {
target = 2
}
launch_specification {
monitoring = false
image_id = "${data.aws_ami.coreos_ami.image_id}"
key_pair = "${var.ssh_key}"
security_group_ids = ["${var.sg_ids}"]
iam_instance_profile = "${aws_iam_instance_profile.worker_profile.arn}"
user_data = "${var.user_data}"
}
tags {
Name = "${var.cluster_name}-worker"
tectonicClusterID = "${var.cluster_id}"
"kubernetes.io/cluster/${var.cluster_name}" = "owned"
}
Note the following tag from the configuration above.
"kubernetes.io/cluster/${var.cluster_name}" = "owned"
There are situations, such as spinning up a kubernetes cluster, where tag keys should be evaluated dynamically.
My suggestion is to change the resource.spotinst_aws_group.tags
schema similar to that of the AWS provider. The following example is pulled from the aws_autoscaling_groups
resource.
tags = [
{
key = "Name"
value = "${var.cluster_name}-worker"
},
{
key = "kubernetes.io/cluster/${var.cluster_name}"
value = "owned"
},
{
key = "clusterID"
value = "${var.cluster_id}"
},
]
The key in the example above is not evaluated and is created as its static value.
Hi there,
Thank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests. For general usage questions, please see: https://www.terraform.io/community.html.
0.13.4 (but this would affect any version)
Please list the resources as a list, for example:
Support requiring http tokens, support hop limits, etc.
There are currently no options for configuring IMDSV2
Terraform v0.11.10
"resource" "spotinst_elastigroup_aws" "default" {
"name" = "default"
"spot_percentage" = 100
"orientation" = "balanced"
"draining_timeout" = 120
"fallback_to_ondemand" = true
"lifetime_period" = "days"
"desired_capacity" = 2
"min_size" = 0
"max_size" = 4
"capacity_unit" = "instance"
"instance_types_ondemand" = "t2.small"
"instance_types_spot" = ["t2.small", "t3.small"]
"subnet_ids" = ["subnet-5c12345a"]
"product" = "Linux/UNIX"
"security_groups" = ["sg-12345678"]
"enable_monitoring" = false
"ebs_optimized" = false
"image_id" = "ami-0150b2ec056e3c3c1"
"key_name" = "default"
"network_interface" = {
"device_index" = 0
"associate_public_ip_address" = true
"delete_on_termination" = true
}
"user_data" = "IyEvYmluL2Jhc2gKCm1rZGlyIC9kZXYvbXF1ZXVlCm1vdW50IC10IG1xdWV1ZSBub25lIC9kZXYvbXF1ZXVlCgpkb2NrZXIgcGx1Z2luIGluc3RhbGwgLS1hbGlhcyBjbG91ZHN0b3I6YXdzIC0tZ3JhbnQtYWxsLXBlcm1pc3Npb25zIGRvY2tlcjR4L2Nsb3Vkc3RvcjoxNy4wNi4wLWNlLWF3czIgQ0xPVURfUExBVEZPUk09QVdTIEFXU19SRUdJT049ZXUtd2VzdC0xIEVGU19TVVBQT1JURUQ9MCBERUJVRz0xCnNlcnZpY2UgZG9ja2VyIHJlc3RhcnQ="
"tags" = {
"key" = "Spotinst"
"value" = "true"
}
"health_check_type" = "ECS_CLUSTER_INSTANCE"
"health_check_grace_period" = 300
"health_check_unhealthy_duration_before_replacement" = 120
"integration_ecs" = {
"cluster_name" = "default"
"autoscale_is_enabled" = true
}
"region" = "eu-west-1"
}
The Spotinst Elastigroup should be created and after that creation running terraform plan
shouldn't point out any changes needed.
The Spotinst Elastigroup is being created successfully but then when I run terraform plan
it points out that user_data has been changed.
terraform apply
terraform plan
Similar problem in the AWS provider: hashicorp/terraform-provider-aws#4954
Similar problem in the Spotinst provider: https://github.com/terraform-providers/terraform-provider-spotinst/issues/23
Pull request probably worth referencing: https://github.com/terraform-providers/terraform-provider-spotinst/pull/39
terraform -v
Terraform v0.13.5
+ provider registry.terraform.io/-/local v2.0.0
+ provider registry.terraform.io/-/spotinst v1.27.0
+ provider registry.terraform.io/hashicorp/local v2.0.0
+ provider registry.terraform.io/spotinst/spotinst v1.29.0
resource "spotinst_elastigroup_aws" "elastic_search_warm" {
name = "ElasticSearch-warm"
description = "Imported from auto scaling group: ElasticSearch-warm"
product = "Linux/UNIX"
min_size = 3
max_size = 21
desired_capacity = 19
capacity_unit = "instance"
region = "eu-west-1"
subnet_ids = [
"subnet-dae37c81",
"subnet-64affc03",
"subnet-4aba9f03",
]
image_id = "ami-0c050c28ba68b201b"
iam_instance_profile = "arn:aws:iam::927637044349:instance-profile/ecsInstanceRole"
key_name = "my-key"
security_groups = [
"sg-62548719",
"sg-69b86912",
]
user_data = data.local_file.cloud_config_elastic_search_warm.content_base64
enable_monitoring = false
ebs_optimized = true
placement_tenancy = "default"
instance_types_ondemand = "i3.large"
instance_types_spot = [
"i3.large",
"i3.xlarge",
]
instance_types_preferred_spot = [
"i3.large",
]
orientation = "balanced"
fallback_to_ondemand = true
ondemand_count = 4
utilize_reserved_instances = true
draining_timeout = 120
lifetime_period = "days"
revert_to_spot {
perform_at = "always"
}
health_check_type = "EC2"
health_check_grace_period = 300
tags {
key = "Environment"
value = "Shared"
}
tags {
key = "ESCluster"
value = "empathyops"
}
tags {
key = "Name"
value = "ElasticSearch"
}
tags {
key = "Service"
value = "ElasticSearch-warm"
}
tags {
key = "Monitoring"
value = "prometheus"
}
tags {
key = "Management"
value = "Spotinst"
}
}
Terraform executes as intended and produces a plan
Panic crash
ondemand_count: 4
terraform plan
The elastigroup was already created through the GUI with ondemand_count: 4
, which gives this json as its configuration:
...
"strategy": {
"risk": null,
"onDemandCount": 4,
"availabilityVsCost": "balanced",
"drainingTimeout": 120,
"utilizeReservedInstances": true,
"fallbackToOd": true,
"scalingStrategy": null,
"persistence": {},
"revertToSpot": {
"performAt": "always"
}
...
Changing the elastigroup configuration to e.g. spot_instances: 80
(no ondemand_count
) makes "risk": 80
in above JSON, and the terraform plan
works perfectly.
Hope this is not misleading, but I think the problem is in these lines in fields_spotinst_elastigroup_aws_strategy.go:
var value *float64 = nil
if elastigroup.Strategy != nil && elastigroup.Strategy.Risk != nil {
value = elastigroup.Strategy.Risk
}
if err := resourceData.Set(string(SpotPercentage), spotinst.Int(int(*value))); err != nil {
return fmt.Errorf(string(commons.FailureFieldReadPattern), string(SpotPercentage), err)
}
As elastigroup.Strategy.Risk
is null, value var remains nil and the cast in spotinst.Int(int(*value))
produces the panic. I think this is why changing the elastigroup configuration with a defined value for risk makes it work.
TF Version: 0.11.14
Provider Version: 1.13
variable "tags_example" {
type = "map"
value = {
tag1 = "value1",
tag2 = "value2"
}
}
data "null_data_source" "tags_example" {
count = "${length(keys(var.tags_example))}"
inputs = {
key = "${element(keys(var.tags_example), count.index)}"
value = "${element(values(var.tags_example), count.index)}"
}
}
resource "spotinst_elastigroup_aws" "elastigroup" {
... configuration ...
tags = ["${data.null_data_source.tags_example.*.outputs}"]
}
Relevent parts of the debug output are here. If more (or a full) debug is required, let me know. It will take some effort to properly redact it.
https://gist.github.com/jalavoy/540eb2ac95fb9818ab7cf19b18a12f6e
None
The provider should read the null_data_source as valid.
The provider reads the null_data_source as an empty set.
Error: module.rancher_agent_dts.module.spotinst_elastigroup.spotinst_elastigroup_aws.elastigroup: "tags.0.key": required field is not set
Error: module.rancher_agent_dts.module.spotinst_elastigroup.spotinst_elastigroup_aws.elastigroup: "tags.0.value": required field is not set
terraform apply
We use this code all over the place. It doesn't seem to be happy inside the spotinst provider.
Basically, when we define a new service, we store all of our tags in a map. All of our end resources are modularized, so when we need to make a new service, we pass the map to the module, which (if needed) transforms it into the proper format using null_data_sources. We use this for AWS ASG a ton to transform it into a similar datastructure as the spotinst provider wants. Looks something like this:
data "null_data_source" "asg-tags" {
count = "${length(var.tags)}"
inputs = {
key = "${element(keys(var.tags), count.index)}"
value = "${element(values(var.tags), count.index)}"
propagate_at_launch = "true"
}
}
The point of doing it this way is if the tag data gets bigger, we don't have to go update the modules to accept this newly sized data. The null_data_source takes care of transforming it, and passing it to the provider in the correct format.
Just to be sure things look like they should, I setup an output to dump data.null_data_source.tags.*.outputs
. It looks like this:
[
{
"key": "business",
"value": "operations"
},
{
"key": "component",
"value": ""
},
{
"key": "defined_in",
"value": "/terraform/services/rancher_dts/src"
},
{
"key": "product",
"value": "infrastructure"
}
]
This is the format the provider wants. So this should pass without an error.
It feels to me like the the provider is evaluating the data structure before it's finished computing. Since other resources (outputs, consul outputs) render and display the datastructure correctly.
This was discussed extensively with Tomer Hadassi in the spotinst slack. Feel free to reference that thread.
Terraform v0.13.5
+ provider registry.terraform.io/hashicorp/aws v3.14.1
+ provider registry.terraform.io/hashicorp/kubernetes v1.13.3
+ provider registry.terraform.io/hashicorp/local v2.0.0
+ provider registry.terraform.io/hashicorp/null v3.0.0
+ provider registry.terraform.io/hashicorp/random v3.0.0
+ provider registry.terraform.io/hashicorp/template v2.2.0
+ provider registry.terraform.io/terraform-providers/spotinst v1.27.0
regarding: https://registry.terraform.io/providers/spotinst/spotinst/latest/docs/resources/ocean_aws
the ocean_aws
resource seems iam_instance_profile
accepts either an ARN or a Name but this isn't explained in the documentation. I found this out because I was comparing some configuration differences between clusters we have and how they were created via terraform, and I saw in the SpotInst UI -> View Configuration the following:
cluster 1
"iamInstanceProfile": {
"name": "<CLUSTER_NAME>20201209214601735300000002"
},
cluster 2
"iamInstanceProfile": {
"arn": "arn:aws:iam:::instance-profile/<CLUSTER_NAME>20201021021723070600000004"
},
This is a request to improve the documentation AND/OR change the meaning of the parameter and include multiple parameters to make it clear what you expect to see as input.
### Community Note
* Please vote on this issue by adding a ๐ [reaction](https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) to help the community and maintainers prioritize this request.
* If you are interested in working on this issue or have submitted a pull request, please leave a comment.
<!--- Thank you for keeping this note for the community --->
According to https://registry.terraform.io/providers/spotinst/spotinst/latest/docs/resources/ocean_ecs_launch_spec we cannot pass "subnet_ids" field to "spotinst_ocean_ecs_launch_spec ".
The API seems to support it though: https://docs.spot.io/api/#operation/OceanECSLaunchSpecCreate field subnetIds.
One possible use case is to run both public & private workloads on the same ECS cluster.
Currently I'm forced to run 2 clusters, one for webapps in public subnets and one for workers in private subnets.
0.12.29
Please list the resources as a list, for example:
If this issue appears to affect multiple resources, it may be an issue with
Terraform's core, so please mention this.
We have "tags" defined in locals as a map
trying to merge the tags in any resource Is not working and has to be created seperately for each tag.
tags = {merge(locals.tags)}
Terraform should take the tags in the locals and create those tags on the resource as it does in any other provider.
it errors with "Unsupported attribute"
Please list the steps required to reproduce the issue, for example:
Are there anything atypical about your accounts that we should know?
Terraform v0.12.18
Provider Versions:
resource "spotinst_ocean_aws" "spotinst" {
name = "${local.cluster_name}"
controller_id = "${local.cluster_name}"
region = local.region
user_data = "${base64encode(module.userdata)}"
subnet_ids = "${module.private_subnet.*.id}"
image_id = "${data.aws_ami.eks-worker.id}"
security_groups = ["${module.worker_security_group}"]
iam_instance_profile = "${module.instance_profile_name}"
associate_public_ip_address = false
root_volume_size = 400
// --- STRATEGY --------------------
min_size = 3
max_size = 1000
fallback_to_ondemand = true
spot_percentage = 100
draining_timeout = 120
utilize_reserved_instances = false
// ---------------------------------
// --- AUTOSCALER -----------------
autoscaler {
autoscale_is_enabled = true
autoscale_is_auto_config = true
autoscale_cooldown = 300
autoscale_down {
evaluation_periods = 300
}
}
// --------------------------------
tags {
key = "kubernetes.io/cluster/${local.cluster_name}"
value = "owned"
}
}
The provider doesn't allow a user to set a According to subnet default
equivalent option when configuring associate_public_ip_address
; it's only available via the spotinst UI. The default value is false
according to docs. The terraform provider should allow a cluster to configure "subnet default" when determining if a public ip address association.
associate_public_ip_address
only supports 2 of the 3 options:
true
: Associate public IP
false
Do not associate public IP
Use Case:
As a user, I would like to configure associate_public_ip_address
in spotinst_ocean_aws resources with all eligible options via Terraform to avoid having to do manual configurations in the UI.
terraform apply
while changing the value for associate_public_ip_address
As part of the preparation for Terraform v0.12, we would like to migrate all providers to use Go Modules. We plan to continue checking dependencies into vendor/ to remain compatible with existing tooling/CI for a period of time, however go modules will be used for management. Go Modules is the official solution for the go programming language, we understand some providers might not want this change yet, however we encourage providers to begin looking towards the switch as this is how we will be managing all Go projects in the future. Would maintainers please react with ๐ for support, or ๐ if you wish to have this provider omitted from the first wave of pull requests. If your provider is in support, we would ask that you avoid merging any pull requests that mutate the dependencies while the Go Modules PR is open (in fact a total codefreeze would be even more helpful), otherwise we will need to close that PR and re-run go mod init
. Once merged, dependencies can be added or updated as follows:
$ GO111MODULE=on go get github.com/some/module@master
$ GO111MODULE=on go mod tidy
$ GO111MODULE=on go mod vendor
GO111MODULE=on might be unnecessary depending on your environment, this example will fetch a module @ master and record it in your project's go.mod and go.sum files. It's a good idea to tidy up afterward and then copy the dependencies into vendor/. To remove dependencies from your project, simply remove all usage from your codebase and run:
$ GO111MODULE=on go mod tidy
$ GO111MODULE=on go mod vendor
Thank you sincerely for all your time, contributions, and cooperation!
The spotinst_ocean_aws_launch_spec
resource if is still in the state file, but deleted from spotinst by some other means than terraform (e.g. spotinst console), then all subsequent terraform plan
operations will exit with an error message "resource not found" instead of acknowledging that it has disappeared and trying to recreate on the next apply.
The only workaround is to terraform state rm
the deleted resource manually.
v0.11.14
v1.13.3
When I manage a spotinst_ocean_aws_launch_spec I would expect that if someone deletes that resource on the spotinst console, when I next run terraform plan
it would notice and will try to recreate it on apply.
terrafrom plan
exits with error:
Error: Error refreshing state: 1 error occurred:
* spotinst_ocean_aws_launch_spec.example: 1 error occurred:
* spotinst_ocean_aws_launch_spec.example: spotinst_ocean_aws_launch_spec.example: failed to read launchSpec: GET https://api.spotinst.io/ocean/aws/k8s/launchSpec/ols-99b018bd?accountId=<account_id>: 400 (request: "5c91be7f-623a-4b56-ab65-1d2e8eb1e80a") CANT_GET_OCEAN_LAUNCH_SPEC: LaunchSpec: 'ols-99b018bd' does not exist
spotinst_ocean_aws_launch_spec
managed by terraformterraform apply
spotinst_ocean_aws_launch_spec
resource using the spotinst consoleterraform plan
0.12.13
When hitting a roll failure, we should be getting a dump of the specific error coming from awaitReadyRoll()
.
Error information from awaitReadyRoll()
is never passed back to the fmt.Errorf()
function. So the actual error is never communicated to the user.
Error: [ERROR] Timed out when waiting for minimum roll %: %!s(<nil>)
Push a roll with this resource that will timeout or otherwise fail in awaitReadyRoll()
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.