1

The following APIM policy cannot be deployed via Terraform:

<policies>
    <inbound>
        <send-request mode="new" response-variable-name="xxx" timeout="20" ignore-error="true">
            <set-url>https://xxx/api/v1/xxx?code={{xxx}}</set-url>
            <set-method>GET</set-method>
        </send-request>
        <return-response>
            <set-status code="302" reason="Redirect" />
            <set-header name="Location" exists-action="override">
                <value>@{
                         var response = context;
                         IResponse variable = context.Variables["xxx"] as IResponse;
                         var content = variable.Body;
                         JObject obj = content.As<JObject>(); <------------ < and > characters
                         JProperty urlprop = obj.Property("xxx");
                         return "" + urlprop.Value;
                       }
                  </value>
            </set-header>
        </return-response>
    </inbound>
    ...
</policies>

With the following error: The 'JObject' start tag on line 15 position 26 does not match the end tag of 'value'. Line 18, position 4.

This is due to the content.As<JObject>.

The policy is defined as in the Terraform documentation.

Same error when using xml_content = "${file("xxx")}".

How to proceed, besides finding a workaround to not use content.As<JObject>?

Francois
  • 10,730
  • 7
  • 47
  • 80

1 Answers1

2

The multilines statement (@{ }) can contain XML unfriendly characters, but not via the Terraform XML reader.

Use &lt; and &gt; if the XML policy is provisioning by Terraform.

Francois
  • 10,730
  • 7
  • 47
  • 80