question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"tags" values in "zappa_settings.py" are not applied to the API Gateway stage that Zappa creates

See original GitHub issue

The tags section of zappa_settings.py is documented as follows:

"tags": { // Attach additional tags to AWS Resources
    "Key": "Value",  // Example Key and value
    "Key2": "Value2",
    },

However, when deploying for API Gateway, the tags are only applied to the Lambda function, not to the associated API Gateway stage.

Context

This is a bit of an issue, primarily as AWS tags are often used for:

  • Cost allocation
  • Third-party AWS metric services (such as Datadog)

When tags aren’t applied to the API Gateway stage that Zappa creates and maintains, then they can’t be used to track API Gateway specific costs or used in third-party metric services to filter metrics/set monitoring alerts.

Expected Behavior

The tags specified in the tags section of zappa_settings.py should be applied to all AWS resources that Zappa creates/manages.

Actual Behavior

Tags are only applied to the Lambda function.

Possible Fix

Apply the same tags that are applied to the Lambda function when creating/updating the API Gateway stage.

Steps to Reproduce

  1. Create a Zappa project that uses API Gateway
  2. Set some tag key/values in the tags section of zappa_settings.py in the Zappa project
  3. Deploy the API Gateway API
  4. Select the API Gateway stage that Zappa has created in the AWS console and select the “Configure Tags” button - no tags are present

Your Environment

  • Zappa version used: 0.48.2

  • Operating System and Python version: Linux (Ubuntu 18.04) - Python 3.6

  • The output of pip freeze:

      argcomplete==1.9.3
      boto3==1.9.172
      botocore==1.12.172
      certifi==2019.6.16
      cfn-flip==1.2.1
      chardet==3.0.4
      Click==7.0
      docutils==0.14
      durationpy==0.5
      future==0.16.0
      hjson==3.0.1
      idna==2.8
      jmespath==0.9.3
      kappa==0.6.0
      lambda-packages==0.20.0
      pkg-resources==0.0.0
      placebo==0.9.0
      python-dateutil==2.6.1
      python-slugify==1.2.4
      PyYAML==5.1.1
      requests==2.22.0
      s3transfer==0.2.1
      six==1.12.0
      toml==0.10.0
      tqdm==4.19.1
      troposphere==2.4.7
      Unidecode==1.1.0
      urllib3==1.25.3
      Werkzeug==0.15.4
      wsgi-request-logger==0.4.6
      zappa==0.48.2
    
  • Your zappa_settings.py:

      {
      "test": {
          "project_name": "test",
          "apigateway_description": "Test.",
          "app_function": "service.app",
          "runtime": "python3.6",
          "apigateway_enabled": true,
          "keep_warm": false,
          "timeout_seconds": 900,
          "memory_size": 3008,
          "extra_permissions": [
              {
                  "Effect": "Allow",
                  "Action": [
                      "dynamodb:GetItem",
                      "dynamodb:PutItem",
                      "dynamodb:Query",
                      "dynamodb:UpdateItem",
                      "iam:PassRole"
                  ],
                  "Resource": "*"
              }
          ],
          "tags": {
              "tag_key_1": "tag_value_1",
              "tag_key_2": "tag_value_2"
          }
      }
      }
    

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:2
  • Comments:6

github_iconTop GitHub Comments

3reactions
cotmancommented, Aug 29, 2019

@Miserlou Any chance the tagging tweak in the linked PR could get into the next Zappa release? I think it’s pretty benign but, at the moment, we’re having to use the forked Zappa in our production deployments so that we’re tagged correctly (and we’d prefer to be back onto your normal PyPi release, so we can pick up other released changed easily).

1reaction
cotmancommented, Sep 4, 2019

PR has now been updated so that it also tags ALBs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Deploy Existing Web Applications as Serverless using AWS ...
Zappa. “Zappa makes it super easy to build and deploy all Python WSGI applications on AWS Lambda + API Gateway. Think of it...
Read more >
Solution for Serverless Python Web Hosting on AWS - InfoTrust
Zappa is a system for running server-less Python web applications on AWS Lambda and AWS API Gateway. This `init` command will help you...
Read more >
Zappa project and virtualenv have the same name
Your project and virtualenv have the same name! You may want to re-create your venv with a new name, or explicitly define a...
Read more >
Setting up tags for an API stage in API Gateway
In the Tag Editor, choose Add New Tag. Enter a tag key (for example, Department ) in the Key field, and enter a...
Read more >
Building Serverless Apps with AWS, Lambda, Python & Zappa
In this post, we review the Python framework Zappa, which greatly ... ID in the Zappa settings file, and Zappa will create an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found