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

[Migrated] BadRequestException: CloudWatch Logs role ARN must be set in account settings to enable logging #793

Open
jneves opened this issue Feb 20, 2021 · 4 comments
Labels
needs-review Needs attention from a maintainer

Comments

@jneves
Copy link
Contributor

jneves commented Feb 20, 2021

Originally from: Miserlou/Zappa#1946 by ebridges

When enabling logging using the setting cloudwatch_log_level an exception will get thrown if the API Gateway Settings has not configured an ARN with permissions to write to Cloudwatch.

Exception encountered (stack trace below):

botocore.errorfactory.BadRequestException: An error occurred (BadRequestException) when calling the UpdateStage operation: CloudWatch Logs role ARN must be set in account settings to enable logging

Expected Behavior

Deploy should be successful

Actual Behavior

This exception is thrown:

Traceback (most recent call last):
  File "/home/elektrum/venv/lib/python3.7/site-packages/zappa/cli.py", line 2779, in handle
    sys.exit(cli.handle())
  File "/home/elektrum/venv/lib/python3.7/site-packages/zappa/cli.py", line 509, in handle
    self.dispatch_command(self.command, stage)
  File "/home/elektrum/venv/lib/python3.7/site-packages/zappa/cli.py", line 546, in dispatch_command
    self.deploy(self.vargs['zip'])
  File "/home/elektrum/venv/lib/python3.7/site-packages/zappa/cli.py", line 830, in deploy
    endpoint_url = self.deploy_api_gateway(api_id)
  File "/home/elektrum/venv/lib/python3.7/site-packages/zappa/cli.py", line 2675, in deploy_api_gateway
    cache_cluster_encrypted=self.stage_config.get('cache_cluster_encrypted', False)
  File "/home/elektrum/venv/lib/python3.7/site-packages/zappa/core.py", line 1802, in deploy_api_gateway
    self.get_patch_op('caching/dataEncrypted', cache_cluster_encrypted)
  File "/home/elektrum/venv/lib/python3.7/site-packages/botocore/client.py", line 357, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/home/elektrum/venv/lib/python3.7/site-packages/botocore/client.py", line 661, in _make_api_call
    raise error_class(parsed_response, operation_name)
botocore.errorfactory.BadRequestException: An error occurred (BadRequestException) when calling the UpdateStage operation: CloudWatch Logs role ARN must be set in account settings to enable logging

Possible Fix

Example of how to set the value using AWS CLI:
https://docs.aws.amazon.com/cli/latest/reference/apigateway/update-account.html#examples

Boto method that should be used to do the update to the account:
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/apigateway.html#APIGateway.Client.update_account

Steps to Reproduce

  1. Clear out the field for Cloudwatch ARN in API Gateway Account Settings. "Empty" is the default value.
  2. Add the setting cloudwatch_log_level to zappa_settings.json
  3. Run zappa deploy [stage]
  4. Deploy should fail with the above stack trace.

Your Environment

  • Zappa version used: 0.48.2
  • Python version: 3.7
  • Operating System: Amazon Linux AMI release 2018.03
pip freeze output ``` argcomplete==1.9.3 boto3==1.9.243 botocore==1.12.243 CacheControl==0.12.5 cachy==0.2.0 certifi==2019.9.11 cfn-flip==1.2.1 chardet==3.0.4 cleo==0.6.8 Click==7.0 defusedxml==0.6.0 Django==2.2.6 django-allauth==0.40.0 django-dotenv==1.4.2 django-sslserver==0.21 django-storages==1.7.2 djangorestframework==3.10.3 docutils==0.15.2 durationpy==0.5 future==0.16.0 gunicorn==19.9.0 hjson==3.0.1 html5lib==1.0.1 idna==2.8 jmespath==0.9.3 jsonschema==3.1.1 kappa==0.6.0 lambda-packages==0.20.0 lockfile==0.12.2 msgpack==0.6.2 oauthlib==3.1.0 pastel==0.1.1 placebo==0.9.0 poetry==0.12.17 psycopg2-binary==2.8.3 pylev==1.3.0 pyrsistent==0.14.11 python-dateutil==2.6.1 python-slugify==1.2.4 python3-openid==3.1.0 pytz==2019.3 PyYAML==5.1.2 requests==2.22.0 requests-oauthlib==1.2.0 s3transfer==0.2.1 shellingham==1.3.1 six==1.12.0 sqlparse==0.3.0 toml==0.10.0 tomlkit==0.5.8 tqdm==4.19.1 troposphere==2.5.2 Unidecode==1.1.1 urllib3==1.25.6 Werkzeug==0.16.0 wsgi-request-logger==0.4.6 zappa==0.48.2 ```
Output of `uname -a` `Linux cc900f5afd54 4.9.184-linuxkit #1 SMP Tue Jul 2 22:58:16 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux`
gestrich pushed a commit to gestrich/aws-sam-node-example that referenced this issue Aug 20, 2021
@ic
Copy link

ic commented Jul 3, 2023

Same problem here, but on update and with the current latest (Zappa 0.57.0) on Lambda Python 3.9 runtime.

@ivan-trustek
Copy link

ivan-trustek commented Mar 26, 2024

up, py3.12 zappa from master

Copy link

Hi there! Unfortunately, this Issue has not seen any activity for at least 90 days. If the Issue is still relevant to the latest version of Zappa, please comment within the next 10 days if you wish to keep it open. Otherwise, it will be automatically closed.

@github-actions github-actions bot added the no-activity [Bot] Closing soon if no new activity label Jun 24, 2024
@ic
Copy link

ic commented Jun 25, 2024

I have not seen the problem any more, while a regular user. Is this okay to close, or anyone still blocked?

@github-actions github-actions bot added needs-review Needs attention from a maintainer and removed no-activity [Bot] Closing soon if no new activity labels Jun 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-review Needs attention from a maintainer
Projects
None yet
Development

No branches or pull requests

3 participants