Search code examples
amazon-web-servicesautomationansibleboto3amazon-rds

When trying to stop RDS using ansible, I get an error saying i haven't provided enough parameters ApplyImmediately, AlocatedStorage, Iops


Below is a snippet from my Ansible playbook

  tasks:
    - name: Stop RDSs
      rds_instance:
        region: us-west-2
        aws_access_key: xxxxxxxxxxxxxxxxxxxxxx
        aws_secret_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        id: "my_instance_id"
        skip_final_snapshot: true
        state: stopped

The error I am getting is

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: Invalid type for parameter Iops, value: None, type: <class 'NoneType'>, valid types: <class 'int'>
fatal: [localhost]: FAILED! => {"boto3_version": "1.26.101", "botocore_version": "1.29.101", "changed": false, "msg": "Unexpected failure for method modify_db_instance with parameters {'AllocatedStorage': None, 'Iops': None, 'DBInstanceIdentifier': 'my_instance_id', 'ApplyImmediately': False}: Parameter validation failed:\nInvalid type for parameter AllocatedStorage, value: None, type: <class 'NoneType'>, valid types: <class 'int'>\nInvalid type for parameter Iops, value: None, type: <class 'NoneType'>, valid types: <class 'int'>"}

and when i explicitly add all the parameters the error statement lists,

allocated_storage: 150  
iops: 1000
apply_immediately: true

the playbook finishes without any errors but the rds doesn't get stopped.

Also this is only happening to a specific set of RDSs, the playbook above works fine with other RDSs in my stack.

My ansible version details are as follows

ansible [core 2.14.4]
 python version = 3.10.10 [GCC 10.2.1 20210110] (/usr/local/bin/python)
  jinja version = 3.1.2
  libyaml = True

Solution

  • have you tried running the playbook in higher verbose? you can also troubleshoot further to see if the API call is making there and handle that specific set of RDS. Here is a link for troubleshooting further https://www.ansible.com/blog/troubleshoot-rds-connectivity-issues-with-ansible-validated-content