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

Bug: sam local start-api fails to build docker image #7825

Open
hxk1633 opened this issue Jan 8, 2025 · 4 comments
Open

Bug: sam local start-api fails to build docker image #7825

hxk1633 opened this issue Jan 8, 2025 · 4 comments
Labels
area/rust Related to Support of Rust/Cargo/Cargo Lambda in SAM CLI stage/needs-investigation Requires a deeper investigation

Comments

@hxk1633
Copy link

hxk1633 commented Jan 8, 2025

Description:

When I run sam local start-api for a rust lambda sam project, it fails to build the docker image neccessary to emulate the rust lambda functions locally.

Steps to reproduce:

I created a rust lambda project and ran sam local start-api to run the lambda api locally.

Observed result:

2025-01-08 15:49:32,325 | Resolving code path. Cwd=/home/nrgxp/fleet-management-api, CodeUri=/home/nrgxp/fleet-management-api/target/lambda/organization                                                             
2025-01-08 15:49:32,326 | Resolved absolute path to code is /home/nrgxp/fleet-management-api/target/lambda/organization                                                                                              
2025-01-08 15:49:32,325 | Resolved real code path to /home/nrgxp/fleet-management-api/target/lambda/device                                                                                                           
2025-01-08 15:49:32,327 | Resolving code path. Cwd=/home/nrgxp/fleet-management-api, CodeUri=/home/nrgxp/fleet-management-api/target/lambda/organization                                                             
2025-01-08 15:49:32,329 | Resolved real code path to /home/nrgxp/fleet-management-api/target/lambda/organization                                                                                                     
2025-01-08 15:49:32,346 | watch resource /home/nrgxp/fleet-management-api/target/lambda/auth                                                                                                                         
2025-01-08 15:49:32,347 | Create Observer for resource /home/nrgxp/fleet-management-api/target/lambda/auth with recursive True                                                                                       
2025-01-08 15:49:32,349 | watch resource /home/nrgxp/fleet-management-api/target/lambda/auth's parent /home/nrgxp/fleet-management-api/target/lambda                                                                 
2025-01-08 15:49:32,350 | Code /home/nrgxp/fleet-management-api/target/lambda/auth is not a zip/jar file                                                                                                             
2025-01-08 15:49:32,353 | Local image was not found.                                                                                                                                                                 
2025-01-08 15:49:32,396 | Removing rapid images for repo public.ecr.aws/sam/emulation-provided.al2023                                                                                                                
Building image.....2025-01-08 15:49:32,511 | watch resource /home/nrgxp/fleet-management-api/target/lambda/device-ota-mqtt                                                                                                              
2025-01-08 15:49:32,512 | Create Observer for resource /home/nrgxp/fleet-management-api/target/lambda/device-ota-mqtt with recursive True                                                                            
2025-01-08 15:49:32,514 | watch resource /home/nrgxp/fleet-management-api/target/lambda/device-ota-mqtt's parent /home/nrgxp/fleet-management-api/target/lambda                                                      
2025-01-08 15:49:32,516 | Code /home/nrgxp/fleet-management-api/target/lambda/device-ota-mqtt is not a zip/jar file                                                                                                  
2025-01-08 15:49:32,519 | Local image was not found.                                                                                                                                                                 
2025-01-08 15:49:32,521 | Removing rapid images for repo public.ecr.aws/sam/emulation-provided.al2023                                                                                                                
Building image.....2025-01-08 15:49:32,595 | watch resource /home/nrgxp/fleet-management-api/target/lambda/deployment                                                                                                                   
2025-01-08 15:49:32,596 | Create Observer for resource /home/nrgxp/fleet-management-api/target/lambda/deployment with recursive True                                                                                 
2025-01-08 15:49:32,598 | watch resource /home/nrgxp/fleet-management-api/target/lambda/deployment's parent /home/nrgxp/fleet-management-api/target/lambda                                                           
2025-01-08 15:49:32,600 | Code /home/nrgxp/fleet-management-api/target/lambda/deployment is not a zip/jar file                                                                                                       
2025-01-08 15:49:32,604 | Local image was not found.                                                                                                                                                                 
2025-01-08 15:49:32,605 | Removing rapid images for repo public.ecr.aws/sam/emulation-provided.al2023                                                                                                                
Building image.....2025-01-08 15:49:32,712 | watch resource /home/nrgxp/fleet-management-api/target/lambda/device-ota                                                                                                                   
2025-01-08 15:49:32,713 | Create Observer for resource /home/nrgxp/fleet-management-api/target/lambda/device-ota with recursive True                                                                                 
2025-01-08 15:49:32,715 | watch resource /home/nrgxp/fleet-management-api/target/lambda/device-ota's parent /home/nrgxp/fleet-management-api/target/lambda                                                           
2025-01-08 15:49:32,716 | Code /home/nrgxp/fleet-management-api/target/lambda/device-ota is not a zip/jar file                                                                                                       
2025-01-08 15:49:32,719 | Local image was not found.                                                                                                                                                                 
2025-01-08 15:49:32,720 | Removing rapid images for repo public.ecr.aws/sam/emulation-provided.al2023                                                                                                                
Building image.....2025-01-08 15:49:32,756 | watch resource /home/nrgxp/fleet-management-api/target/lambda/group                                                                                                                        
2025-01-08 15:49:32,757 | Create Observer for resource /home/nrgxp/fleet-management-api/target/lambda/group with recursive True                                                                                      
2025-01-08 15:49:32,759 | watch resource /home/nrgxp/fleet-management-api/target/lambda/group's parent /home/nrgxp/fleet-management-api/target/lambda                                                                
2025-01-08 15:49:32,760 | Code /home/nrgxp/fleet-management-api/target/lambda/group is not a zip/jar file                                                                                                            
2025-01-08 15:49:32,763 | Local image was not found.                                                                                                                                                                 
2025-01-08 15:49:32,765 | Removing rapid images for repo public.ecr.aws/sam/emulation-provided.al2023                                                                                                                
Building image...2025-01-08 15:49:32,819 | watch resource /home/nrgxp/fleet-management-api/target/lambda/device                                                                                                                       
2025-01-08 15:49:32,820 | Create Observer for resource /home/nrgxp/fleet-management-api/target/lambda/device with recursive True                                                                                     
2025-01-08 15:49:32,822 | watch resource /home/nrgxp/fleet-management-api/target/lambda/device's parent /home/nrgxp/fleet-management-api/target/lambda                                                               
2025-01-08 15:49:32,824 | Code /home/nrgxp/fleet-management-api/target/lambda/device is not a zip/jar file                                                                                                           
2025-01-08 15:49:32,828 | Local image was not found.                                                                                                                                                                 
2025-01-08 15:49:32,830 | Removing rapid images for repo public.ecr.aws/sam/emulation-provided.al2023                                                                                                                
Building image...2025-01-08 15:49:32,878 | watch resource /home/nrgxp/fleet-management-api/target/lambda/organization                                                                                                                 
2025-01-08 15:49:32,879 | Create Observer for resource /home/nrgxp/fleet-management-api/target/lambda/organization with recursive True                                                                               
2025-01-08 15:49:32,881 | watch resource /home/nrgxp/fleet-management-api/target/lambda/organization's parent /home/nrgxp/fleet-management-api/target/lambda                                                         
2025-01-08 15:49:32,883 | Code /home/nrgxp/fleet-management-api/target/lambda/organization is not a zip/jar file                                                                                                     
2025-01-08 15:49:32,886 | Local image was not found.                                                                                                                                                                 
2025-01-08 15:49:32,888 | Removing rapid images for repo public.ecr.aws/sam/emulation-provided.al2023                                                                                                                
Building image......................................................................................................
2025-01-08 15:49:34,169 | Failed to build Docker Image                                                                                                                                                               
NoneType: None                                                                                                                                                                                                       
2025-01-08 15:49:34,174 | Loading AWS credentials from session with profile 'None'                                                                                                                                   
..
2025-01-08 15:49:34,264 | Failed to build Docker Image                                                                                                                                                               
NoneType: None                                                                                                                                                                                                       
2025-01-08 15:49:34,268 | Loading AWS credentials from session with profile 'None'                                                                                                                                   
......
2025-01-08 15:49:34,407 | Failed to build Docker Image                                                                                                                                                               
NoneType: None                                                                                                                                                                                                       
2025-01-08 15:49:34,413 | Loading AWS credentials from session with profile 'None'                                                                                                                                   
.
2025-01-08 15:49:34,471 | Failed to build Docker Image                                                                                                                                                               
NoneType: None                                                                                                                                                                                                       
.
2025-01-08 15:49:34,529 | Failed to build Docker Image                                                                                                                                                               
NoneType: None                                                                                                                                                                                                       
.
2025-01-08 15:49:34,550 | Failed to build Docker Image                                                                                                                                                               
NoneType: None                                                                                                                                                                                                       
.
2025-01-08 15:49:34,561 | Failed to build Docker Image                                                                                                                                                               
NoneType: None                                                                                                                                                                                                       
.
2025-01-08 15:49:34,567 | Failed to build Docker Image                                                                                                                                                               
NoneType: None                                                                                                                                                                                                       
2025-01-08 15:49:36,189 | Resolving code path. Cwd=/home/nrgxp/fleet-management-api, CodeUri=/home/nrgxp/fleet-management-api/target/lambda/product                                                                  
2025-01-08 15:49:36,191 | Resolved absolute path to code is /home/nrgxp/fleet-management-api/target/lambda/product                                                                                                   
2025-01-08 15:49:36,191 | Resolving code path. Cwd=/home/nrgxp/fleet-management-api, CodeUri=/home/nrgxp/fleet-management-api/target/lambda/product                                                                  
2025-01-08 15:49:36,192 | Resolved real code path to /home/nrgxp/fleet-management-api/target/lambda/product                                                                                                          
2025-01-08 15:49:36,230 | watch resource /home/nrgxp/fleet-management-api/target/lambda/product                                                                                                                      
2025-01-08 15:49:36,231 | Create Observer for resource /home/nrgxp/fleet-management-api/target/lambda/product with recursive True                                                                                    
2025-01-08 15:49:36,233 | watch resource /home/nrgxp/fleet-management-api/target/lambda/product's parent /home/nrgxp/fleet-management-api/target/lambda                                                              
2025-01-08 15:49:36,234 | Code /home/nrgxp/fleet-management-api/target/lambda/product is not a zip/jar file                                                                                                          
2025-01-08 15:49:36,236 | Local image was not found.                                                                                                                                                                 
2025-01-08 15:49:36,236 | Removing rapid images for repo public.ecr.aws/sam/emulation-provided.al2023                                                                                                                
Building image...2025-01-08 15:49:36,290 | Resolving code path. Cwd=/home/nrgxp/fleet-management-api, CodeUri=/home/nrgxp/fleet-management-api/target/lambda/release                                                                  
2025-01-08 15:49:36,291 | Resolved absolute path to code is /home/nrgxp/fleet-management-api/target/lambda/release                                                                                                   
2025-01-08 15:49:36,292 | Resolving code path. Cwd=/home/nrgxp/fleet-management-api, CodeUri=/home/nrgxp/fleet-management-api/target/lambda/release                                                                  
2025-01-08 15:49:36,293 | Resolved real code path to /home/nrgxp/fleet-management-api/target/lambda/release                                                                                                          
2025-01-08 15:49:36,308 | watch resource /home/nrgxp/fleet-management-api/target/lambda/release                                                                                                                      
2025-01-08 15:49:36,309 | Create Observer for resource /home/nrgxp/fleet-management-api/target/lambda/release with recursive True                                                                                    
2025-01-08 15:49:36,311 | watch resource /home/nrgxp/fleet-management-api/target/lambda/release's parent /home/nrgxp/fleet-management-api/target/lambda                                                              
2025-01-08 15:49:36,312 | Code /home/nrgxp/fleet-management-api/target/lambda/release is not a zip/jar file                                                                                                          
2025-01-08 15:49:36,315 | Local image was not found.                                                                                                                                                                 
2025-01-08 15:49:36,316 | Removing rapid images for repo public.ecr.aws/sam/emulation-provided.al2023                                                                                                                
Building image.......2025-01-08 15:49:36,436 | Resolving code path. Cwd=/home/nrgxp/fleet-management-api, CodeUri=/home/nrgxp/fleet-management-api/target/lambda/stage                                                                    
2025-01-08 15:49:36,437 | Resolved absolute path to code is /home/nrgxp/fleet-management-api/target/lambda/stage                                                                                                     
2025-01-08 15:49:36,438 | Resolving code path. Cwd=/home/nrgxp/fleet-management-api, CodeUri=/home/nrgxp/fleet-management-api/target/lambda/stage                                                                    
2025-01-08 15:49:36,439 | Resolved real code path to /home/nrgxp/fleet-management-api/target/lambda/stage                                                                                                            
2025-01-08 15:49:36,449 | watch resource /home/nrgxp/fleet-management-api/target/lambda/stage                                                                                                                        
2025-01-08 15:49:36,449 | Create Observer for resource /home/nrgxp/fleet-management-api/target/lambda/stage with recursive True                                                                                      
2025-01-08 15:49:36,451 | watch resource /home/nrgxp/fleet-management-api/target/lambda/stage's parent /home/nrgxp/fleet-management-api/target/lambda                                                                
2025-01-08 15:49:36,452 | Code /home/nrgxp/fleet-management-api/target/lambda/stage is not a zip/jar file                                                                                                            
2025-01-08 15:49:36,454 | Local image was not found.                                                                                                                                                                 
2025-01-08 15:49:36,454 | Removing rapid images for repo public.ecr.aws/sam/emulation-provided.al2023                                                                                                                
Building image..........................................
2025-01-08 15:49:37,562 | Failed to build Docker Image                                                                                                                                                               
NoneType: None                                                                                                                                                                                                       
.
2025-01-08 15:49:37,634 | Failed to build Docker Image                                                                                                                                                               
NoneType: None                                                                                                                                                                                                       
.
2025-01-08 15:49:37,640 | Failed to build Docker Image                                                                                                                                                               
NoneType: None                                                                                                                                                                                                       
2025-01-08 15:49:37,643 | Exception raised during the execution                                                                                                                                                      
2025-01-08 15:49:37,644 | Lambda functions containers initialization failed because of Error building docker image: The command '/bin/sh -c mv /var/rapid/aws-lambda-rie-x86_64 /var/rapid/aws-lambda-rie && chmod +x
/var/rapid/aws-lambda-rie' returned a non-zero code: 127   

Expected result:

I expect it to build the docker images for rust lambda emulation without any errors.

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

{
  "version": "1.132.0",
  "system": {
    "python": "3.11.10",
    "os": "Linux-6.8.0-51-generic-x86_64-with-glibc2.39"
  },
  "additional_dependencies": {
    "docker_engine": "27.4.1",
    "aws_cdk": "Not available",
    "terraform": "Not available"
  },
  "available_beta_feature_env_vars": [
    "SAM_CLI_BETA_FEATURES",
    "SAM_CLI_BETA_BUILD_PERFORMANCE",
    "SAM_CLI_BETA_TERRAFORM_SUPPORT",
    "SAM_CLI_BETA_RUST_CARGO_LAMBDA"
  ]
}

Add --debug flag to command you are running

@hxk1633 hxk1633 added the stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. label Jan 8, 2025
@hxk1633
Copy link
Author

hxk1633 commented Jan 8, 2025

I should also mention that I don't get this error when I use the provided.al2 runtime for the lambdas. But that runtime gives me this error mentioned in this issue: awslabs/aws-lambda-rust-runtime#874. So they recomended using provided.al2023 to fix the issue, but it fails to build the docker image as described in my post.

@roger-zhangg
Copy link
Member

Thanks for reporting, could you help to share the template you have to point to al2023? I'm trying to reproduce this issue.

@hxk1633
Copy link
Author

hxk1633 commented Jan 24, 2025

@roger-zhangg Sure, here is the template file:

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31

Parameters:
  Stage:
    Type: String
    Default: dev

Globals:
  Function:
    Tags:
      project: fleet_management_dev
    Environment:
      Variables:
        STAGE: dev
        POSTGRES_URL: *************************************
        REDIS_URL: *************************************
        MQTT_HOST: *************************************
        CRON_SERVICE_HOST:*************************************
        USER_JWT_SECRET: **********************************
        ACCESS_TOKEN_MAXAGE: 60
        REFRESH_TOKEN_MAXAGE: 36000
        AWS_ACCESS_KEY_ID: ***************************
        AWS_SECRET_ACCESS_KEY: ************************************
        AWS_DEFAULT_REGION: us-east-1
        RUST_BACKTRACE: full

Resources:
  ApiDeployment:
    Type: AWS::Serverless::Api
    Properties:
      StageName: !Ref Stage
      Cors:
        AllowCredentials: true
        AllowMethods: "'GET,POST,PATCH,PUT,DELETE'"
        AllowHeaders: "'Content-Type,Authorization,Accept,product-id'"
        AllowOrigin: "'*'"
      BinaryMediaTypes:
        - '*~1*'
        - 'multipart/form-data'
      Tags:
        project: !Sub fleet_management_${Stage}
  # --------------------------------------------------- Lambda functions --------------------------------------------------- #
  Auth:
    Type: AWS::Serverless::Function
    Metadata:
      BuildMethod: rust-cargolambda
      BuildProperties:
        Binary: auth
    Properties:
      CodeUri: target/lambda/auth/
      Handler: bootstrap
      Runtime: provided.al2023
      Timeout: 30
      Events:
        Login:
          Type: Api
          Properties:
            Path: /api/auth/login
            Method: post
            RestApiId: !Ref ApiDeployment
        Register:
          Type: Api
          Properties:
            Path: /api/auth/register
            Method: post
            RestApiId: !Ref ApiDeployment
        RefreshToken:
          Type: Api
          Properties:
            Path: /api/auth/refresh
            Method: post
            RestApiId: !Ref ApiDeployment
  Component:
    Type: AWS::Serverless::Function
    Metadata:
      BuildMethod: rust-cargolambda
      BuildProperties:
        Binary: component
    Properties:
      CodeUri: target/lambda/component/
      Handler: bootstrap
      Runtime: provided.al2023
      Events:
        CreateComponentType:
          Type: Api
          Properties:
            Path: /api/components
            Method: post
            RestApiId: !Ref ApiDeployment
        GetComponentType:
          Type: Api
          Properties:
            Path: /api/components/{id}
            Method: get
            RestApiId: !Ref ApiDeployment
        DeleteComponentType:
          Type: Api
          Properties:
            Path: /api/components/{id}
            Method: delete
            RestApiId: !Ref ApiDeployment
        GetComponentTypes:
          Type: Api
          Properties:
            Path: /api/products/{id}/components
            Method: get
            RestApiId: !Ref ApiDeployment
        GetComponentFirmwares:
          Type: Api
          Properties:
            Path: /api/components/{id}/firmware
            Method: get
            RestApiId: !Ref ApiDeployment
        CreateComponentFirmware:
          Type: Api
          Properties:
            Path: /api/components/{id}/firmware
            Method: post
            RestApiId: !Ref ApiDeployment
        GetComponentFirmware:
          Type: Api
          Properties:
            Path: /api/components/{id}/firmware/{firmware_id}
            Method: get
            RestApiId: !Ref ApiDeployment
        UpdateComponentFirmware:
          Type: Api
          Properties:
            Path: /api/components/{id}/firmware/{firmware_id}
            Method: put
            RestApiId: !Ref ApiDeployment
        DeleteComponentFirmware:
          Type: Api
          Properties:
            Path: /api/components/{id}/firmware/{firmware_id}
            Method: delete
            RestApiId: !Ref ApiDeployment
  Deployment:
    Type: AWS::Serverless::Function
    Metadata:
      BuildMethod: rust-cargolambda
      BuildProperties:
        Binary: deployment
    Properties:
      CodeUri: target/lambda/deployment/
      Handler: bootstrap
      Runtime: provided.al2023
      Events:
        CreateDeployment:
          Type: Api
          Properties:
            Path: /api/deployments
            Method: post
            RestApiId: !Ref ApiDeployment
        GetDeployment:
          Type: Api
          Properties:
            Path: /api/deployments/{id}
            Method: get
            RestApiId: !Ref ApiDeployment
        GetDeployments:
          Type: Api
          Properties:
            Path: /api/products/{id}/deployments
            Method: get
            RestApiId: !Ref ApiDeployment
        UpdateDeployment:
          Type: Api
          Properties:
            Path: /api/deployments/{id}
            Method: put
            RestApiId: !Ref ApiDeployment
        RunDeployment:
          Type: Api
          Properties:
            Path: /api/deployments/{id}/run
            Method: post
            RestApiId: !Ref ApiDeployment
        AbortDeployment:
          Type: Api
          Properties:
            Path: /api/deployments/{id}/abort
            Method: post
            RestApiId: !Ref ApiDeployment
  DeviceOtaMqtt:
    Type: AWS::Serverless::Function
    Metadata:
      BuildMethod: rust-cargolambda
      BuildProperties:
        Binary: device-ota-mqtt
    Properties:
      CodeUri: target/lambda/device-ota-mqtt/
      Handler: bootstrap
      Runtime: provided.al2023
      Events:
        OtaMqtt:
          Type: Api
          Properties:
            Path: /api/mqtt
            Method: post
            RestApiId: !Ref ApiDeployment
  DeviceOta:
    Type: AWS::Serverless::Function
    Metadata:
      BuildMethod: rust-cargolambda
      BuildProperties:
        Binary: device-ota
    Properties:      
      CodeUri: target/lambda/device-ota/
      Handler: bootstrap
      Runtime: provided.al2023
      Events:
        StartOta:
          Type: Api
          Properties:
            Path: /api/device/{device_sn}/ota/start
            Method: put
            RestApiId: !Ref ApiDeployment
        OtaUpdate:
          Type: Api
          Properties:
            Path: /api/device/{device_sn}/ota/update
            Method: post
            RestApiId: !Ref ApiDeployment
        OtaData:
          Type: Api
          Properties:
            Path: /api/device/{device_sn}/ota/data
            Method: post
            RestApiId: !Ref ApiDeployment
        OtaStatus:
          Type: Api
          Properties:
            Path: /api/device/{device_sn}/ota/status
            Method: post
            RestApiId: !Ref ApiDeployment
        OtaQueue:
          Type: Api
          Properties:
            Path: /api/ota-queue
            Method: post
            RestApiId: !Ref ApiDeployment
  Device:
    Type: AWS::Serverless::Function
    Metadata:
      BuildMethod: rust-cargolambda
      BuildProperties:
        Binary: device
    Properties:
      CodeUri: target/lambda/device/
      Handler: bootstrap
      Runtime: provided.al2023
      Events:
        CreateDevice:
          Type: Api
          Properties:
            Path: /api/devices
            Method: post
            RestApiId: !Ref ApiDeployment
        GetDevice:
          Type: Api
          Properties:
            Path: /api/devices/{id}
            Method: get
            RestApiId: !Ref ApiDeployment
        GetDevices:
          Type: Api
          Properties:
            Path: /api/products/{id}/devices
            Method: get
            RestApiId: !Ref ApiDeployment
        UpdateDevice:
          Type: Api
          Properties:
            Path: /api/devices/{id}
            Method: put
            RestApiId: !Ref ApiDeployment
        DeleteDevice:
          Type: Api
          Properties:
            Path: /api/devices/{id}
            Method: delete
            RestApiId: !Ref ApiDeployment
        GetDeviceJobs:
          Type: Api
          Properties:
            Path: /api/devices/{id}/jobs
            Method: get
            RestApiId: !Ref ApiDeployment
        CancelDeviceJobs:
          Type: Api
          Properties:
            Path: /api/devices/{id}/jobs/cancel
            Method: post
            RestApiId: !Ref ApiDeployment
  Group:
    Type: AWS::Serverless::Function
    Metadata:
      BuildMethod: rust-cargolambda
      BuildProperties:
        Binary: group
    Properties: 
      CodeUri: target/lambda/group/
      Handler: bootstrap
      Runtime: provided.al2023
      Events:
        CreateGroup:
          Type: Api
          Properties:
            Path: /api/groups
            Method: post
            RestApiId: !Ref ApiDeployment
        GetGroup:
          Type: Api
          Properties:
            Path: /api/groups/{id}
            Method: get
            RestApiId: !Ref ApiDeployment
        GetGroups:
          Type: Api
          Properties:
            Path: /api/products/{id}/groups
            Method: get
            RestApiId: !Ref ApiDeployment
        UpdateGroup:
          Type: Api
          Properties:
            Path: /api/groups/{id}
            Method: put
            RestApiId: !Ref ApiDeployment
        DeleteGroup:
          Type: Api
          Properties:
            Path: /api/groups/{id}
            Method: delete
            RestApiId: !Ref ApiDeployment
        GetGroupDevices:
          Type: Api
          Properties:
            Path: /api/groups/{id}/devices
            Method: get
            RestApiId: !Ref ApiDeployment
        AssignDevicesToGroup:
          Type: Api
          Properties:
            Path: /api/groups/{id}/devices
            Method: put
            RestApiId: !Ref ApiDeployment
  Organization:
    Type: AWS::Serverless::Function
    Metadata:
      BuildMethod: rust-cargolambda
      BuildProperties:
        Binary: organization
    Properties: 
      CodeUri: target/lambda/organization/
      Handler: bootstrap
      Runtime: provided.al2023
      Events:
        CreateOrganization:
          Type: Api
          Properties:
            Path: /api/organizations
            Method: post
            RestApiId: !Ref ApiDeployment
        GetOrganization:
          Type: Api
          Properties:
            Path: /api/organizations/{id}
            Method: get
            RestApiId: !Ref ApiDeployment
        GetOrganizations:
          Type: Api
          Properties:
            Path: /api/organizations
            Method: get
            RestApiId: !Ref ApiDeployment
        UpdateOrganization:
          Type: Api
          Properties:
            Path: /api/organizations/{id}
            Method: put
            RestApiId: !Ref ApiDeployment
        DeleteOrganization:
          Type: Api
          Properties:
            Path: /api/organizations/{id}
            Method: delete
            RestApiId: !Ref ApiDeployment
  Product:
    Type: AWS::Serverless::Function
    Metadata:
      BuildMethod: rust-cargolambda
      BuildProperties:
        Binary: product
    Properties: 
      CodeUri: target/lambda/product/
      Handler: bootstrap
      Runtime: provided.al2023
      Events:
        CreateProduct:
          Type: Api
          Properties:
            Path: /api/products
            Method: post
            RestApiId: !Ref ApiDeployment
        GetProduct:
          Type: Api
          Properties:
            Path: /api/products/{id}
            Method: get
            RestApiId: !Ref ApiDeployment
        GetProducts:
          Type: Api
          Properties:
            Path: /api/organizations/{orgId}/products
            Method: get
            RestApiId: !Ref ApiDeployment
        UpdateProduct:
          Type: Api
          Properties:
            Path: /api/products/{id}
            Method: put
            RestApiId: !Ref ApiDeployment
        DeleteProduct:
          Type: Api
          Properties:
            Path: /api/products/{id}
            Method: delete
            RestApiId: !Ref ApiDeployment
  Release:
    Type: AWS::Serverless::Function
    Metadata:
      BuildMethod: rust-cargolambda
      BuildProperties:
        Binary: release
    Properties: 
      CodeUri: target/lambda/release/
      Handler: bootstrap
      Runtime: provided.al2023
      Events:
        CreateRelease:
          Type: Api
          Properties:
            Path: /api/releases
            Method: post
            RestApiId: !Ref ApiDeployment
        GetRelease:
          Type: Api
          Properties:
            Path: /api/releases/{id}
            Method: get
            RestApiId: !Ref ApiDeployment
        GetReleases:
          Type: Api
          Properties:
            Path: /api/products/{id}/releases
            Method: get
            RestApiId: !Ref ApiDeployment
        UpdateRelease:
          Type: Api
          Properties:
            Path: /api/releases/{id}
            Method: put
            RestApiId: !Ref ApiDeployment
        DeleteRelease:
          Type: Api
          Properties:
            Path: /api/releases/{id}
            Method: delete
            RestApiId: !Ref ApiDeployment
  Stage:
    Type: AWS::Serverless::Function
    Metadata:
      BuildMethod: rust-cargolambda
      BuildProperties:
        Binary: stage
    Properties: 
      CodeUri: target/lambda/stage/
      Handler: bootstrap
      Runtime: provided.al2023
      Events:
        CreateStage:
          Type: Api
          Properties:
            Path: /api/organizations/{org_id}/stages
            Method: post
            RestApiId: !Ref ApiDeployment
        GetStages:
          Type: Api
          Properties:
            Path: /api/organizations/{org_id}/stages
            Method: get
            RestApiId: !Ref ApiDeployment
        GetStage:
          Type: Api
          Properties:
            Path: /api/stages/{id}
            Method: get
            RestApiId: !Ref ApiDeployment
        UpdateStage:
          Type: Api
          Properties:
            Path: /api/stages/{id}
            Method: patch
            RestApiId: !Ref ApiDeployment
        DeleteStage:
          Type: Api
          Properties:
            Path: /api/stages/{id}
            Method: delete
            RestApiId: !Ref ApiDeployment

@roger-zhangg
Copy link
Member

Thanks, will try and reproduce this

@roger-zhangg roger-zhangg added stage/needs-investigation Requires a deeper investigation area/rust Related to Support of Rust/Cargo/Cargo Lambda in SAM CLI and removed stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. labels Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/rust Related to Support of Rust/Cargo/Cargo Lambda in SAM CLI stage/needs-investigation Requires a deeper investigation
Projects
None yet
Development

No branches or pull requests

2 participants