aws / chalice

Python Serverless Microframework for AWS
Apache License 2.0
10.67k stars 1.01k forks source link

Config `log_retention_in_days` not working #2079

Open garganshulgarg opened 1 year ago

garganshulgarg commented 1 year ago

Whenever we are using log_retention_in_days attribute within our chalice configuration we are getting "Feature Unsupported exception"

chalice.package.UnsupportedFeatureError: LogGroup(resource_name='api_handler-log-group', log_group_name='/aws/lambda/xxx-api_handler', retention_in_days=7)

We are using chalice version 1.29.0

antoine-briand commented 11 months ago

Hi 👋

I'm not sure it's entirely related, but I'm trying to use 'log_retention_in_days': 7, in a chalice project with CDK. When I add this to the stage_config, I get the following error :

RuntimeError: Element referenced in Fn::Sub expression with logical ID: 'ApiHandler' was not found in the template

I'm using chalice==1.29.0 and python 3.10.

        self.chalice = Chalice(
            self,
            'ChaliceApp',
            source_dir=RUNTIME_SOURCE_DIR,
            stage_config={
                'environment_variables': self.environment_variables,
                'lambda_timeout': 900,
                'lambda_memory_size': 256,
                'log_retention_in_days' : 7
            },
        )
delta1513 commented 5 months ago

I get the same error when adding log_retention_in_days to my chalice config. Fairly certain I'm doing this right. Here's my obfuscated config:

{
  "version": "2.0",
  "app_name": "***",
  "automatic_layer": true,
  "stages": {
    "public": {
      "api_gateway_stage": "***",
      "api_gateway_endpoint_type": "REGIONAL",
      "autogen_policy": false,
      "iam_policy_file": "iam-policy.json",
      "subnet_ids": "***",
      "security_group_ids": [ ... ],
      "log_retention_in_days": 731,
      "environment_variables": { ... }
    }
  }
}

Then when I package this (before being run with terraform), I get this error:

chalice.package.UnsupportedFeatureError: LogGroup(resource_name='***', log_group_name='/aws/lambda/***', retention_in_days=731)

The chalice version we are using is 1.29.0 and I've also tried upgrading to 1.31.1 with no luck either 🙁