Team,
Is there a way to Create item
on the aws dynamodb table using Ansible?
We have a dynamodb table, which has Attributes called hostID
, we would like to update the value using the ansible task (the value
get generated from another task). I have tried a few different ways using community.aws.dynamodb_table module
but no luck. Any suggestions?
Task:
- name: Insert an item with hostID into the onprem_certificates DynamoDB table
community.aws.dynamodb_table:
region: "{{ aws_ssm_region }}"
name: "{{ dynamodb_table_name }}"
hash_key_name: "hostID"
item:
hostID: "{{ manage_instance_id }}"
state: "present"
This one is working.
- name: Update dynamodb table with managed instance details
delegate_to: localhost
become: false
ansible.builtin.command: >
aws dynamodb --region "{{ aws_ssm_region }}" put-item \
--table-name "{{ dynamodb_table_name }}" \
--item \
'{"hostID": {"S": "'{{ manage_instance_id }}'" }}'