# Setting cloudformation time output as fact

**URL:** <https://forum.ansible.com/t/setting-cloudformation-time-output-as-fact/33417>\
**Category:** Ansible Project\
**Created:** [July 16, 2020, 6:14pm UTC](https://forum.ansible.com/t/setting-cloudformation-time-output-as-fact/33417 "2020-07-16T18:14:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![takshika\_jambhule](https://avatars.discourse-cdn.com/v4/letter/t/aca169/32.png) [@takshika\_jambhule](https://forum.ansible.com/u/takshika_jambhule)\
**Post date:** [July 16, 2020, 6:14pm UTC](https://forum.ansible.com/t/setting-cloudformation-time-output-as-fact/33417/1 "2020-07-16T18:14:47Z")

</div>

```auto
I'm trying to set up Cloudformation time as fact as below

```

```auto
- name: Set Cloud Formation launch time as fact
  set_fact:
    elasped_time: "{{ (ansible_date_time.iso8601[:19] | to_datetime(date_fmt) - ansible_facts['cloudformation'][stack_name]['stack_description']['creation_time'][:19] | to_datetime(date_fmt)).total_seconds() / 3600 | int }}"
  connection: local

```

```auto
But I'm getting the below error:-

```

```auto
*{"msg": "The task includes an option with an undefined variable. The error was: Unable to look up a name or access an attribute in template string ({{ (ansible_date_time.iso8601[:19] | to_datetime(date_fmt) - ansible_facts['cloudformation'][stack_name]['stack_description']['creation_time'][:19] | to_datetime(date_fmt)).total_seconds() / 3600 | int }}).\nMake sure your variable name does not contain invalid characters like '-': strptime() argument 1 must be str, not AnsibleUndefined\n\nThe offending line appears to be:\n\n\n- name: Set Cloud Formation launch time as fact\n ^ here\n"}*

```

```auto
Can someone suggest how to fix this?

```
