terraform apply and plan is broken with carriage return in opsworks custom.json template file

Created on 13 Oct 2016  ·  6Comments  ·  Source: hashicorp/terraform

Hi there,

found a pretty strange issue. It seems like a carriage return at the bottom of a template.json are "compared / diffed / parsed" in a wrong way with the actually applied state within opsworks.
It seems only to afffect version 0.7.5

Terraform Version

0.7.5

Affected Resource(s)

  • aws_opsworks_stack

    Terraform Configuration Files

    Attached as file

1) opsworks-create-stack.tf includes the data "template_file" + the module that is used for creating an opsworks stack

2) config_stack.json is the template file itself that is rendered

Expected Behavior

As there are no changes within the custom.json - terraform should not try to apply or suggest any changes that are related to the custom.json during plan or apply.

Actual Behavior

terraform plan suggests changes , terraform apply - really applies changes although there are none - Actually if you apply the changes for the custom.json they are the same in Opsworks as before.

Steps to Reproduce

1)

  • create a opsworks stack with a custom.json
  • the template file includes a carriage return at the end of the template.json

2)

  • apply initially
  • the next plan or apply will show changes , but actually there are none

What i suspect to be a cause of the problem:
It seems like the carriage return "/n" within the template is deleted by the Opsworks API.
A strong indication for this issue is, that terraform plan or terraform applyshow in their change list an additional "/n" after the whole custom.json block.

If you delete the carriage return (bottom line) within the template file, the issue seems to be fixed.

Additional information:
Usage of S3 remote state files.

Cheers
Ole

opsworks-create-stack.tf.txt
config_stack.json.txt

bug provideaws

Most helpful comment

A workaround is to use the trimspace interpolation function on the template.

All 6 comments

I am having the same issue, with the very same setup (custom_json as a template file, S3 remote state file). Because I would like to trigger null_resources on the custom_json, this is more than just an inconvenience.

After doing some quick tests, it seems like 0.7.6 is affected as well.

A workaround is to use the trimspace interpolation function on the template.

0.7.10 is still affected.

0.9.5 is still affected…

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kforsthoevel picture kforsthoevel  ·  86Comments

shubhambhartiya picture shubhambhartiya  ·  72Comments

oillio picture oillio  ·  78Comments

phinze picture phinze  ·  86Comments

kklipsch picture kklipsch  ·  95Comments