spotinst / terraform-provider-spotinst

Terraform Spotinst provider.
https://registry.terraform.io/providers/spotinst/spotinst/latest/docs
Mozilla Public License 2.0
63 stars 56 forks source link

Unexpected user_data change in spotinst_elastigroup_aws #42

Closed Defozo closed 5 years ago

Defozo commented 5 years ago

Terraform Version

Terraform v0.11.10

Affected Resource(s)

Terraform Configuration Files

"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"
}

Expected Behavior

The Spotinst Elastigroup should be created and after that creation running terraform plan shouldn't point out any changes needed.

Actual Behavior

The Spotinst Elastigroup is being created successfully but then when I run terraform plan it points out that user_data has been changed.

Steps to Reproduce

  1. terraform apply
  2. terraform plan
  3. The plan presents the required change to elastigroup's user_data because it has changed.

References

Similar problem in the AWS provider: https://github.com/terraform-providers/terraform-provider-aws/issues/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

alexindeed commented 5 years ago

Thanks for reporting @Defozo. The changes from #39 were released in v1.10.0, which should resolve this issue. If you encounter future trouble with user data (or other base64 encoded strings) please let me know!