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

Lambda function is packaged and uploaded every time, when no changes have been made #834

Open
3 tasks done
mrchops1024 opened this issue Mar 21, 2024 · 2 comments
Open
3 tasks done

Comments

@mrchops1024
Copy link

Are you certain it's a bug?

  • Yes, it looks like a bug

Are you using the latest plugin release?

  • Yes, I'm using the latest plugin release

Is there an existing issue for this?

  • I have searched existing issues, it hasn't been reported yet

Issue description

Despite no changes being made to my python Lambda function, it is packaged and uploaded to S3 on every deploy. Here is what the directory structure for this basic project looks like:

./serverless.yml
./.gitignore
./package-lock.json
./package.json
./lambda
./lambda/requirements.txt
./lambda/index.py

Service configuration (serverless.yml) content

service: serverless-python-requirements-test

frameworkVersion: '3'

plugins:
  - serverless-python-requirements

package:
  individually: true

custom:
  pythonRequirements:
    slim: true
    noDeploy:
      - boto3
      - botocore
      - jmespath
      - python-dateutil
      - s3transfer
      - six
      - urllib3

provider:
  name: aws
  region: us-west-2
  runtime: python3.11
  stackName: cfn-stack-usw2-serverless-python-requirements-test
  deploymentBucket:
    name: s3-usw2-serverless-python-requirements-test
    maxPreviousDeploymentArtifacts: 5
  deploymentPrefix: 'functions'
  versionFunctions: false

functions:
  serverless-python-requirements-test:
    name: lambda-usw2-serverless-python-requirements-test
    role: lambdaRole
    handler: index.lambda_handler
    module: lambda
    package:
      patterns:
        - '!**/.venv/**'
        - '!**/__pycache__/**'
        - '!**/__init__.py'

resources:
  Resources:
    lambdaRole:
      Type: AWS::IAM::Role
      Properties:
        Path: /
        RoleName: iam-role-serverless-python-requirements-test
        AssumeRolePolicyDocument:
          Version: '2012-10-17'
          Statement:
            - Effect: Allow
              Action: sts:AssumeRole
              Principal:
                Service:
                  - lambda.amazonaws.com
        Policies:
          - PolicyName: iam-policy-serverless-python-requirements-test
            PolicyDocument:
              Version: '2012-10-17'
              Statement:
                - Effect: Allow
                  Action:
                    - 'logs:CreateLogGroup'
                    - 'logs:CreateLogStream'
                    - 'logs:PutLogEvents'
                    - 's3:ListAllMyBuckets'
                  Resource: '*'

Command name and used flags

serverless deploy --verbose

Command output

Deploying serverless-python-requirements-test to stage dev (us-west-2)

Packaging
Generated requirements from /Users/user/Projects/serverless-python-requirements-test/lambda/requirements.txt in /Users/user/Projects/serverless-python-requirements-test/.serverless/lambda/requirements.txt
Using static cache of requirements found at /Users/user/Library/Caches/serverless-python-requirements/01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b_x86_64_slspyc
Excluding development dependencies for function "serverless-python-requirements-test"
Injecting required Python packages to package
Retrieving CloudFormation stack
Uploading
Uploading CloudFormation file to S3
Uploading State file to S3
Uploading service lambda-lambda-usw2-serverless-python-requirements-test.zip file to S3 (537 B)
Updating CloudFormation stack
Creating new change set
Waiting for new change set to be created
Change Set did not reach desired state, retrying
Executing created change set
  UPDATE_IN_PROGRESS - AWS::CloudFormation::Stack - cfn-stack-usw2-serverless-python-requirements-test
  UPDATE_IN_PROGRESS - AWS::Lambda::Function - ServerlessDashpythonDashrequirementsDashtestLambdaFunction
  UPDATE_COMPLETE - AWS::Lambda::Function - ServerlessDashpythonDashrequirementsDashtestLambdaFunction
  UPDATE_COMPLETE_CLEANUP_IN_PROGRESS - AWS::CloudFormation::Stack - cfn-stack-usw2-serverless-python-requirements-test
  UPDATE_COMPLETE - AWS::CloudFormation::Stack - cfn-stack-usw2-serverless-python-requirements-test
Retrieving CloudFormation stack
Removing old service artifacts from S3

✔ Service deployed to stack cfn-stack-usw2-serverless-python-requirements-test (29s)

functions:
  serverless-python-requirements-test: lambda-usw2-serverless-python-requirements-test (537 B)

Stack Outputs:
  ServerlessDeploymentBucketName: s3-usw2-serverless-python-requirements-test

Need a faster logging experience than CloudWatch? Try our Dev Mode in Console: run "serverless dev"

Environment information

Framework Core: 3.38.0 (local)
Plugin: 7.2.3
SDK: 4.5.1
@pgrzesik
Copy link
Collaborator

Hey @mrchops1024 👋 Sorry you've run into trouble. I tried reproducing it on a simpler case and I wasn't able to do so. Would you be able to check what is the difference in final zip between the deploys?

@mrchops1024
Copy link
Author

I just ran a deploy, which uploaded the .zip to S3 and ran a Cloudformation update. I copied the .zip file out of the .serverless directory and ran deploy again, with the same results.

Comparing the two .zip files and they look identical based on contents:

./requirements.txt
./index.py
./.completed_requirements

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants