# Template format error: YAML not well-formed.

**URL:** <https://forum.ansible.com/t/template-format-error-yaml-not-well-formed/29384>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [January 7, 2019, 4:34pm UTC](https://forum.ansible.com/t/template-format-error-yaml-not-well-formed/29384 "2019-01-07T16:34:25Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kishore\_Ponniah](https://avatars.discourse-cdn.com/v4/letter/k/74df32/32.png) [@Kishore\_Ponniah](https://forum.ansible.com/u/Kishore_Ponniah)\
**Post date:** [January 7, 2019, 4:34pm UTC](https://forum.ansible.com/t/template-format-error-yaml-not-well-formed/29384/1 "2019-01-07T16:34:25Z")

</div>

Hi all,

My cloudformation template has exceeded the template body limit more than 51200 bytes and I am trying to upload to s3 and deploy using cross account. I used template\_url parameter in the playbook but giving an error. Before adding template\_url, I had template\_body which was working fine. I have only replaced template\_body to template\_url.

Please find the playbook below:

- name: create xx-xxxx-xxxx-xxxxxx-iam-atlas-developer-roles changeset  
cloudformation:  
stack\_name: “xx-xxxx-xxxx-xxxxxx-iam-atlas-developer-roles”  
state: present  
region: “{{ account\_config.1 }}”  
aws\_access\_key: “{{ account\_config.0.sts\_creds.access\_key }}”  
aws\_secret\_key: “{{ account\_config.0.sts\_creds.secret\_key }}”  
security\_token: “{{ account\_config.0.sts\_creds.session\_token }}”  
create\_changeset: true  
changeset\_name: “{{ cf\_changeset\_name }}”  
template\_url: “[https://s3.console.aws.amazon.com/s3/buckets/xxxxxxxxxxxxxxxxxxxxxxxxxx/xxxxxxxxxxxx/cloudformation/xxxxxxx/xx-xxxx-xxxx-xxxxxx-iam-atlas-developer-roles.yaml](https://s3.console.aws.amazon.com/s3/buckets/xxxxxxxxxxxxxxxxxxxxxxxxxx/xxxxxxxxxxxx/cloudformation/xxxxxxx/xx-xxxx-xxxx-xxxxxx-iam-atlas-developer-roles.yaml)”  
template\_parameters: “{{ account\_config.0.account\_config.stacks[’ xx-xxxx-xxxx-xxxxxx-iam-atlas-developer-roles’].params }}”  
termination\_protection: no  
tags: “{{ global\_tags | combine(account\_config.0.account\_config.stacks[’ xx-xxxx-xxxx-xxxxxx-iam-atlas-developer-roles’].override\_tags, recursive=True) }}”  
loop: “{{ assumed\_roles\_with\_account\_config.results|subelements(‘account\_config.regions’, skip\_missing=True) }}”  
loop\_control:  
loop\_var: account\_config  
label: “{{ account\_config.0.account\_config.account\_alias }}:{{ account\_config.1 }}”  
tags:  
rxgt-ps-identity-stack-deploy

- name: create xx-xxxx-xxxx-xxxxxx-iam-atlas-developer-roles stack  
cloudformation:  
stack\_name: “xx-xxxx-xxxx-xxxxxx-iam-atlas-developer-roles”  
state: present  
region: “{{ account\_config.1 }}”  
aws\_access\_key: “{{ account\_config.0.sts\_creds.access\_key }}”  
aws\_secret\_key: “{{ account\_config.0.sts\_creds.secret\_key }}”  
security\_token: “{{ account\_config.0.sts\_creds.session\_token }}”  
create\_changeset: false  
changeset\_name: “{{ cf\_changeset\_name }}”  
template\_url: “[https://s3.console.aws.amazon.com/s3/buckets/xxxxxxxxxxxxxxxxxxxxxxxxxx/xxxxxxxxxxxx/cloudformation/xxxxxxx/xx-xxxx-xxxx-xxxxxx-iam-atlas-developer-roles.yaml](https://s3.console.aws.amazon.com/s3/buckets/xxxxxxxxxxxxxxxxxxxxxxxxxx/xxxxxxxxxxxx/cloudformation/xxxxxxx/xx-xxxx-xxxx-xxxxxx-iam-atlas-developer-roles.yaml)”

template\_parameters: “{{ account\_config.0.account\_config.stacks[‘xx-xxxx-xxxx-xxxxxx-iam-atlas-developer-roles’].params }}”  
termination\_protection: no  
tags: “{{ global\_tags | combine(account\_config.0.account\_config.stacks[‘xx-xxxx-xxxx-xxxxxx-iam-atlas-developer-roles’].override\_tags, recursive=True) }}”

# Convert to a list of dicts duplicated per region. See [https://docs.ansible.com/ansible/latest/user\_guide/playbooks\_filters.html#subelements-filter](https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html#subelements-filter)

loop: “{{ assumed\_roles\_with\_account\_config.results|subelements(‘account\_config.regions’, skip\_missing=True) }}”  
loop\_control:  
loop\_var: account\_config  
label: “{{ account\_config.0.account\_config.account\_alias }}:{{ account\_config.1 }}”  
when: with\_stack\_deploy  
tags:  
rxgt-ps-identity-stack-deploy

---

<div class="post-metadata">

**Author:** ![Kishore\_Ponniah](https://avatars.discourse-cdn.com/v4/letter/k/74df32/32.png) [@Kishore\_Ponniah](https://forum.ansible.com/u/Kishore_Ponniah)\
**Post date:** [January 7, 2019, 4:38pm UTC](https://forum.ansible.com/t/template-format-error-yaml-not-well-formed/29384/2 "2019-01-07T16:38:11Z")

</div>

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: botocore.exceptions.ClientError: An error occurred (ValidationError) when calling the CreateChangeSet operation: Template format error: YAML not well-formed. (line 12, column 6)

---

<div class="post-metadata">

**Author:** ![Karthik\_Chandrasheka](https://avatars.discourse-cdn.com/v4/letter/k/9d8465/32.png) [@Karthik\_Chandrasheka](https://forum.ansible.com/u/Karthik_Chandrasheka)\
**Post date:** [January 7, 2019, 4:38pm UTC](https://forum.ansible.com/t/template-format-error-yaml-not-well-formed/29384/3 "2019-01-07T16:38:31Z")

</div>

It would have shown line number as well in the error. Please look into yaml file.

May be it could be an issue with unnecessary tab/space.

Regards,  
Karthik.C

---

<div class="post-metadata">

**Author:** ![Kishore\_Ponniah](https://avatars.discourse-cdn.com/v4/letter/k/74df32/32.png) [@Kishore\_Ponniah](https://forum.ansible.com/u/Kishore_Ponniah)\
**Post date:** [January 7, 2019, 4:48pm UTC](https://forum.ansible.com/t/template-format-error-yaml-not-well-formed/29384/4 "2019-01-07T16:48:19Z")

</div>

Yes, it did show the line number (line 12, column 6). I checked the line with tab and space

- name: get sts session token

I did not make any update on this section. The only change I made was instead of template\_body, I changed to template\_url.

---

<div class="post-metadata">

**Author:** ![goforawalktwice](https://avatars.discourse-cdn.com/v4/letter/g/c5a1d2/32.png) [@goforawalktwice](https://forum.ansible.com/u/goforawalktwice)\
**Post date:** [January 8, 2019, 12:58am UTC](https://forum.ansible.com/t/template-format-error-yaml-not-well-formed/29384/5 "2019-01-08T00:58:08Z")

</div>

hi, when I paste that YAML to

[https://jsonformatter.org/yaml-validator](https://jsonformatter.org/yaml-validator)

it reckons line 22 is a problem - the second -name entry. When I remove from line 22 down it reckons it’s valid YAML.

Regards, Straff

---

<div class="post-metadata">

**Author:** ![Karl\_Auer](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@Karl\_Auer](https://forum.ansible.com/u/Karl_Auer)\
**Post date:** [January 8, 2019, 1:04am UTC](https://forum.ansible.com/t/template-format-error-yaml-not-well-formed/29384/6 "2019-01-08T01:04:04Z")

</div>

What is the problem that it reports on line 22?

When posting code, please post in a fixed-width font if you can. Makes it easier to check indentation.

Regards, K.

---

<div class="post-metadata">

**Author:** ![goforawalktwice](https://avatars.discourse-cdn.com/v4/letter/g/c5a1d2/32.png) [@goforawalktwice](https://forum.ansible.com/u/goforawalktwice)\
**Post date:** [January 8, 2019, 1:37am UTC](https://forum.ansible.com/t/template-format-error-yaml-not-well-formed/29384/7 "2019-01-08T01:37:43Z")

</div>

ooops … the error was due to me copy/paste formatting - the second ‘-name’ got indented too far - fixing that indentation makes it valid YAML according to that site

---

<div class="post-metadata">

**Author:** ![Kishore\_Ponniah](https://avatars.discourse-cdn.com/v4/letter/k/74df32/32.png) [@Kishore\_Ponniah](https://forum.ansible.com/u/Kishore_Ponniah)\
**Post date:** [January 8, 2019, 10:06am UTC](https://forum.ansible.com/t/template-format-error-yaml-not-well-formed/29384/8 "2019-01-08T10:06:31Z")

</div>

Please find my code below: I checked the code using YAML validator and looks like it is valid. But still complaining about Line 12 column 6.

Any help please?

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [January 8, 2019, 12:41pm UTC](https://forum.ansible.com/t/template-format-error-yaml-not-well-formed/29384/9 "2019-01-08T12:41:15Z")

</div>

I suspect the issue is introduced by the copy/pasting.  
Can you pipe it directly to yamllint and tell us what that says?

DIck

---

<div class="post-metadata">

**Author:** ![Kishore\_Ponniah](https://avatars.discourse-cdn.com/v4/letter/k/74df32/32.png) [@Kishore\_Ponniah](https://forum.ansible.com/u/Kishore_Ponniah)\
**Post date:** [January 8, 2019, 1:04pm UTC](https://forum.ansible.com/t/template-format-error-yaml-not-well-formed/29384/10 "2019-01-08T13:04:11Z")

</div>

Hi,

That issue is now fixed by re-doing that part of the code but introduced with another error: S3 error: Requests specifying Server Side Encryption with AWS KMS managed keys require AWS Signature Version 4. This is because the S3 bucket is encrypted. I tried to create a temporary unencrypted bucket and it works fine. I found a document and it says “to use KMS with S3 encryption you have to set the signature version to v4 explicitly”

[https://forums.aws.amazon.com/thread.jspa?threadID=165286](https://forums.aws.amazon.com/thread.jspa?threadID=165286)  
[https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingAWSSDK.html#specify-signature-version](https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingAWSSDK.html#specify-signature-version)

I am not sure where this needs to be updated, as I am running this code from Cloud9 environment. I guess it is Python-Boto SDK.
