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.

Obsolete `DependsOn` with Lambda functions

See original GitHub issue

Bug Report

Description

Lambda functions have an obsolete DependsOn resource.

  1. What did you do? I ran the sls package command

  2. What happened? A cloudformation-template-update-stack.json was generated with

    "NylasLambdaFunction": {
      "Type": "AWS::Lambda::Function",
      "Properties": {
        "Code": {
          "S3Bucket": "removed",
          "S3Key": "removed"
        },
        "FunctionName": "removed",
        "Handler": "functions/nylas/index.handler",
        "MemorySize": 1024,
        "Role": {
          "Fn::GetAtt": [
            "IamRoleLambdaExecution",
            "Arn"
          ]
        },
        "Runtime": "nodejs12.x",
        "Timeout": 600,
        "TracingConfig": {
          "Mode": "Active"
        },
        "Environment": {
          "Variables": {
            "NYLAS_APP_ID": "missing_NYLAS_APP_ID",
            "NYLAS_APP_SECRET": "missing_NYLAS_APP_SECRET"
          }
        }
      },
      "DependsOn": [
        "NylasLogGroup",
        "IamRoleLambdaExecution" # Issue is here, this isn't required because dependency is enforced by "Fn:GetAtt"
      ]
    },
  1. What should’ve happened?
    "NylasLambdaFunction": {
      "Type": "AWS::Lambda::Function",
      "Properties": {
        "Code": {
          "S3Bucket": "removed",
          "S3Key": "removed"
        },
        "FunctionName": "removed",
        "Handler": "functions/nylas/index.handler",
        "MemorySize": 1024,
        "Role": {
          "Fn::GetAtt": [
            "IamRoleLambdaExecution",
            "Arn"
          ]
        },
        "Runtime": "nodejs12.x",
        "Timeout": 600,
        "TracingConfig": {
          "Mode": "Active"
        },
        "Environment": {
          "Variables": {
            "NYLAS_APP_ID": "missing_NYLAS_APP_ID",
            "NYLAS_APP_SECRET": "missing_NYLAS_APP_SECRET"
          }
        }
      },
      "DependsOn": [
        "NylasLogGroup",
        # Remove the IamRoleLambdaExecution depedency
      ]
    },
  1. What’s the content of your serverless.yml file?
service: ${self:custom.project.name}

package:
  individually: true

provider:
  name: aws
  tracing:
    lambda: true
  versionFunctions: false
  stage: ${file(./serverless.js):provider.stage}
  stackName: ${file(./serverless.js):project.stackName}
  runtime: ${file(./serverless.js):provider.runtime}
  region: ${file(./serverless.js):provider.region}
  logRetentionInDays: ${file(./serverless.js):provider.logRetentionInDays}

  deploymentBucket:
    name: ${file(./serverless.js):provider.deploymentBucket.name}
  iamRoleStatements: # permissions for all of your functions can be set here
    - Effect: 'Allow'
      Action:
        - 's3:*'
      Resource: '*'
    - Effect: 'Allow'
      Action:
        - 'dynamodb:*'
      Resource: '*'

plugins:
  - '@dathuis/serverless-stack-output'
  - serverless-webpack
  - serverless-offline

custom:
  project: ${file(./serverless.js):project}

  webpack:
    webpackConfig: 'webpack.config.js'
    includeModules:
      packagePath: '../../package.json'
      forceExclude:
        - aws-sdk
    packager: 'npm'

functions:
  nylas:
    handler: functions/nylas/index.handler
    environment:
      NYLAS_APP_ID: ${env:NYLAS_APP_ID, 'missing_NYLAS_APP_ID'}
      NYLAS_APP_SECRET: ${env:NYLAS_APP_SECRET, 'missing_NYLAS_APP_SECRET'}
    memorySize: 1024
    timeout: 600

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
ghostcommented, Mar 18, 2020

This does trigger W3005 on cfn-lint: https://github.com/aws-cloudformation/cfn-python-lint/blob/master/docs/rules.md

Would be nice if serverless passed all the errors and warnings for cfn-lint by itself. We run cfn-lint on the generated stack to make sure our custom CFN code isn’t broken, so this does generate a decent bit of noise. Not sure how to lint just the custom resources.

1reaction
AhmedFat7ycommented, May 12, 2020

will work on it

Read more comments on GitHub >

github_iconTop Results From Across the Web

DependsOn attribute - AWS CloudFormation
Specify that the creation of a specific resource depends on another resource in CloudFormation with the DependsOn attribute.
Read more >
How do you "DependsOn" a Lambda function from a CFN ...
The DependsOn attribute should have the logical name of the Lambda Function in the Cloud formation template not the ARN of Lambda Function....
Read more >
AWS Lambda Functions - Serverless Framework
By default, Lambda allocates 512 MB of ephemeral storage in functions under the /tmp directory. You can increase its size via the ephemeralStorageSize...
Read more >
aws.lambda.Function - Pulumi
Documentation for the aws.lambda.Function resource with examples, input properties, output properties, lookup functions, and supporting types.
Read more >
Config Rules: Outdated AMI Check - A Secure Cloud
This configuration will create a Lambda Function for the Custom Config ... 300 DependsOn: "LambdaIamRoleCustomConfigRule" LambdaIamRoleCustomConfigRule: ...
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