Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AWS_URL isn't passed into dynamodb_table #146

Closed
fsproru opened this issue Jul 19, 2020 · 5 comments
Closed

AWS_URL isn't passed into dynamodb_table #146

fsproru opened this issue Jul 19, 2020 · 5 comments
Labels
affects_2.10 bug This issue/PR relates to a bug module module plugins plugin (any type) python3 traceback

Comments

@fsproru
Copy link

fsproru commented Jul 19, 2020

SUMMARY

dynamodb_table module doesn't use AWS_URL as described in the documentation. Which prevents us from running it against LocalStack

ISSUE TYPE
  • Bug Report
COMPONENT NAME

dynamodb_table

ANSIBLE VERSION
ansible 2.9.3
  config file = None
  configured module search path = ['{{HOME}}/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/Cellar/ansible/2.9.3/libexec/lib/python3.8/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.8.1 (default, Dec 27 2019, 18:06:00) [Clang 11.0.0 (clang-1100.0.33.16)]
CONFIGURATION
empty
OS / ENVIRONMENT

macOS Catalina

STEPS TO REPRODUCE

Running the following playbook

---
- hosts: localhost
  remote_user: bob
  tasks:
    - name: Create the Tank table
      dynamodb_table:
        name: Tank
        hash_key_name: id
        hash_key_type: STRING
        read_capacity: 1
        write_capacity: 1

using the following command

AWS_URL=http://localhost:4566 AWS_REGION=us-east-1 AWS_ACCESS_KEY_ID=NONE_FOR_LOCAL AWS_SECRET_ACCESS_KEY=NONE_FOR_LOCAL ansible-playbook ./playbook-dynamo.yml
EXPECTED RESULTS

Expected to create a DynamoDB table in LocalStack since AWS_URL points to it

ACTUAL RESULTS

The command fails with the following output, looks like it still tries to hit some default AWS endpoints instead of AWS_URL

PLAY [localhost] ***************************************************************

TASK [Gathering Facts] *********************************************************
ok: [localhost]

TASK [Create the Tank table] ***************************************************
fatal: [localhost]: FAILED! => {"changed": false, "hash_key_name": "id", "hash_key_type": "STRING", "indexes": [], "msg": "Failed to create/update dynamo table due to error: Traceback (most recent call last):\n  File \"/var/folders/y7/bpszvwgj7lv54vjwp99lgg2h0000gn/T/ansible_dynamodb_table_payload_kapu_np8/ansible_dynamodb_table_payload.zip/ansible/modules/cloud/amazon/dynamodb_table.py\", line 213, in create_or_update_dynamo_table\n  File \"/var/folders/y7/bpszvwgj7lv54vjwp99lgg2h0000gn/T/ansible_dynamodb_table_payload_kapu_np8/ansible_dynamodb_table_payload.zip/ansible/modules/cloud/amazon/dynamodb_table.py\", line 292, in dynamo_table_exists\n  File \"/var/folders/y7/bpszvwgj7lv54vjwp99lgg2h0000gn/T/ansible_dynamodb_table_payload_kapu_np8/ansible_dynamodb_table_payload.zip/ansible/modules/cloud/amazon/dynamodb_table.py\", line 285, in dynamo_table_exists\n  File \"/usr/local/Cellar/ansible/2.9.3/libexec/lib/python3.8/site-packages/boto/dynamodb2/table.py\", line 356, in describe\n    result = self.connection.describe_table(self.table_name)\n  File \"/usr/local/Cellar/ansible/2.9.3/libexec/lib/python3.8/site-packages/boto/dynamodb2/layer1.py\", line 977, in describe_table\n    return self.make_request(action='DescribeTable',\n  File \"/usr/local/Cellar/ansible/2.9.3/libexec/lib/python3.8/site-packages/boto/dynamodb2/layer1.py\", line 2840, in make_request\n    response = self._mexe(http_request, sender=None,\n  File \"/usr/local/Cellar/ansible/2.9.3/libexec/lib/python3.8/site-packages/boto/connection.py\", line 954, in _mexe\n    status = retry_handler(response, i, next_sleep)\n  File \"/usr/local/Cellar/ansible/2.9.3/libexec/lib/python3.8/site-packages/boto/dynamodb2/layer1.py\", line 2884, in _retry_handler\n    raise self.ResponseError(response.status, response.reason,\nboto.exception.JSONResponseError: JSONResponseError: 400 Bad Request\n{'__type': 'com.amazon.coral.service#UnrecognizedClientException', 'message': 'The security token included in the request is invalid.'}\n", "range_key_name": null, "range_key_type": "STRING", "read_capacity": 1, "region": "us-east-1", "table_name": "Tank", "write_capacity": 1}

PLAY RECAP *********************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

Related issues:

@ansibullbot
Copy link

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibullbot
Copy link

@ansibullbot ansibullbot added the plugins plugin (any type) label Aug 27, 2020
@derekmwright
Copy link

As an FYI, this also appears to cause issues for those of us using GovCloud.

@tremble
Copy link
Contributor

tremble commented Oct 12, 2020

@derekmwright unfortunately most of dynamodb_table is currently a boto v2 module, so I'm not entirely surprised that it doesn't behave well with GovCloud.

There's an in-progress PR (#65) which would likely fix the issue by migrating to boto3 and our various helpers, however it appears to need some additional work.

@tremble
Copy link
Contributor

tremble commented Jul 9, 2022

This was finally fixed by #726 and should be available since release 2.1.0.

@tremble tremble closed this as completed Jul 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects_2.10 bug This issue/PR relates to a bug module module plugins plugin (any type) python3 traceback
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants